Skip to content

A cookbook for easily disabling Chef runs

License

Notifications You must be signed in to change notification settings

mattlqx/cookbook-kill-switch

Repository files navigation

kill-switch

This cookbook allows you a quick and easy way to stop Chef runs in your environment either through a touch file on the filesystem or through a node attribute. You also have the choice of a clean or unclean exit.

The exit logic occurs during the compilation phase. This recipe should be included at the very tippy top of your run_list to ensure other compilation phase actions do not run.

You should absolutely use this functionality sparingly. Converging a node on a routine basis prevents configuration drift and the longer you go without running Chef, the more risk you take from more changes being introduced to the system on the next run. There are however use-cases and emergency situations where you need to shut-down Chef runs on a tier of servers or even globally for a period of time. This cookbook aims to be a tool that can be leveraged for those scenarios.

There is some monkey-patching that needs to happen to have the option of a clean exit during compilation. No refunds, sorry.

Attributes

Key Type Description Default
['kill_switch']['engage'] Bool Force Chef run to exit immediately. false
['kill_switch']['normal_exit'] Bool Exit should be "success" / `0`. Will still generate a `fatal` level log message regardless. false
['kill_switch']['touch_file'] String Engage kill switch if a file exists at this path C:\\.kill_chef on Windows, /.kill_chef on Linux
['kill_switch']['when_reboot_scheduled'] Bool Engage kill switch if there is a scheduled reboot (only supported on Ubuntu 16+ presently) true

Recipes

kill-switch::default

Checks for a touch file or node['kill_switch']['engage'] to be true and exits the Chef run immediately with desired exit status.

License and Authors

Authors: Matt Kulka [email protected]