Showing with 415 additions and 4 deletions.
  1. +10 −0 CHANGELOG.md
  2. +36 −0 README.md
  3. +7 −0 data/common.yaml
  4. +39 −2 manifests/init.pp
  5. +48 −0 manifests/udev/rule.pp
  6. +35 −0 manifests/udevd.pp
  7. +6 −0 manifests/unit_file.pp
  8. +1 −1 metadata.json
  9. +120 −1 spec/classes/init_spec.rb
  10. +77 −0 spec/defines/udev_rules.spec
  11. +31 −0 templates/udev_conf.epp
  12. +5 −0 templates/udev_rule.epp
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org).

## [2.12.0](https://github.com/camptocamp/puppet-systemd/tree/2.12.0) (2021-02-10)

[Full Changelog](https://github.com/camptocamp/puppet-systemd/compare/2.11.0...2.12.0)

### Added

- Allow service reloading \#159 [\#175](https://github.com/camptocamp/puppet-systemd/pull/175) ([k0ka](https://github.com/k0ka))
- Allow additional option for $cache parameter [\#169](https://github.com/camptocamp/puppet-systemd/pull/169) ([bryangwilliam](https://github.com/bryangwilliam))
- Add management of udev objects [\#165](https://github.com/camptocamp/puppet-systemd/pull/165) ([jcpunk](https://github.com/jcpunk))

## [2.11.0](https://github.com/camptocamp/puppet-systemd/tree/2.11.0) (2021-01-19)

[Full Changelog](https://github.com/camptocamp/puppet-systemd/compare/2.10.0...2.11.0)
Expand Down
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ class{'systemd':
manage_networkd => true,
manage_timesyncd => true,
manage_journald => true,
manage_udevd => true,
manage_logind => true,
}
```
Expand Down Expand Up @@ -320,6 +321,41 @@ systemd::journald_settings:
ensure: absent
```
### udevd configuration
It allows you to manage the udevd configuration. You can set the udev.conf values via the `udev_log`, `udev_children_max`, `udev_exec_delay`, `udev_event_timeout`, `udev_resolve_names`, and `udev_timeout_signal` parameters.

Additionally you can set custom udev rules with the `udev_rules` parameter.

```puppet
class { 'systemd':
manage_udevd => true,
udev_rules => {
'example_raw.rules' => {
'rules' => [
'ACTION=="add", KERNEL=="sda", RUN+="/bin/raw /dev/raw/raw1 %N"',
'ACTION=="add", KERNEL=="sdb", RUN+="/bin/raw /dev/raw/raw2 %N"',
],
},
},
}
```

### udev::rules configuration

Custom udev rules can be defined for specific events.

```yaml
systemd::udev::rule:
ensure: present
path: /etc/udev/rules.d
selinux_ignore_defaults: false
notify: "Service[systemd-udevd']"
rules:
- 'ACTION=="add", KERNEL=="sda", RUN+="/bin/raw /dev/raw/raw1 %N"'
- 'ACTION=="add", KERNEL=="sdb", RUN+="/bin/raw /dev/raw/raw2 %N"',
```

### logind configuration

It also allows you to manage logind settings. You can manage logind settings through setting the `logind_settings` parameter. If you want a parameter to be removed, you can pass its value as params.
Expand Down
7 changes: 7 additions & 0 deletions data/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,12 @@ systemd::accounting: {}
systemd::purge_dropin_dirs: true
systemd::manage_journald: true
systemd::journald_settings: {}
systemd::manage_udevd: false
systemd::udev_log: ~
systemd::udev_children_max: ~
systemd::udev_exec_delay: ~
systemd::udev_event_timeout: ~
systemd::udev_timeout_signal: ~
systemd::udev_resolve_names: ~
systemd::manage_logind: false
systemd::logind_settings: {}
41 changes: 39 additions & 2 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
# Takes a boolean argument or "opportunistic"
#
# @param cache
# Takes a boolean argument.
# Takes a boolean argument or "no-negative".
#
# @param dns_stub_listener
# Takes a boolean argument or one of "udp" and "tcp".
Expand Down Expand Up @@ -75,6 +75,31 @@
# @param journald_settings
# Config Hash that is used to configure settings in journald.conf
#
# @param manage_udevd
# Manage the systemd udev daemon
#
# @param udev_log
# The value of /etc/udev/udev.conf udev_log
#
# @param udev_children_max
# The value of /etc/udev/udev.conf children_max
#
# @param udev_exec_delay
# The value of /etc/udev/udev.conf exec_delay
#
# @param udev_event_timeout
# The value of /etc/udev/udev.conf event_timeout
#
# @param udev_resolve_names
# The value of /etc/udev/udev.conf resolve_names
#
# @param udev_timeout_signal
# The value of /etc/udev/udev.conf timeout_signal
#
# @param udev_rules
# Config Hash that is used to generate instances of our
# `udev::rule` define.
#
# @param manage_logind
# Manage the systemd logind
#
Expand All @@ -98,7 +123,7 @@
Optional[Variant[Boolean,Enum['resolve']]] $multicast_dns,
Optional[Variant[Boolean,Enum['allow-downgrade']]] $dnssec,
Optional[Variant[Boolean,Enum['opportunistic', 'no']]] $dnsovertls,
Boolean $cache,
Optional[Variant[Boolean,Enum['no-negative']]] $cache,
Optional[Variant[Boolean,Enum['udp','tcp']]] $dns_stub_listener,
Boolean $use_stub_resolver,
Boolean $manage_networkd,
Expand All @@ -112,10 +137,18 @@
Boolean $purge_dropin_dirs,
Boolean $manage_journald,
Systemd::JournaldSettings $journald_settings,
Boolean $manage_udevd,
Optional[Variant[Integer,String]] $udev_log,
Optional[Integer] $udev_children_max,
Optional[Integer] $udev_exec_delay,
Optional[Integer] $udev_event_timeout,
Optional[Enum['early', 'late', 'never']] $udev_resolve_names,
Optional[Variant[Integer,String]] $udev_timeout_signal,
Boolean $manage_logind,
Systemd::LogindSettings $logind_settings,
Hash $loginctl_users = {},
Hash $dropin_files = {},
Hash $udev_rules = {},
) {
contain systemd::systemctl::daemon_reload

Expand All @@ -133,6 +166,10 @@
contain systemd::timesyncd
}

if $manage_udevd {
contain systemd::udevd
}

if $manage_accounting {
contain systemd::system
}
Expand Down
48 changes: 48 additions & 0 deletions manifests/udev/rule.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Adds a custom udev rule
#
# @api public
#
# @see udev(7)
#
# @attr name [Pattern['^.+\.rules$']]
# The name of the udev rules to create
#
# @param $ensure
# Whether to drop a file or remove it
#
# @param path
# The path to the main systemd settings directory
#
# @param selinux_ignore_defaults
# If Puppet should ignore the default SELinux labels.
#
# @param notify_services
# List of services to notify when this rule is updated
#
# @param rules
# The literal udev rules you want to deploy
#
define systemd::udev::rule (
Array $rules,
Enum['present', 'absent', 'file'] $ensure = 'present',
Stdlib::Absolutepath $path = '/etc/udev/rules.d',
Optional[Variant[Array, String]] $notify_services = [],
Optional[Boolean] $selinux_ignore_defaults = false,
) {
include systemd

$filename = assert_type(Pattern['^.+\.rules$'], $name) |$expected, $actual| {
fail("The \$name should match \'${expected}\', you passed \'${actual}\'")
}

file { $filename:
ensure => $ensure,
owner => 'root',
group => 'root',
mode => '0444',
path => join([$path, $name], '/'),
notify => $notify_services,
selinux_ignore_defaults => $selinux_ignore_defaults,
content => epp("${module_name}/udev_rule.epp", {'rules' => $rules}),
}
}
35 changes: 35 additions & 0 deletions manifests/udevd.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# @api private
#
# This class manages systemd's udev config
#
# https://www.freedesktop.org/software/systemd/man/udev.conf.html
class systemd::udevd {
assert_private()

service { 'systemd-udevd':
ensure => running,
enable => true,
}

file { '/etc/udev/udev.conf':
ensure => 'file',
owner => 'root',
group => 'root',
mode => '0444',
content => epp("${module_name}/udev_conf.epp", {
'udev_log' => $systemd::udev_log,
'udev_children_max' => $systemd::udev_children_max,
'udev_exec_delay' => $systemd::udev_exec_delay,
'udev_event_timeout' => $systemd::udev_event_timeout,
'udev_resolve_names' => $systemd::udev_resolve_names,
'udev_timeout_signal' => $systemd::udev_timeout_signal,
}),
notify => Service['systemd-udevd'],
}

$systemd::udev_rules.each |$udev_rule_name, $udev_rule| {
systemd::udev::rule { $udev_rule_name:
* => $udev_rule,
}
}
}
6 changes: 6 additions & 0 deletions manifests/unit_file.pp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
# @param active
# If set, will manage the state of the unit.
#
# @param restart
# Specify a restart command manually. If left unspecified, a standard Puppet service restart happens.
#
define systemd::unit_file (
Enum['present', 'absent', 'file'] $ensure = 'present',
Stdlib::Absolutepath $path = '/etc/systemd/system',
Expand All @@ -58,6 +61,7 @@
Boolean $show_diff = true,
Optional[Variant[Boolean, Enum['mask']]] $enable = undef,
Optional[Boolean] $active = undef,
Optional[String] $restart = undef,
) {
include systemd

Expand Down Expand Up @@ -85,9 +89,11 @@
}

if $enable != undef or $active != undef {

service { $name:
ensure => $active,
enable => $enable,
restart => $restart,
provider => 'systemd',
}

Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "camptocamp-systemd",
"version": "2.11.0",
"version": "2.12.0",
"author": "camptocamp",
"summary": "Puppet Systemd module",
"license": "Apache-2.0",
Expand Down
Loading