Question

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

Was it helpful?

Solution

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?).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top