2 changes: 1 addition & 1 deletion .msync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/

modulesync_config_version: '5.5.0'
modulesync_config_version: '6.0.0'
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,32 @@ 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)

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

**Breaking changes:**

- Drop Puppet 6 support [\#342](https://github.com/voxpupuli/puppet-systemd/pull/342) ([bastelfreak](https://github.com/bastelfreak))

**Implemented enhancements:**

- Refactor unit template [\#344](https://github.com/voxpupuli/puppet-systemd/pull/344) ([traylenator](https://github.com/traylenator))
- Allow LimitCORE in \[Service\] for manage\_unit/dropin [\#341](https://github.com/voxpupuli/puppet-systemd/pull/341) ([traylenator](https://github.com/traylenator))
- Allow SyslogIdentifier, KillMode and KillSignal to \[service\] section [\#339](https://github.com/voxpupuli/puppet-systemd/pull/339) ([traylenator](https://github.com/traylenator))
- Addition of path directives to manage\_unit/dropin [\#337](https://github.com/voxpupuli/puppet-systemd/pull/337) ([traylenator](https://github.com/traylenator))
- Addition of timer directives to manage\_unit and manage\_dropin [\#335](https://github.com/voxpupuli/puppet-systemd/pull/335) ([traylenator](https://github.com/traylenator))
- Allow DefaultDependencies to be set in \[Unit\] section [\#334](https://github.com/voxpupuli/puppet-systemd/pull/334) ([traylenator](https://github.com/traylenator))

**Closed issues:**

- Increase inifile version in metadata to \< 7.0.0 [\#336](https://github.com/voxpupuli/puppet-systemd/issues/336)

**Merged pull requests:**

- Increase inifile dependency upper version to \< 7.0.0 [\#338](https://github.com/voxpupuli/puppet-systemd/pull/338) ([canihavethisone](https://github.com/canihavethisone))
- Group spec expectations in a single example [\#331](https://github.com/voxpupuli/puppet-systemd/pull/331) ([ekohl](https://github.com/ekohl))

## [v4.2.0](https://github.com/voxpupuli/puppet-systemd/tree/v4.2.0) (2023-04-18)

[Full Changelog](https://github.com/voxpupuli/puppet-systemd/compare/v4.1.0...v4.2.0)
Expand All @@ -14,6 +40,7 @@ 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
13 changes: 7 additions & 6 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
source ENV['GEM_SOURCE'] || 'https://rubygems.org'

group :test do
gem 'voxpupuli-test', '~> 5.4', :require => false
gem 'voxpupuli-test', '~> 6.0', :require => false
gem 'coveralls', :require => false
gem 'simplecov-console', :require => false
gem 'puppet_metadata', '~> 2.0', :require => false
gem 'puppet_metadata', '~> 3.0', :require => false
end

group :development do
Expand All @@ -16,18 +16,19 @@ group :development do
end

group :system_tests do
gem 'voxpupuli-acceptance', '~> 1.0', :require => false
gem 'voxpupuli-acceptance', '~> 2.0', :require => false
end

group :release do
gem 'github_changelog_generator', '>= 1.16.1', :require => false if RUBY_VERSION >= '2.5'
gem 'voxpupuli-release', '~> 2.0', :require => false
gem 'github_changelog_generator', '>= 1.16.1', :require => false
gem 'voxpupuli-release', '~> 3.0', :require => false
gem 'faraday-retry', '~> 2.1', :require => false
end

gem 'rake', :require => false
gem 'facter', ENV['FACTER_GEM_VERSION'], :require => false, :groups => [:test]

puppetversion = ENV['PUPPET_GEM_VERSION'] || '>= 6.0'
puppetversion = ENV['PUPPET_GEM_VERSION'] || '~> 7.24'
gem 'puppet', puppetversion, :require => false, :groups => [:test]

# vim: syntax=ruby
106 changes: 105 additions & 1 deletion REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
* [`Systemd::ServiceLimits`](#Systemd--ServiceLimits): Matches Systemd Service Limit Struct
* [`Systemd::Unit`](#Systemd--Unit): custom datatype that validates different filenames for systemd units and unit templates
* [`Systemd::Unit::Install`](#Systemd--Unit--Install): Possible keys for the [Install] section of a unit file
* [`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::Timer`](#Systemd--Unit--Timer): Possible keys for the [Timer] section of a unit file
Expand Down Expand Up @@ -781,6 +782,30 @@ systemd::manage_dropin { 'myconf.conf':
}
```

##### drop in file to change a path unit and override TriggerLimitBurst

```puppet
systemd::manage_dropin { 'triggerlimit.conf':
ensure => present,
unit => 'passwd.path',
path_entry => {
'TriggerLimitBurst' => 100,
},
}
```

##### drop in file to override the LimitCORE for a service

```puppet
systemd::manage_dropin { 'corelimit.conf':
ensure => present,
unit => 'rsyslog.conf',
path_entry => {
'LimitCORE' => 'infinity',
},
}
```

#### Parameters

The following parameters are available in the `systemd::manage_dropin` defined type:
Expand All @@ -800,6 +825,7 @@ The following parameters are available in the `systemd::manage_dropin` defined t
* [`service_entry`](#-systemd--manage_dropin--service_entry)
* [`install_entry`](#-systemd--manage_dropin--install_entry)
* [`timer_entry`](#-systemd--manage_dropin--timer_entry)
* [`path_entry`](#-systemd--manage_dropin--path_entry)

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

Expand Down Expand Up @@ -919,6 +945,14 @@ key value pairs for [Timer] section of the unit file

Default value: `undef`

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

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

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

Default value: `undef`

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

Generate unit file from template
Expand All @@ -945,6 +979,24 @@ systemd::manage_unit { 'myrunner.service':
}
```

##### Genenerate a path unit

```puppet
systemd::manage_unit { 'passwd-mon.path':
ensure => present,
unit_entry => {
'Description' => 'Monitor the passwd file',
},
path_entry => {
'PathModified => '/etc/passwd',
'Unit' => 'passwd-mon.service',
},
install_entry => {
'WantedBy' => 'multi-user.target',
},
}
```

#### Parameters

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

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

Expand Down Expand Up @@ -1099,6 +1152,14 @@ key value pairs for [Timer] section of the unit file

Default value: `undef`

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

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

key value pairs for [Path] 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 @@ -2155,6 +2216,30 @@ Struct[{
}]
```

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

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

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

Alias of

```puppet
Struct[{
Optional['PathExists'] => Variant[Enum[''],Stdlib::Unixpath,Array[Variant[Enum[''],Stdlib::Unixpath],1]],
Optional['PathExistsGlob'] => Variant[Enum[''],Stdlib::Unixpath,Array[Variant[Enum[''],Stdlib::Unixpath],1]],
Optional['PathChanged'] => Variant[Enum[''],Stdlib::Unixpath,Array[Variant[Enum[''],Stdlib::Unixpath],1]],
Optional['PathModified'] => Variant[Enum[''],Stdlib::Unixpath,Array[Variant[Enum[''],Stdlib::Unixpath],1]],
Optional['DirectoryNotEmpty'] => Variant[Enum[''],Stdlib::Unixpath,Array[Variant[Enum[''],Stdlib::Unixpath],1]],
Optional['Unit'] => Systemd::Unit,
Optional['MakeDirectory'] => Boolean,
Optional['DirectoryMode'] => Pattern[/\A[0-7]{1,4}\z/],
Optional['TriggerLimitIntervalSec'] => String,
Optional['TriggerLimitBurst'] => Integer[0],
}]
```

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

Possible keys for the [Service] section of a unit file
Expand Down Expand Up @@ -2183,6 +2268,10 @@ Struct[{
Optional['ExecReload'] => Variant[Systemd::Unit::Service::Exec,Array[Systemd::Unit::Service::Exec,1]],
Optional['ExecStop'] => 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['KillSignal'] => Pattern[/^SIG[A-Z]+$/],
Optional['KillMode'] => Enum['control-group', 'mixed', 'process', 'none'],
Optional['SyslogIdentifier'] => String,
Optional['LimitCORE'] => Pattern['^(infinity|((\d+(K|M|G|T|P|E)?(:\d+(K|M|G|T|P|E)?)?)))$'],
Optional['RestartSec'] => String,
Optional['TimeoutStartSec'] => String,
Optional['TimeoutStopSec'] => String,
Expand Down Expand Up @@ -2232,7 +2321,21 @@ Alias of

```puppet
Struct[{
Optional['OnCalendar'] => Variant[String,Array[String,1]],
Optional['OnActiveSec'] => Variant[Integer[0],String,Array[Variant[Integer[0],String]]],
Optional['OnBootSec'] => Variant[Integer[0],String,Array[Variant[Integer[0],String]]],
Optional['OnStartUpSec'] => Variant[Integer[0],String,Array[Variant[Integer[0],String]]],
Optional['OnUnitActiveSec'] => Variant[Integer[0],String,Array[Variant[Integer[0],String]]],
Optional['OnUnitInactiveSec'] => Variant[Integer[0],String,Array[Variant[Integer[0],String]]],
Optional['OnCalendar'] => Variant[Integer[0],String,Array[Variant[Integer[0],String]]],
Optional['AccuracySec'] => Variant[Integer[0],String],
Optional['RandomizedDelaySec'] => Variant[Integer[0],String],
Optional['FixedRandomDelay'] => Boolean,
Optional['OnClockChange'] => Boolean,
Optional['OnTimezoneChange'] => Boolean,
Optional['Unit'] => Systemd::Unit,
Optional['Persistent'] => Boolean,
Optional['WakeSystem'] => Boolean,
Optional['RemainAfterElapse'] => Boolean,
}]
```

Expand All @@ -2249,6 +2352,7 @@ Alias of
Struct[{
Optional['Description'] => Variant[String,Array[String,1]],
Optional['Documentation'] => Variant[String,Array[String,1]],
Optional['DefaultDependencies'] => Boolean,
Optional['Wants'] => Variant[Enum[''],Systemd::Unit,Array[Variant[Enum[''],Systemd::Unit],1]],
Optional['Requires'] => Variant[Enum[''],Systemd::Unit,Array[Variant[Enum[''],Systemd::Unit],1]],
Optional['Requisite'] => Variant[Enum[''],Systemd::Unit,Array[Variant[Enum[''],Systemd::Unit],1]],
Expand Down
27 changes: 26 additions & 1 deletion manifests/manage_dropin.pp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,24 @@
# },
# }
#
# @example drop in file to change a path unit and override TriggerLimitBurst
# systemd::manage_dropin { 'triggerlimit.conf':
# ensure => present,
# unit => 'passwd.path',
# path_entry => {
# 'TriggerLimitBurst' => 100,
# },
# }
#
# @example drop in file to override the LimitCORE for a service
# systemd::manage_dropin { 'corelimit.conf':
# ensure => present,
# unit => 'rsyslog.conf',
# path_entry => {
# 'LimitCORE' => 'infinity',
# },
# }
#
# @param unit The unit to create a dropfile for
# @param filename The target unit file to create. The filename of the drop in. The full path is determined using the path, unit and this filename.
# @param ensure The state of this dropin file
Expand All @@ -29,6 +47,7 @@
# @param service_entry key value pairs for [Service] section of the unit file
# @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
#
define systemd::manage_dropin (
Systemd::Unit $unit,
Expand All @@ -46,9 +65,14 @@
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,
) {
if $timer_entry and $unit !~ Pattern['^[^/]+\.timer'] {
fail("Systemd::Manage_unit[${name}]: timer_entry is only valid for timer units")
fail("Systemd::Manage_dropin[${name}]: for unit ${unit} timer_entry is only valid for timer units")
}

if $path_entry and $unit !~ Pattern['^[^/]+\.path'] {
fail("Systemd::Manage_dropin[${name}]: for unit ${unit} path_entry is only valid for path units")
}

systemd::dropin_file { $name:
Expand All @@ -68,6 +92,7 @@
'service_entry' => $service_entry,
'install_entry' => $install_entry,
'timer_entry' => $timer_entry,
'path_entry' => $path_entry,
}),
}
}
23 changes: 23 additions & 0 deletions manifests/manage_unit.pp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,22 @@
# WantedBy => 'multi-user.target',
# },
# }
#
# @example Genenerate a path unit
# systemd::manage_unit { 'passwd-mon.path':
# ensure => present,
# unit_entry => {
# 'Description' => 'Monitor the passwd file',
# },
# path_entry => {
# 'PathModified => '/etc/passwd',
# 'Unit' => 'passwd-mon.service',
# },
# install_entry => {
# 'WantedBy' => 'multi-user.target',
# },
# }
#
# @param name [Pattern['^[^/]+\.(service|socket|device|mount|automount|swap|target|path|timer|slice|scope)$']]
# The target unit file to create
#
Expand All @@ -40,6 +56,7 @@
# @param service_entry key value pairs for [Service] section of the unit file.
# @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.
#
define systemd::manage_unit (
Enum['present', 'absent'] $ensure = 'present',
Expand All @@ -58,13 +75,18 @@
Systemd::Unit::Unit $unit_entry,
Optional[Systemd::Unit::Service] $service_entry = undef,
Optional[Systemd::Unit::Timer] $timer_entry = undef,
Optional[Systemd::Unit::Path] $path_entry = undef,
) {
assert_type(Systemd::Unit, $name)

if $timer_entry and $name !~ Pattern['^[^/]+\.timer'] {
fail("Systemd::Manage_unit[${name}]: timer_entry is only valid for timer units")
}

if $path_entry and $name !~ Pattern['^[^/]+\.path'] {
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")
}
Expand All @@ -86,6 +108,7 @@
'service_entry' => $service_entry,
'install_entry' => $install_entry,
'timer_entry' => $timer_entry,
'path_entry' => $path_entry,
}),
}
}
Loading