Skip to content

Instantly share code, notes, and snippets.

@gkspranger
Created May 1, 2019 18:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gkspranger/5133b1390fbd2693e50f122b40967ddb to your computer and use it in GitHub Desktop.
Save gkspranger/5133b1390fbd2693e50f122b40967ddb to your computer and use it in GitHub Desktop.
# cookbook code
...
reboot 'soon' do
delay_mins 2
action :request_reboot
end
Chef.event_handler do
on :run_failed do |exception, run_status|
Chef::Log.warn "FAILED exception :: #{exception}"
Chef::Log.warn "FAILED run status :: #{run_status}"
Chef::Log.warn "FAILED reboot info :: #{run_status.run_context.reboot_info}"
end
on :run_completed do |node, run_status|
Chef::Log.warn "COMPLETED node :: #{node}"
Chef::Log.warn "COMPLETED run status :: #{run_status}"
# this will be an empty hash if no reboot info
# run_status.run_context.reboot_info.empty?
Chef::Log.warn "COMPLETED reboot info :: #{run_status.run_context.reboot_info}"
end
end
###########################
###########################
# chef-client output
...
Running handlers:
Running handlers complete
Chef Client finished, 1/1 resources updated in 01 seconds
[2019-05-01T18:39:04+00:00] WARN: COMPLETED node :: node[default-bento-centos-76]
[2019-05-01T18:39:04+00:00] WARN: COMPLETED run status :: #<Chef::RunStatus:0x0000000004dcfd30>
[2019-05-01T18:39:04+00:00] WARN: COMPLETED reboot info :: {:delay_mins=>2, :reason=>"Reboot by Chef", :timestamp=>2019-05-01 18:39:04 +0000, :requested_by=>"soon"}
[2019-05-01T18:39:04+00:00] WARN: Rebooting server at a recipe's request. Details: {:delay_mins=>2, :reason=>"Reboot by Chef", :timestamp=>2019-05-01 18:39:04 +0000, :requested_by=>"soon"}
Running handlers:
[2019-05-01T18:39:04+00:00] ERROR: Running exception handlers
Running handlers complete
[2019-05-01T18:39:04+00:00] ERROR: Exception handlers complete
Chef Client failed. 1 resources updated in 01 seconds
[2019-05-01T18:39:04+00:00] WARN: FAILED exception :: Rebooting server at a recipe's request. Details: {:delay_mins=>2, :reason=>"Reboot by Chef", :timestamp=>2019-05-01 18:39:04 +0000, :requested_by=>"soon"}
[2019-05-01T18:39:04+00:00] WARN: FAILED run status :: #<Chef::RunStatus:0x0000000004dcfd30>
[2019-05-01T18:39:04+00:00] WARN: FAILED reboot info :: {:delay_mins=>2, :reason=>"Reboot by Chef", :timestamp=>2019-05-01 18:39:04 +0000, :requested_by=>"soon"}
[2019-05-01T18:39:04+00:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
[2019-05-01T18:39:04+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2019-05-01T18:39:04+00:00] FATAL: Chef::Exceptions::Reboot: Rebooting server at a recipe's request. Details: {:delay_mins=>2, :reason=>"Reboot by Chef", :timestamp=>2019-05-01 18:39:04 +0000, :requested_by=>"soon"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment