- From: Andrea Campi <
>
- To: "
" <
>
- Cc: "
" <
>
- Subject: [chef] Re: Re: Exception Handlers with ignore_failure
- Date: Tue, 4 Dec 2012 08:30:35 +0100
Are you sure?
The events.resource_failed in the code that you pasted looks exactly what is
needed. I don't have the code in front of me but I think notifiers have
access to that.
On Dec 4, 2012, at 7:06 AM, jfotop
<
>
wrote:
>
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
Archive powered by MHonArc 2.6.16.