Information Technology Reference
In-Depth Information
$
cd ..
$
mkdir roles
$
cd roles
to denote nodes that are web servers. Create the file
chef-zero/roles/webserver.json
as shown
in
Example 15-4
.
It contains the
apache
directory in its run list and the attribute
node['apache']['port']
set at the default attribute precedence. We'll be using this attrib-
ute to show how we can change the behavior of the cookbook depending on whether the
node is in production.
Example 15-4. chefdk/chef-zero/roles/webserver.json
{
"name"
:
"webserver"
,
"description"
:
"Web Server"
,
"json_class"
:
"Chef::Role"
,
"chef_type"
:
"role"
,
"default_attributes"
: {
"apache"
: {
"port"
:
80
}
},
"run_list"
:
[
"recipe[apache]"
]
}
Create a directory called
cookbooks
, parallel to the others you have created so far in this
chapter, and make it the current working directory:
$
cd ..
$
mkdir cookbooks
$
cd cookbooks
So far, your
chef-zero
directory should resemble the following structure:
chef-zero
├── cookbooks
├── environments
│ └── production.json