]> git.openstreetmap.org Git - chef.git/commitdiff
systemd: use subscribes to avoid daemon-reload race with service reload/restart
authorGrant Slater <github@firefishy.com>
Wed, 3 Dec 2025 23:40:57 +0000 (23:40 +0000)
committerGrant Slater <github@firefishy.com>
Wed, 3 Dec 2025 23:40:57 +0000 (23:40 +0000)
cookbooks/hardware/recipes/default.rb
cookbooks/systemd/resources/service.rb
cookbooks/systemd/resources/timer.rb

index 04ead0b00e1664cd9ce97d5b97d361f1a005eafd..73fc91bf6e6e29c929307b18d887ea35909b1b5d 100644 (file)
@@ -566,13 +566,6 @@ if watchdog_module
     action :install
   end
 
-  execute "systemctl-reload" do
-    action :nothing
-    command "systemctl daemon-reload"
-    user "root"
-    group "root"
-  end
-
   directory "/etc/systemd/system.conf.d" do
     owner "root"
     group "root"
@@ -584,7 +577,14 @@ if watchdog_module
     owner "root"
     group "root"
     mode "644"
-    notifies :run, "execute[systemctl-reload]"
+  end
+
+  execute "systemctl-reload" do
+    action :nothing
+    command "systemctl daemon-reload"
+    user "root"
+    group "root"
+    subscribes :run, "template[/etc/systemd/system.conf.d/watchdog.conf]"
   end
 end
 
index 8b380c306699be039fd145fcb8b1577d88ad4c51..34d4e6c50b17400654484015e91d890819b15900 100644 (file)
@@ -193,7 +193,6 @@ action :create do
     group "root"
     mode "644"
     variables service_variables
-    notifies :run, "execute[systemctl-reload]"
   end
 
   execute "systemctl-reload" do
@@ -201,6 +200,7 @@ action :create do
     command "systemctl daemon-reload"
     user "root"
     group "root"
+    subscribes :run, "template[#{config_name}]"
   end
 end
 
@@ -212,7 +212,6 @@ action :delete do
 
   file config_name do
     action :delete
-    notifies :run, "execute[systemctl-reload]"
   end
 
   execute "systemctl-reload" do
@@ -220,6 +219,7 @@ action :delete do
     command "systemctl daemon-reload"
     user "root"
     group "root"
+    subscribes :run, "file[#{config_name}]"
   end
 end
 
index 2b21ba28914bd4bbe7657c35136f9e359149d165..44dcaed1b9e86128d5cf1bb5f5b73c0f1cc55191 100644 (file)
@@ -58,7 +58,6 @@ action :create do
     group "root"
     mode "644"
     variables timer_variables
-    notifies :run, "execute[systemctl-reload]"
   end
 
   execute "systemctl-reload" do
@@ -66,6 +65,7 @@ action :create do
     command "systemctl daemon-reload"
     user "root"
     group "root"
+    subscribes :run, "template[#{config_name}]"
   end
 end
 
@@ -79,7 +79,7 @@ action :delete do
     command "systemctl daemon-reload"
     user "root"
     group "root"
-    subscribes :run, "file[/etc/systemd/system/#{new_resource.timer}.timer]"
+    subscribes :run, "file[#{config_name}]"
   end
 end