How to write a chef_handler to send mail when chef-client is run unsuccessfully?

966 views Asked by At

I have already been through the documentation on Chef-Client Handler:

https://docs.chef.io/resource_chef_handler.html

What I would like to achieve is to send a mail whenever there there is a failure during the chef-client run on the Node.

1> Is there a sample recipe or notes that I could refer to? 
2> Should the SMTP Server be enabled on the Node, or on the CHEF 
Server?
3> Almost all the Knowledge base pages were written for CHEF 13, and those notes doesn't seems to work on CHEF 14, so is there any additional settings that has been done or needs to be done?
4> Is there a sample code with instructions to which I could refer that I could use to set up my recipe??

Thank you

1

There are 1 answers

2
coderanger On

That is literally the example shown on https://docs.chef.io/handlers.html#send-email :)