- From: jfotop <
>
- To:
- Subject: [chef] Re: Exception Handlers with ignore_failure
- Date: Mon, 3 Dec 2012 22:06:40 -0800 (PST)
From what I saw in "def run_action" of Class: Chef::Resource:
begin
return if should_skip?(action)
provider_for_action(action).run_action
rescue Exception => e
if ignore_failure
Chef::Log.error("#{self} (#{defined_at}) had an error: #{e.message};
ignore_failure is set, continuing")
events.resource_failed(self, action, e)
elsif retries > 0
.....
.....
and from what I read about Chef Exception handlers, it probably can't be done.
For now, I have created an ugly solution...a chef-client wrapper script which
gets the output of chef-client run and if an exception is tossed out with an
exit status of 0, an email is sent with the output.
Ugly, but I was short of ideas and since I'm running from cron, it willll do.
If anyone else has a better idea, please share..
Could this possibly reviewed as a possible feature ?
Thanks!
============================================
For anyone interested, the wrapper script is:
#!/bin/sh
/usr/bin/chef-client > /tmp/chef-init-run.tmp
let chef-success=$?
grep Exception /tmp/chef-init-run.tmp > /dev/null 2>&1
let exception_found=$?
if [[ $chef-success -eq 0 && $exception_found -eq 0 ]];then
/bin/mail -s "Chef run detected some errors, although chef run
completed successfully on `host -TtA $(hostname) |awk '{print $1}'`"
< /tmp/chef-init-run.tmp
fi
# Now remove the temp file
/bin/rm -f /tmp/chef-init-run.tmp
- [chef] Re: Exception Handlers with ignore_failure, jfotop, 12/03/2012
Archive powered by MHonArc 2.6.16.