Module: Chef::Platform::Rebooter

Extended by:
Mixin::ShellOut
Defined in:
lib/chef/platform/rebooter.rb

Constant Summary

Constants included from Mixin::ShellOut

Mixin::ShellOut::DEPRECATED_OPTIONS

Class Method Summary collapse

Methods included from Mixin::ShellOut

run_command_compatible_options, shell_out, shell_out!, shell_out_with_systems_locale, shell_out_with_systems_locale!

Class Method Details

.reboot!(node) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/chef/platform/rebooter.rb', line 30

def reboot!(node)
  reboot_info = node.run_context.reboot_info

  cmd = if Chef::Platform.windows?
          # should this do /f as well? do we then need a minimum delay to let apps quit?
          "shutdown /r /t #{reboot_info[:delay_mins] * 60} /c \"#{reboot_info[:reason]}\""
        else
          # probably Linux-only.
          "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)
end

.reboot_if_needed!(node) ⇒ Object

this is a wrapper function so Chef::Client only needs a single line of code.



46
47
48
49
50
# File 'lib/chef/platform/rebooter.rb', line 46

def reboot_if_needed!(node)
  if node.run_context.reboot_requested?
    reboot!(node)
  end
end