Exception Handlers with ignore_failure

The following question may be plain dumb, but since I’m not afraid to be called
dumb, I’m going to ask :stuck_out_tongue:

Is there anyway to use exception handlers on a chef run and get an email (like
the one in http://docs.opscode.com/essentials_handlers_write.html) if a
resource that has “ignore_failure -> true” ?
I want to configure chef to continue it’s run even if some resources fail, but
get notified via email if any resource failed and only if there was a failure.
I’ll say it also in another way:

  • If resource with ignore_failure->true fails, continue run but send an email.
  • If resource with ignore_failure->false fails, exit chef run and send an
    email.
  • If nothing fails, don’t send an email…

Thanks in advance!!

totally not dumb, imo. lookin' forward to readin' feedback.

kallen

On Mon, 03 Dec 2012, jfotop wrote:

The following question may be plain dumb, but since I'm not afraid to be called
dumb, I'm going to ask :stuck_out_tongue:

Is there anyway to use exception handlers on a chef run and get an email (like
the one in http://docs.opscode.com/essentials_handlers_write.html) if a
resource that has "ignore_failure -> true" ?
I want to configure chef to continue it's run even if some resources fail, but
get notified via email if any resource failed and only if there was a failure.
I'll say it also in another way:

  • If resource with ignore_failure->true fails, continue run but send an email.
  • If resource with ignore_failure->false fails, exit chef run and send an
    email.
  • If nothing fails, don't send an email...

Thanks in advance!!

U can use chef_handlers to send a mail.

Chef.event_handler do
on :resource_failed do
HandlerSendEmail::Helper.new.send_email_on_run_failure(
Chef.run_context.node.name
)
end
end
something like this u can use