Information Technology Reference
In-Depth Information
Chef Client - Linux/Mac OS X:
$
touch recipes/message.rb
Chef Client - Windows:
$
touch recipes\message.rb
Now edit the
recipes/message.rb
file containing the recipe as shown in
Example 8-8
.
The
message recipe will be used to set additional values related to the message of the day.
Example 8-8. chefdk/motd-attributes/recipes/message.rb
node
.
default
[
'motd-attributes'
][
'company'
] =
'the best company in the universe'
TIP
Note that our
.kitchen.yml
file includes only a reference to the
default
recipe in its run
list. We never intend for external consumers of our cookbook to refer to this
message
re-
cipe directly. We're just using the
message
recipe to organize our code, and it is assumed
that
include_recipe
will be used inside the
default
recipe to include any other neces-
sary code:
...
run_list:
- recipe[motd-attributes::default]
...
Some Chef coders use the convention of putting an underscore prefix (“_”) in the name of
recipes that are “private”—recipes used merely to organize Chef code into smaller, more
understandable chunks. They name the recipe file
"_message.rb"
to make this intent
more clear in the cookbook file structure.
Also, you need to add an
include_recipe
statement to your
default.rb
. The
in-
clude_recipe
statement ensures that the
message.rb
file gets processed during the Chef run.
Otherwise, only the recipe file
default.rb
will be evaluated when the run list is
motd-at-