1 # Creates a systemd unit file
7 # @attr name [Pattern['^.+\.(service|socket|device|mount|automount|swap|target|path|timer|slice|scope)$']]
8 # The target unit file to create
10 # * Must not contain ``/``
13 # The main systemd configuration path
16 # The full content of the unit file
18 # * Mutually exclusive with ``$source``
21 # The ``File`` resource compatible ``source``
23 # * Mutually exclusive with ``$content``
26 # If set, will force the file to be a symlink to the given target
28 # * Mutually exclusive with both ``$source`` and ``$content``
31 # If set, will manage the unit enablement status.
34 # If set, will manage the state of the unit.
36 define systemd::unit_file(
37 Enum['present', 'absent', 'file'] $ensure = 'present',
38 Stdlib::Absolutepath $path = '/etc/systemd/system',
39 Optional[String] $content = undef,
40 Optional[String] $source = undef,
41 Optional[Stdlib::Absolutepath] $target = undef,
42 Optional[Variant[Boolean, Enum['mask']]] $enable = undef,
43 Optional[Boolean] $active = undef,
47 assert_type(Systemd::Unit, $name)
52 $_ensure = $ensure ? {
58 file { "${path}/${name}":
66 notify => Class['systemd::systemctl::daemon_reload'],
69 if $enable != undef or $active != undef {
73 provider => 'systemd',
74 subscribe => File["${path}/${name}"],
75 require => Class['systemd::systemctl::daemon_reload'],