From: Grant Slater Date: Fri, 27 Oct 2023 21:11:28 +0000 (+0100) Subject: podman: avoid starting and immediate restart on first run X-Git-Url: https://git.openstreetmap.org./chef.git/commitdiff_plain/c6294e91397c6feebd9b9f0e33da615b3ca17998?ds=inline podman: avoid starting and immediate restart on first run --- diff --git a/cookbooks/podman/resources/service.rb b/cookbooks/podman/resources/service.rb index 6ce5da35e..6052b7fb2 100644 --- a/cookbooks/podman/resources/service.rb +++ b/cookbooks/podman/resources/service.rb @@ -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