From c37f6bcb0e397648dd6fd30794689aa939f978f6 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Tue, 11 Apr 2017 09:35:44 +0100 Subject: [PATCH] Treat an exit status of 3 as success for chef-client When chef-client is terminated with SIGTERM it unhelpfully returns an exit status of 3 which, by default, is treated as an unsuccessful exit. --- cookbooks/chef/recipes/default.rb | 1 + cookbooks/systemd/resources/service.rb | 1 + cookbooks/systemd/templates/default/service.erb | 3 +++ 3 files changed, 5 insertions(+) diff --git a/cookbooks/chef/recipes/default.rb b/cookbooks/chef/recipes/default.rb index 9443d0548..2e2e345a1 100644 --- a/cookbooks/chef/recipes/default.rb +++ b/cookbooks/chef/recipes/default.rb @@ -112,6 +112,7 @@ if node[:lsb][:release].to_f >= 15.10 description "Chef client" after "network.target" exec_start "/usr/bin/chef-client -i 1800 -s 20" + success_exit_status 3 restart "on-failure" end else diff --git a/cookbooks/systemd/resources/service.rb b/cookbooks/systemd/resources/service.rb index 2a8f22b2b..664304da8 100644 --- a/cookbooks/systemd/resources/service.rb +++ b/cookbooks/systemd/resources/service.rb @@ -45,6 +45,7 @@ property :standard_output, String, :is => %w(inherit null tty journal syslog kmsg journal+console syslog+console kmsg+console socket) property :standard_error, String, :is => %w(inherit null tty journal syslog kmsg journal+console syslog+console kmsg+console socket) +property :success_exit_status, [Integer, String, Array] property :restart, String, :is => %w(on-success on-failure on-abnormal on-watchdog on-abort always) property :private_tmp, [TrueClass, FalseClass] diff --git a/cookbooks/systemd/templates/default/service.erb b/cookbooks/systemd/templates/default/service.erb index ffc0efb72..f7f851ae5 100644 --- a/cookbooks/systemd/templates/default/service.erb +++ b/cookbooks/systemd/templates/default/service.erb @@ -75,6 +75,9 @@ ProtectHome=<%= @protect_home %> <% if @no_new_privileges -%> NoNewPrivileges=<%= @no_new_privileges %> <% end -%> +<% if @success_exit_status -%> +SuccessExitStatus=<%= Array(@success_exit_status).join(" ") %> +<% end -%> <% if @restart -%> Restart=<%= @restart %> <% end -%> -- 2.39.5