Information Technology Reference
In-Depth Information
d. Resources. All files in the resources/ folder from every cookbook are loaded
because resources must be loaded before the recipes.
e. Providers. All files in the providers/ folder from every cookbook are loaded so
the resources reference the proper provider.
f. Recipes. All files in the recipes/ folder from every cookbook are loaded and
evaluated. At this point, the recipes are not executed to place the node in the
desired configuration, but the Ruby code is executed and each resource is ad-
ded to the resource collection.
5. Converge
The converge phase is the most critical phase of a Chef run. This is when the Chef re-
cipes are executed on the target node—packages are installed, templates are written,
files are copied, and so on.
6. Report
If the Chef Client run is performed successfully, any new values in the node object are
saved; otherwise, an exception is raised without updating the node object. Then noti-
fication and exception handlers are executed. Notification and exception handlers can
perform a variety of functions, such as sending emails, posting to IRC, or sending
messages to PagerDuty.
The run list is a key component used in a Chef run. As mentioned earlier, the run list con-
tains a list of recipes to execute on the target node. It is not very common to pass a list of re-
cipe .rb files, as we've done so far when running chef-client . Real-world chef runs typic-
ally involve dozens of cookbooks with possibly hundreds of recipes and associated files.
There needs to be a succinct way of referring to all the files in a cookbook. That's the pur-
pose of a run list.
A run list is used to specify the cookbook recipes to be evaluated on a node. A run list speci-
fies recipes in the form recipe['<cookbook_name>::<recipe_name>'] ; for example, re-
cipe['motd::default'] . When the Chef code is contained in the recipes/default.rb file of
a cookbook, the recipe name is optional as the default is implied. recipe['motd'] is equi-
valent to recipe['motd::default'] . Note that the .rb file extension is omitted when refer-
ring to a recipe, as this is assumed.
Search WWH ::




Custom Search