Book Image

Mastering Chef

By : Mayank Joshi
Book Image

Mastering Chef

By: Mayank Joshi

Overview of this book

Table of Contents (20 chapters)
Mastering Chef
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
2
Knife and Its Associated Plugins
10
Data Bags and Templates
Index

Custom Chef handlers


A Chef handler is used to identify different situations that might occur during a chef-client run, and eventually it instructs the chef-client on what it should do to handle these situations. There are three types of handlers in Chef:

  • The exception handler: This is used to identify situations that have caused a chef-client run to fail. This can be used to send out alerts over an email or dashboard.

  • The report handler: This is used to report back when a chef-client run has successfully completed. This can report details about the run, such as the number of resources updated, time taken for a chef-client run to complete, and so on.

  • The start handler: This is used to run events at the beginning of a chef-client run.

Writing custom Chef handlers is nothing more than just inheriting your class from Chef::Handler and overriding the report method.

Let's say we want to send out an email every time a chef-client run breaks. Chef provides a failed? method to check the status of a chef...