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


A resource is nothing but a Ruby block with four components – a type, a name, one or more attributes, and one or more actions. The following is a typical way to declare a resource in a Chef recipe:

type "name" do
   attribute "value"
   action :type_of_action

All actions have a default value. For example, the package resource's default action is :install and hence, if we just want to install a package, we can just say:

package "package_name"

This will take care of the installation of the latest available version of the package called package_name.

The chef-client handles the processing of recipes in two phases. In the first phase, resource collection is built. In this phase, all the recipes mentioned in run_list are evaluated in the order specified. All the resources described in the recipes are identified and collected into a collection. All the libraries are loaded first to ensure that all Ruby classes and language extensions are available. This is followed by the loading of attributes...