On Saturday, November 16, 2013 at 3:26 PM, Steffen Gebert wrote:
I’m playing around with etckeeper and chef and wrote a start handler
that should prevent chef from doing anything, if /etc was modified
Is there any way to fail the chef run from a handler? They are executed
with run_report_safely, which catches all the exceptions.
Thanks for your help
You could override the #run_report_safely method. The code comment about "not overriding this method unless you know what you’re doing” applies to your case. Of course, the caveat there is that other handlers won’t run. For a more elegant approach, you’d need to patch that method, maybe using catch and throw, to allow for changing the state of the chef run to failure.
You could also move the code to the first recipe in the run_list if that’s something you can control.