diff options
Diffstat (limited to 'lib/chef/platform')
-rw-r--r-- | lib/chef/platform/rebooter.rb | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/chef/platform/rebooter.rb b/lib/chef/platform/rebooter.rb index c678b60dd1..74c8b2da1f 100644 --- a/lib/chef/platform/rebooter.rb +++ b/lib/chef/platform/rebooter.rb @@ -19,6 +19,7 @@ require "chef/dsl/reboot_pending" require "chef/log" require "chef/platform" +require "chef/application/exit_code" class Chef class Platform @@ -27,6 +28,8 @@ class Chef class << self + include Chef::DSL::RebootPending + def reboot!(node) reboot_info = node.run_context.reboot_info @@ -38,8 +41,16 @@ class Chef "shutdown -r +#{reboot_info[:delay_mins]} \"#{reboot_info[:reason]}\"" end - Chef::Log.warn "Rebooting server at a recipe's request. Details: #{reboot_info.inspect}" - shell_out!(cmd) + msg = "Rebooting server at a recipe's request. Details: #{reboot_info.inspect}" + begin + Chef::Log.warn msg + shell_out!(cmd) + rescue Mixlib::ShellOut::ShellCommandFailed => e + raise Chef::Exceptions::RebootFailed.new(e.message) + end + + raise Chef::Exceptions::Reboot.new(msg) if Chef::Application::ExitCode.enforce_rfc_062_exit_codes? + Chef::Application::ExitCode.notify_reboot_exit_code_deprecation end # this is a wrapper function so Chef::Client only needs a single line of code. |