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
About the Author
About the Reviewers
Knife and Its Associated Plugins
Data Bags and Templates

Custom plugins

For most purpose, the plugins provided by Ohai will be good enough. However, sooner or later, one lands up in a situation where one wants some attributes associated with nodes being provisioned, and these attributes define a system-level property that can be used to make certain decisions during the chef-client run. For such cases, Ohai provides us with the ability to write our own custom plugins. Ohai provides a very simple DSL that can be used for this purpose. For example, we run a large number of machines on AWS and there are different kinds of machines available known by different names such as m1.xlarge, c1.xlarge, and so on. We want to push different configurations on the basis of different types of EC2 instance. So, we go ahead and write our plugin that emits an attribute called node['machine_type']. Now, in our cookbooks, we can make use of this attribute to decide which config to push to the node.

A custom plugin describes a set of attributes to be collected by Ohai...