21 changes: 19 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,25 @@ All notable changes to this project will be documented in this file.
Each new release typically also includes the latest modulesync defaults.
These should not affect the functionality of the module.

## [v5.0.0](https://github.com/voxpupuli/puppet-systemd/tree/v5.0.0) (2023-05-15)
## [v5.1.0](https://github.com/voxpupuli/puppet-systemd/tree/v5.1.0) (2023-06-15)

[Full Changelog](https://github.com/voxpupuli/puppet-systemd/compare/v5.0.0...v5.1.0)

**Implemented enhancements:**

- Support StandardOutput, StandardError and RequiresMountsFor. [\#353](https://github.com/voxpupuli/puppet-systemd/pull/353) ([traylenator](https://github.com/traylenator))
- Allow WorkingDirectory to be specified in \[Service\] [\#352](https://github.com/voxpupuli/puppet-systemd/pull/352) ([traylenator](https://github.com/traylenator))
- Socket support for manage unit and dropin [\#350](https://github.com/voxpupuli/puppet-systemd/pull/350) ([traylenator](https://github.com/traylenator))
- Relax stdlib dependency version requirements [\#349](https://github.com/voxpupuli/puppet-systemd/pull/349) ([smortex](https://github.com/smortex))
- No insistence on unit\_entry ever or service\_entry with absent manage\_unit [\#345](https://github.com/voxpupuli/puppet-systemd/pull/345) ([traylenator](https://github.com/traylenator))
- Add comment in manage\_unit deployed files [\#333](https://github.com/voxpupuli/puppet-systemd/pull/333) ([traylenator](https://github.com/traylenator))

**Closed issues:**

- Feature Request for socket unit files [\#348](https://github.com/voxpupuli/puppet-systemd/issues/348)
- Module require an old version of puppetlabs-inifile [\#343](https://github.com/voxpupuli/puppet-systemd/issues/343)

## [v5.0.0](https://github.com/voxpupuli/puppet-systemd/tree/v5.0.0) (2023-06-01)

[Full Changelog](https://github.com/voxpupuli/puppet-systemd/compare/v4.2.0...v5.0.0)

Expand Down Expand Up @@ -40,7 +58,6 @@ These should not affect the functionality of the module.

**Merged pull requests:**

- Release 4.2.0 [\#332](https://github.com/voxpupuli/puppet-systemd/pull/332) ([ekohl](https://github.com/ekohl))
- Stick to the Puppet language style guide in examples [\#327](https://github.com/voxpupuli/puppet-systemd/pull/327) ([smortex](https://github.com/smortex))
- Fix `manage_unit` example in README.md [\#326](https://github.com/voxpupuli/puppet-systemd/pull/326) ([Enucatl](https://github.com/Enucatl))

Expand Down
143 changes: 140 additions & 3 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
* [`Systemd::Unit::Path`](#Systemd--Unit--Path): Possible keys for the [Path] section of a unit file
* [`Systemd::Unit::Service`](#Systemd--Unit--Service): Possible keys for the [Service] section of a unit file
* [`Systemd::Unit::Service::Exec`](#Systemd--Unit--Service--Exec): Possible strings for ExecStart, ExecStartPrep, ...
* [`Systemd::Unit::Socket`](#Systemd--Unit--Socket): Possible keys for the [Socket] section of a unit file
* [`Systemd::Unit::Timer`](#Systemd--Unit--Timer): Possible keys for the [Timer] section of a unit file
* [`Systemd::Unit::Unit`](#Systemd--Unit--Unit): Possible keys for the [Unit] section of a unit file

Expand Down Expand Up @@ -826,6 +827,7 @@ The following parameters are available in the `systemd::manage_dropin` defined t
* [`install_entry`](#-systemd--manage_dropin--install_entry)
* [`timer_entry`](#-systemd--manage_dropin--timer_entry)
* [`path_entry`](#-systemd--manage_dropin--path_entry)
* [`socket_entry`](#-systemd--manage_dropin--socket_entry)

##### <a name="-systemd--manage_dropin--unit"></a>`unit`

Expand Down Expand Up @@ -953,6 +955,14 @@ key value pairs for [Path] section of the unit file

Default value: `undef`

##### <a name="-systemd--manage_dropin--socket_entry"></a>`socket_entry`

Data type: `Optional[Systemd::Unit::Socket]`

key value pairs for the [Socket] section of the unit file

Default value: `undef`

### <a name="systemd--manage_unit"></a>`systemd::manage_unit`

Generate unit file from template
Expand Down Expand Up @@ -984,19 +994,59 @@ systemd::manage_unit { 'myrunner.service':
```puppet
systemd::manage_unit { 'passwd-mon.path':
ensure => present,
unit_entry => {
unit_entry => {
'Description' => 'Monitor the passwd file',
},
path_entry => {
'PathModified => '/etc/passwd',
'Unit' => 'passwd-mon.service',
},
install_entry => {
'WantedBy' => 'multi-user.target',
'WantedBy' => 'multi-user.target',
},
}
```

##### Generate a socket and service (xinetd style)

```puppet
systemd::manage_unit {'arcd.socket':
ensure => 'present',
unit_entry => {
'Description' => 'arcd.service',
}
socket_entry => {
'ListenStream' => 4241,
'Accept' => true,
'BindIPv6Only' => 'both',
install_entry => {
'WantedBy' => 'sockets.target',
}
}
systemd::manage_unit{'arcd@.service':
ensure => 'present',
enable => true,
active => true,
unit_entry => {
'Description' => 'arc sever for %i',
},
service_entry => {
'Type' => 'simple',
'ExecStart' => /usr/sbin/arcd /usr/libexec/arcd/arcd.pl,
'StandardInput' => 'socket',
}
```

##### Remove a unit file

```puppet
systemd::manage_unit { 'my.service':
ensure => 'absent',
}
```

#### Parameters

The following parameters are available in the `systemd::manage_unit` defined type:
Expand All @@ -1019,6 +1069,7 @@ The following parameters are available in the `systemd::manage_unit` defined typ
* [`install_entry`](#-systemd--manage_unit--install_entry)
* [`timer_entry`](#-systemd--manage_unit--timer_entry)
* [`path_entry`](#-systemd--manage_unit--path_entry)
* [`socket_entry`](#-systemd--manage_unit--socket_entry)

##### <a name="-systemd--manage_unit--name"></a>`name`

Expand Down Expand Up @@ -1124,10 +1175,12 @@ Default value: `true`

##### <a name="-systemd--manage_unit--unit_entry"></a>`unit_entry`

Data type: `Systemd::Unit::Unit`
Data type: `Optional[Systemd::Unit::Unit]`

key value pairs for [Unit] section of the unit file.

Default value: `undef`

##### <a name="-systemd--manage_unit--service_entry"></a>`service_entry`

Data type: `Optional[Systemd::Unit::Service]`
Expand Down Expand Up @@ -1160,6 +1213,14 @@ key value pairs for [Path] section of the unit file.

Default value: `undef`

##### <a name="-systemd--manage_unit--socket_entry"></a>`socket_entry`

Data type: `Optional[Systemd::Unit::Socket]`

kev value paors for [Socket] section of the unit file.

Default value: `undef`

### <a name="systemd--modules_load"></a>`systemd::modules_load`

Creates a modules-load.d drop file
Expand Down Expand Up @@ -2255,6 +2316,7 @@ Struct[{
Optional['AmbientCapabilities'] => Variant[Pattern[/^CAP_[A-Z_]+$/],Array[Pattern[/^CAP_[A-Z_]+$/],1]],
Optional['User'] => String[1],
Optional['Group'] => String[1],
Optional['WorkingDirectory'] => String[0],
Optional['Type'] => Enum['simple', 'exec', 'forking', 'oneshot', 'dbus', 'notify', 'idle'],
Optional['ExitType'] => Enum['main', 'cgroup'],
Optional['RemainAfterExit'] => Boolean,
Expand Down Expand Up @@ -2297,6 +2359,8 @@ Struct[{
Stdlib::Unixpath,Pattern[/-\/.+/],
Array[Variant[Stdlib::Unixpath,Pattern[/-\/.+/]],1],
],
Optional['StandardOutput'] => Variant[Enum['inherit','null','tty','journal','kmsg','journal+console','kmsg+console','socket'],Pattern[/\A(file:|append:|truncate:).+$\z/]],
Optional['StandardError'] => Variant[Enum['inherit','null','tty','journal','kmsg','journal+console','kmsg+console','socket'],Pattern[/\A(file:|append:|truncate:).+$\z/]],
}]
```

Expand All @@ -2310,6 +2374,78 @@ Possible strings for ExecStart, ExecStartPrep, ...

Alias of `Variant[Enum[''], Pattern[/^[@\-:]*(\+|!|!!)?[@\-:]*\/.*/], Pattern[/^[@\-:]*(\+|!|!!)?[@\-:]*[^\/]*(\s.*)?$/]]`

### <a name="Systemd--Unit--Socket"></a>`Systemd::Unit::Socket`

Possible keys for the [Socket] section of a unit file

* **See also**
* https://www.freedesktop.org/software/systemd/man/systemd.socket.html

Alias of

```puppet
Struct[{
Optional['ListenStream'] => Variant[Stdlib::Port,String[1]],
Optional['ListenDatagram'] => Variant[Stdlib::Port,String[1]],
Optional['ListenSequentialPacket'] => Variant[Stdlib::Port,String[1]],
Optional['ListenFIFO'] => Stdlib::Unixpath,
Optional['ListenSpecial'] => Stdlib::Unixpath,
Optional['ListenNetlink'] => String[1],
Optional['ListenMessageQueue'] => Pattern[/\A\/.*\z/],
Optional['ListenUSBFunction'] => Stdlib::Unixpath,
Optional['SocketProtocol'] => Enum['udplite', 'sctp'],
Optional['BindIPv6Only'] => Enum['default', 'both', 'ipv6-only'],
Optional['Backlog'] => Integer[0],
Optional['BindToDevice'] => String[1],
Optional['SocketUser'] => String[1],
Optional['SocketGroup'] => String[1],
Optional['SocketMode'] => Stdlib::Filemode,
Optional['DirectoryMode'] => Stdlib::Filemode,
Optional['Accept'] => Boolean,
Optional['Writable'] => Boolean,
Optional['FlushPending'] => Boolean,
Optional['MaxConnections'] => Integer[0],
Optional['MaxConnectionsPerSource'] => Integer[0],
Optional['KeepAlive'] => Boolean,
Optional['KeepAliveTimeSec'] => Integer[0],
Optional['KeepAliveIntervalSec'] => Integer[0],
Optional['KeepAliveProbes'] => Integer[0],
Optional['NoDelay'] => Boolean,
Optional['Priority'] => Integer,
Optional['DeferAcceptSec'] => Integer[0],
Optional['ReceiveBuffer'] => Variant[Integer[0],String[1]],
Optional['SendBuffer'] => Variant[Integer[0],String[1]],
Optional['IPTOS'] => Variant[Integer,Enum['low-delay', 'throughput', 'reliability', 'low-cost']],
Optional['IPTTL'] => Integer[0],
Optional['Mark'] => String[1],
Optional['ReusePort'] => Boolean,
Optional['SmackLabel'] => String[1],
Optional['SmackLabelIPIn'] => String[1],
Optional['SmackLabelIPOut'] => String[1],
Optional['SELinuxContextFromNet'] => Boolean,
Optional['PipeSize'] => Variant[Integer[0],String[1]],
Optional['FreeBind'] => Boolean,
Optional['Transparent'] => Boolean,
Optional['Broadcast'] => Boolean,
Optional['PassCredentials'] => Boolean,
Optional['PassSecurity'] => Boolean,
Optional['PassPacketInfo'] => Boolean,
Optional['Timestamping'] => Enum['off', 'us', 'usec', 'ns'],
Optional['TCPCongestion'] => Enum['westwood', 'veno', 'cubic', 'lp'],
Optional['ExecStartPre'] => Variant[Systemd::Unit::Service::Exec,Array[Systemd::Unit::Service::Exec,1]],
Optional['ExecStartPost'] => Variant[Systemd::Unit::Service::Exec,Array[Systemd::Unit::Service::Exec,1]],
Optional['ExecStopPre'] => Variant[Systemd::Unit::Service::Exec,Array[Systemd::Unit::Service::Exec,1]],
Optional['ExecStopPost'] => Variant[Systemd::Unit::Service::Exec,Array[Systemd::Unit::Service::Exec,1]],
Optional['TimeoutSec'] => String[1],
Optional['Service'] => Systemd::Unit,
Optional['RemoveOnStop'] => Boolean,
Optional['Symlinks'] => Variant[Stdlib::Unixpath,Array[Stdlib::Unixpath,1]],
Optional['FileDescriptorName'] => String[1,255],
Optional['TriggerLimitIntervalSec'] => String[1],
Optional['TriggerLimitBurst'] => Integer[0],
}]
```

### <a name="Systemd--Unit--Timer"></a>`Systemd::Unit::Timer`

Possible keys for the [Timer] section of a unit file
Expand Down Expand Up @@ -2363,6 +2499,7 @@ Struct[{
Optional['After'] => Variant[Enum[''],Systemd::Unit,Array[Variant[Enum[''],Systemd::Unit],1]],
Optional['OnFailure'] => Variant[Enum[''],Systemd::Unit,Array[Variant[Enum[''],Systemd::Unit],1]],
Optional['OnSuccess'] => Variant[Enum[''],Systemd::Unit,Array[Variant[Enum[''],Systemd::Unit],1]],
Optional['RequiresMountsFor'] => Variant[Enum[''],Stdlib::Unixpath,Array[Variant[Enum[''],Stdlib::Unixpath],1]],
# Conditions and Asserts
Optional['ConditionPathExists'] => Variant[Enum[''],Stdlib::Unixpath,Pattern[/^!.*$/],Array[Variant[Enum[''],Stdlib::Unixpath,Pattern[/^!.*$/]],1]],
Optional['ConditionPathIsDirectory'] => Variant[Enum[''],Stdlib::Unixpath,Pattern[/^!.*$/],Array[Variant[Enum[''],Stdlib::Unixpath,Pattern[/^!.*$/]],1]],
Expand Down
3 changes: 3 additions & 0 deletions manifests/manage_dropin.pp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
# @param install_entry key value pairs for [Install] section of the unit file
# @param timer_entry key value pairs for [Timer] section of the unit file
# @param path_entry key value pairs for [Path] section of the unit file
# @param socket_entry key value pairs for the [Socket] section of the unit file
#
define systemd::manage_dropin (
Systemd::Unit $unit,
Expand All @@ -66,6 +67,7 @@
Optional[Systemd::Unit::Service] $service_entry = undef,
Optional[Systemd::Unit::Timer] $timer_entry = undef,
Optional[Systemd::Unit::Path] $path_entry = undef,
Optional[Systemd::Unit::Socket] $socket_entry = undef,
) {
if $timer_entry and $unit !~ Pattern['^[^/]+\.timer'] {
fail("Systemd::Manage_dropin[${name}]: for unit ${unit} timer_entry is only valid for timer units")
Expand Down Expand Up @@ -93,6 +95,7 @@
'install_entry' => $install_entry,
'timer_entry' => $timer_entry,
'path_entry' => $path_entry,
'socket_entry' => $socket_entry,
}),
}
}
47 changes: 42 additions & 5 deletions manifests/manage_unit.pp
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,52 @@
# @example Genenerate a path unit
# systemd::manage_unit { 'passwd-mon.path':
# ensure => present,
# unit_entry => {
# unit_entry => {
# 'Description' => 'Monitor the passwd file',
# },
# path_entry => {
# 'PathModified => '/etc/passwd',
# 'Unit' => 'passwd-mon.service',
# },
# install_entry => {
# 'WantedBy' => 'multi-user.target',
# 'WantedBy' => 'multi-user.target',
# },
# }
#
# @example Generate a socket and service (xinetd style)
# systemd::manage_unit {'arcd.socket':
# ensure => 'present',
# unit_entry => {
# 'Description' => 'arcd.service',
# }
# socket_entry => {
# 'ListenStream' => 4241,
# 'Accept' => true,
# 'BindIPv6Only' => 'both',
# install_entry => {
# 'WantedBy' => 'sockets.target',
# }
# }
#
# systemd::manage_unit{'arcd@.service':
# ensure => 'present',
# enable => true,
# active => true,
# unit_entry => {
# 'Description' => 'arc sever for %i',
# },
#
# service_entry => {
# 'Type' => 'simple',
# 'ExecStart' => /usr/sbin/arcd /usr/libexec/arcd/arcd.pl,
# 'StandardInput' => 'socket',
# }
#
# @example Remove a unit file
# systemd::manage_unit { 'my.service':
# ensure => 'absent',
# }
#
# @param name [Pattern['^[^/]+\.(service|socket|device|mount|automount|swap|target|path|timer|slice|scope)$']]
# The target unit file to create
#
Expand All @@ -57,6 +91,7 @@
# @param install_entry key value pairs for [Install] section of the unit file.
# @param timer_entry key value pairs for [Timer] section of the unit file
# @param path_entry key value pairs for [Path] section of the unit file.
# @param socket_entry kev value paors for [Socket] section of the unit file.
#
define systemd::manage_unit (
Enum['present', 'absent'] $ensure = 'present',
Expand All @@ -72,10 +107,11 @@
Hash[String[1], Any] $service_parameters = {},
Boolean $daemon_reload = true,
Optional[Systemd::Unit::Install] $install_entry = undef,
Systemd::Unit::Unit $unit_entry,
Optional[Systemd::Unit::Unit] $unit_entry = undef,
Optional[Systemd::Unit::Service] $service_entry = undef,
Optional[Systemd::Unit::Timer] $timer_entry = undef,
Optional[Systemd::Unit::Path] $path_entry = undef,
Optional[Systemd::Unit::Socket] $socket_entry = undef,
) {
assert_type(Systemd::Unit, $name)

Expand All @@ -87,8 +123,8 @@
fail("Systemd::Manage_unit[${name}]: path_entry is only valid for path units")
}

if $name =~ Pattern['^[^/]+\.service'] and !$service_entry {
fail("Systemd::Manage_unit[${name}]: service_entry is only required for service units")
if $ensure != 'absent' and $name =~ Pattern['^[^/]+\.service'] and !$service_entry {
fail("Systemd::Manage_unit[${name}]: service_entry is required for service units")
}

systemd::unit_file { $name:
Expand All @@ -109,6 +145,7 @@
'install_entry' => $install_entry,
'timer_entry' => $timer_entry,
'path_entry' => $path_entry,
'socket_entry' => $socket_entry,
}),
}
}
Loading