From e8e15889d11664d827186685ee42c05706c6c49e Mon Sep 17 00:00:00 2001 From: Tomas Barton Date: Tue, 27 Aug 2024 14:01:25 +0200 Subject: [PATCH] Reload udev rules after change (#484) --- manifests/udev/rule.pp | 2 +- manifests/udevd.pp | 7 +++++++ spec/classes/init_spec.rb | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/manifests/udev/rule.pp b/manifests/udev/rule.pp index 06b65c4a..d1708737 100644 --- a/manifests/udev/rule.pp +++ b/manifests/udev/rule.pp @@ -43,7 +43,7 @@ owner => 'root', group => 'root', mode => '0444', - notify => $notify_services, + notify => $notify_services << 'Exec[systemd-udev_reload]', selinux_ignore_defaults => $selinux_ignore_defaults, content => epp("${module_name}/udev_rule.epp", { 'rules' => $rules }), } diff --git a/manifests/udevd.pp b/manifests/udevd.pp index 92635b5d..a560372b 100644 --- a/manifests/udevd.pp +++ b/manifests/udevd.pp @@ -36,4 +36,11 @@ * => $udev_rule, } } + + exec { 'systemd-udev_reload': + command => 'udevadm control --reload-rules && udevadm trigger', + refreshonly => true, + path => $facts['path'], + } + } diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index 1be26d8a..50be9471 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -701,6 +701,8 @@ 'ACTION=="add", KERNEL=="sdb", RUN+="/bin/raw /dev/raw/raw2 %N"', ]) } + + it { is_expected.to contain_file('/etc/udev/rules.d/example_raw.rules').that_notifies('Exec[systemd-udev_reload]') } end context 'with machine-info' do