Book Image

Mastering Chef

By : Mayank Joshi
Book Image

Mastering Chef

By: Mayank Joshi

Overview of this book

Table of Contents (20 chapters)
Mastering Chef
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
2
Knife and Its Associated Plugins
10
Data Bags and Templates
Index

Setting up an environment on a node


Once environments have been created, we will need to ensure that the nodes are correctly associated with the environments. Again, as with the management of environments, there are multiple ways to associate a node with an environment.

Using Knife

We can make use of the knife node command with the environment_set argument to set the environment for a node without editing the node object:

$ knife node environment_set node01 production

This will set the environment for node01 as production. The next time chef-client executes on the node, it'll apply the configuration corresponding to the production environment on node01.

We can also edit the node object itself and set the chef_environment property with the required environment name as follows:

$ knife node edit node01

This will open up the corresponding node01 object's JSON in the text editor. Add/edit the chef_environment property with the right environment name and save the file to apply the changes:

{
   ...