How to schedule a restart of a Windows machine at the end of a recipe instead of running a chef-client?

I am currently using WindowsRebootHandler to reboot the machine at the end of the chef-client startup (i.e. after running all recipes).

Is there a way to schedule a machine restart at the end of each recipe run instead of running the chef-client?

Even when I tried with a 0 in timeout windows_reboot, a reboot occurred at the end of the chef-client run.

+4
source share
2 answers

Good idea or not, here is a way to do this:

-- "firstrun". "firstrun" , :

  • .
  • chef .

Windows - "" , .

0

, .

, :

include_recipe 'mycookbook::second_recipe' unless reboot_pending?

windows_reboot 30
    timeout 30
    reason 'scheduled reboot'
    action :nothing
end

some_task 'stuff' do
    ...
    notifies :request, 'windows_reboot[30]', :delayed
end

, , - .

Alex Vinyar Github Chef.

0

All Articles