Information Technology Reference
In-Depth Information
▪ Database
▪ Monitoring
Although you can add recipes directly to a node's run list, that's not how your infrastructure
works. Think about how you normally refer to servers:
▪ “It's a
web server
.”
▪ “It's a
database server
.”
▪ “It's a
monitoring server
.”
Roles allow you to conveniently encapsulate the run lists and attributes required for a server
to be what you already think it is. Roles make it easy to configure many nodes identically
without repeating yourself each time.
In addition to obvious roles, such as a “web server,” it is common practice to group any func-
tionality that goes together into a role. The most common example is a
base role
, where you
include all the recipes that should be run on every node.
Create a Web Server Role
Roles can be created and managed in the same fashion as data bags—there is a directory un-
der
chef-playground
in which they are organized. The directory name is
roles
by default.
Use the
chef-playground
directory you created in
Chapter 11
.
Use the same dual command
prompt setup you used there. Start the
chef-zero
server on an open port in one window. We
will be using port 9501 in the examples in this chapter:
$
chef-zero --port 9501
Make sure the
chef-playground
directory is the current working directory:
$
cd chef-playground
Now run
knife upload nodes
to load up
chef-zero
with fake node data: