Chef Blogs

Single chef-client run with multiple reboots on Windows

Lucas Welch | Posted on

This post originally appeared on Chef engineer Alex Vinyar’s blog.

To teach is to learn…

…or something along these lines. “How do I manage reboots with chef-client on Windows” is a question I hear every so often.

So, this time around, I decided to buckle down and write down as many ways as I could remember to reboot a server and continue a chef-client run. No mucking around with the run_list, or messing around with multiple run_lists, definitely no manual steps, and most definitely no knife exec.

Here is my brainchild – input and feedback are most welcome!

https://github.com/vinyar/chef_win_reboots

In my experience I found a couple of common situations where Windows needs to be defibrillated-

  • something has been installed and reboot is needed
  • a bunch of somethings have been installed and reboot is needed
  • something needs to be installed and a reboot is pending
  • a series of somethings needs to be installed and they have various reboot state requirements
  • a week has passed since a reboot has been performed
  • server joined a domain

With Chef managing your infrastructure there is a new reboot scenario:

  • reboot immediately without aborting a chef-client run

The patterns in the Github repo allow users to manage reboots at the resource level, or as a wrapper cookbook pattern.

A real example can be seen in pattern two – which was really the genesis for this repo from way back when – https://github.com/vinyar/chef_win_reboots/blob/master/reboot_demo/recipes/pattern2.rb