noli
noli

Reputation: 15996

How can I get chef to reboot the node, and pick up the recipe from where it left off?

I'm trying to set up an asterisk server with chef using Berkshelf and Vagrant, and I'd first like to upgrade the kernel by running

apt-get upgrade

, and rebooting my machine.

How can I trigger a reboot in the recipe, and have it pick up after the machine reboots? I have no problem with this using Fabric, but

execute "reboot"

the Chef provisioner in Vagrant died as the machine rebooted

Upvotes: 4

Views: 2897

Answers (1)

StephenKing
StephenKing

Reputation: 37580

Idempotence is one of the principles of Chef.

This means that your recipe can run over and over again, and it will only change things that are not as expected.

So in your case it would look like this:

  • First Chef run notices that an unexpected kernel is installed. It thus installs the kernel and triggers a reboot.
  • Chef runs again, identifies that the kernel is installed as expected and thus just continues. Now you can continue with other things.

One note: I've never tried this, but signalling a reboot in the middle of a Chef run could do some damage. I'd recommend to abort the chef run after the reboot signal (e.g. through raising an Exception, see How do you abort/end a Chef run?).

Upvotes: 1

Related Questions