Skip to content

Commit

Permalink
Merge pull request #428 from /issues/291
Browse files Browse the repository at this point in the history
Add parameter to manage /etc/udev/rules.d directory
  • Loading branch information
TheMeier authored Mar 10, 2024
2 parents 5031e05 + a7d6ba5 commit 51c0d2c
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
9 changes: 9 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ The following parameters are available in the `systemd` class:
* [`manage_oomd`](#-systemd--manage_oomd)
* [`oomd_ensure`](#-systemd--oomd_ensure)
* [`oomd_settings`](#-systemd--oomd_settings)
* [`udev_purge_rules`](#-systemd--udev_purge_rules)

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

Expand Down Expand Up @@ -602,6 +603,14 @@ Hash of systemd-oomd configurations for oomd.conf

Default value: `{}`

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

Data type: `Boolean`

Toggle if unmanaged files in /etc/udev/rules.d should be purged if manage_udevd is enabled

Default value: `false`

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

Update the systemd temp files
Expand Down
3 changes: 3 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@
# @param oomd_settings
# Hash of systemd-oomd configurations for oomd.conf
#
# @param udev_purge_rules
# Toggle if unmanaged files in /etc/udev/rules.d should be purged if manage_udevd is enabled
class systemd (
Optional[Pattern['^.+\.target$']] $default_target = undef,
Hash[String,String] $accounting = {},
Expand Down Expand Up @@ -239,6 +241,7 @@
Boolean $manage_oomd = false,
Enum['stopped','running'] $oomd_ensure = 'running',
Systemd::OomdSettings $oomd_settings = {},
Boolean $udev_purge_rules = false,
) {
contain systemd::install

Expand Down
6 changes: 6 additions & 0 deletions manifests/udevd.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
enable => true,
}

file { '/etc/udev/rules.d':
ensure => directory,
purge => $systemd::udev_purge_rules,
recurse => true,
}

file { '/etc/udev/udev.conf':
ensure => 'file',
owner => 'root',
Expand Down
15 changes: 15 additions & 0 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@
it { is_expected.to compile.with_all_deps }
it { is_expected.not_to contain_service('systemd-udevd') }
it { is_expected.not_to contain_file('/etc/udev/udev.conf') }
it { is_expected.not_to contain_file('/etc/udev/rules.d') }
end

context 'when working with udevd and no custom rules' do
Expand Down Expand Up @@ -534,6 +535,8 @@
with_content(%r{^resolve_names=early$}).
with_content(%r{^timeout_signal=SIGKILL$})
}

it { is_expected.to contain_file('/etc/udev/rules.d').with_ensure('directory').with_purge(false) }
end

context 'when working with udevd and a rule set' do
Expand All @@ -557,6 +560,18 @@
}
end

context 'when enabling udevd management and rule purging' do
let(:params) do
{
manage_udevd: true,
udev_purge_rules: true,
}
end

it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_file('/etc/udev/rules.d').with_ensure('directory').with_purge(true) }
end

it { is_expected.to compile.with_all_deps }

it {
Expand Down

0 comments on commit 51c0d2c

Please sign in to comment.