Information Technology Reference
In-Depth Information
Because cookbooks are versioned, a pattern of using a role cookbook in lieu of using the run
list feature of roles is one technique many Chef developers use. They still use roles for com-
mon attributes, but the role run list is moved to a cookbook. A recipe can emulate a role run
list easily through the use of the include_recipe command we introduced in In-
clude_Recipe .
For example, in this case, we could create a webserver cookbook where the default recipe
includes the apache cookbook:
#
# Cookbook Name:: webserver
# Recipe:: default
#
# Copyright (C) 2014
#
#
#
include_recipe "motd"
include_recipe "user"
include_recipe "apache"
Nodes could still include the webserver role as a classification mechanism and for any
shared attributes. It can still be handy to run this command to find all the web servers on
your network:
knife search node role : webserver
NOTE
chef-zero currently does not seem to index roles for searching, so the preceding com-
mand will not work with the test setup in this chapter. Instead, you'll need to use a full
Chef Server setup.
In this scenario, the run list of the webserver role would be blank, and instead nodes would
add the cookbook recipe[webserver] to their run list. Cookbooks are versioned, and with
environments, which we'll introduce in the next chapter, you can ensure that a subset of
Search WWH ::




Custom Search