Information Technology Reference
In-Depth Information
Environments might include attributes necessary for configuring your infrastructure, such as:
▪ The URL of a payment service API
▪ The location of a package repository
▪ The version of Chef configuration files that should be used
Environments allow for isolating resources on a Chef Server because environments can con-
tain version constraints, unlike with roles. Environments still have a use even when you have
Test Kitchen at your disposal, because you'll probably want to do some testing against serv-
ers in your production environment.
Create a Dev Environment
Environments can be created and managed in the same fashion as data bags and roles, organ-
ized in a directory under chef-playground . The directory name is environments 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 that the chef-playground directory is the current working directory:
$ cd chef-playground
Create an environments directory in chef-playground :
$ mkdir environments
We're going to create a .json file representing the new environment. A basic environment has
a name: and description: . Environments can have one or more cookbook constraints as
well. The ability to “pin” cookbooks to particular versions is the most useful feature of envir-
onments. Create the file chef-playground/roles/dev.json containing the code provided in
Example 15-1 .
Search WWH ::




Custom Search