简体   繁体   中英

Does JClouds-Chef have a revert function?

I'm using the excellent JClouds-Chef library to bootstrap and configure VMs with Chef.

I need to account for the use case where something goes wrong after JClouds-Chef has been executed on the VM, that allows me to basically rollback and uninstall it. The goal here is to leave the system in the same state it was originally in (before JClouds-Chef got involved) if something goes awry.

  1. One solution might be to uninstall Chef Client completely
  2. Another solution might be to wipe the slate clean or reverse the bootstrap to the point where there is simple a /tmp/chef-bootstrap.sh file on the VM
  3. The ideal solution , given my scenario, would be for it to be "OK" if that chef-bootstrap.sh could be run over and over again, and each time it runs, simply reconfigure the Chef Client to use whatever are the latest recipes/roles/environments that the VM should have.

So my first question is, is #3 above the case? If not, then how could I implement solutions #1 or #2, or is there a better way to go about this undo/revert/rollback functionality?

As far as I know Chef does not provide that rollback out of the box.

Regarding your questions:

  1. Uninstalling the Chef client won't uninstall what the Chef run could have installed nor revert the changes in config files, etc.
  2. That script should have to be created manually.
  3. The way to revert things in Chef (or uninstall something) is to create a recipe that removes what needs to be removed (for example to rollback an Apache installation you would create a recipe that uninstalls it).

The latest is the recommended and you could do it by:

  • Adding the "chef-client" cookbook to the run list of your nodes so it runs periodically. This way it will watch for changes in the run list and apply them.
  • If something fails, you can update the run list of the node and leave there the "rollback recipes". In the next Chef client run, the state will be reverted.

When using the Chef client periodically, it is extremely important that all recipes you use are idempotent so they can be run many times without failing (by definition they should!).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM