Skip to end of metadata
Go to start of metadata




Opscode provides a cookbook for distributing custom Chef Handlers.

Add cookbook to chef-repo

Download the cookbook to your Chef Repository.

Write Chef Handler

See the Exception and Report Handlers page for instructions on how to write new Chef handlers. These files will go under cookbooks/chef_handler/files/default/handlers.

Change the Handler Path

If you wish to change the directory where the handlers are copied, edit the cookbook attributes file and change the path for the node['chef_handler']['handler_path'] attribute. You can also set this value in a role.

Enable the Chef Handler with the chef_handler LWRP

After you distribute handler files down to the node, you have to enable it so Chef will know to fire it on the conclusion of Chef runs. This is very easy to do using the chef_handler LWRP. This LWRP requires, configures and enables handlers on the node for the current Chef run. It also has the ability to pass arguments to the handlers initializer, allowing initialization data to be pulled from a node's attribute data.

It is best to declare `chef_handler` resources early on in the compile phase so they are available to fire for any exceptions during the Chef run.
If you have a base role you would want any recipes that register Chef handlers to come first in the run_list.

Upload to your Chef Server

The cookbook needs to be uploaded to the Chef Server to be used.

Add the recipe to a run list

Add the recipe[chef_handler] to a node or role run list. Put it first to make sure your custom handlers are loaded and available to other recipes.
When Chef runs, during the compile phase the handlers will be copied into place and be available for enabling with the chef_handler LWRP.

Additional Information

See the README.md of the chef_handler cookbook for additional information.





Exception and Report Handlers


Lightweight Resources and Providers (LWRP)



Labels:
None
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.