]> git.openstreetmap.org Git - chef.git/commitdiff
podman: avoid starting and immediate restart on first run
authorGrant Slater <github@firefishy.com>
Fri, 27 Oct 2023 21:11:28 +0000 (22:11 +0100)
committerGrant <github@firefishy.com>
Sat, 28 Oct 2023 19:02:36 +0000 (20:02 +0100)
cookbooks/podman/resources/service.rb

index 6ce5da35ee1a2601251cb30cd99770aeda76f5e9..6052b7fb2c3d7c1d6347219bb7966695f6f117f1 100644 (file)
@@ -41,9 +41,16 @@ action :create do
     restart "on-failure"
   end
 
+  # No action :start here to avoid a start and then immediate :restart, due to subscribe, on first run
   service new_resource.service do
-    action [:enable, :start]
-    subscribes :restart, "systemd_service[#{new_resource.service}]"
+    action :enable
+    subscribes :restart, "systemd_service[#{new_resource.service}]", :immediately
+  end
+
+  # Ensure the service is started if not running, replies on status of service resource
+  notify_group new_resource.service do
+    action :run
+    notifies :start, "service[#{new_resource.service}]", :immediately
   end
 end