Chapter 14. Roles
Roles are a way of classifying the different types of services in your infrastructure, as shown in Figure 14-1.
Roles can be used to represent the types of servers in your infrastructure:
- Load balancer
- Application server
- Database cache
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 functionality 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 under 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 ...