X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/62d2dd6209eddec292fa35c2ce4a387c6450d6f7..c6294e91397c6feebd9b9f0e33da615b3ca17998:/cookbooks/podman/resources/service.rb?ds=sidebyside diff --git a/cookbooks/podman/resources/service.rb b/cookbooks/podman/resources/service.rb index 3f3e8054c..6052b7fb2 100644 --- a/cookbooks/podman/resources/service.rb +++ b/cookbooks/podman/resources/service.rb @@ -33,16 +33,24 @@ action :create do notify_access "all" environment "PODMAN_SYSTEMD_UNIT" => "%n" exec_start_pre "/bin/rm --force %t/%n.ctr-id" - exec_start "/usr/bin/podman run --cidfile=%t/%n.ctr-id --cgroups=no-conmon --userns=auto --label=io.containers.autoupdate=registry --network=slirp4netns #{publish_options} --rm --sdnotify=conmon --detach --replace --name=%N #{new_resource.image}" + exec_start "/usr/bin/podman run --cidfile=%t/%n.ctr-id --cgroups=no-conmon --userns=auto --label=io.containers.autoupdate=registry --network=slirp4netns:mtu=1500 #{publish_options} --rm --sdnotify=conmon --detach --replace --name=%N #{new_resource.image}" exec_stop "/usr/bin/podman stop --ignore --time=10 --cidfile=%t/%n.ctr-id" exec_stop_post "/usr/bin/podman rm --force --ignore --cidfile=%t/%n.ctr-id" + timeout_start_sec 180 timeout_stop_sec 70 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