- From: Daniel DeLeo <
>
- To:
- Subject: [chef] Re: How to fail the chef run from a start handler?
- Date: Mon, 18 Nov 2013 08:58:51 -0800
On Saturday, November 16, 2013 at 3:26 PM, Steffen Gebert wrote:
Hi,
I'm playing around with etckeeper and chef and wrote a start handler
that should prevent chef from doing anything, if /etc was modified
previously.
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
Steffen
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.
--
Daniel DeLeo
Archive powered by MHonArc 2.6.16.