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
About the Author
About the Reviewers
Knife and Its Associated Plugins
Data Bags and Templates

Managing environments

There are multiple ways to manage environments in Chef. They are described in the following subsections.

Using Knife

Knife can be used to create, edit, delete, show information about a particular environment, or list all available environments. It can be used to push the configuration concerned with an environment through a file containing code written using Ruby DSL and eventually this file can be maintained in the version control system.

Creating a new environment

The knife environment create ENVIRONMENT_NAME command can be used to create a new environment. Let's use it to create a new environment called production and see the command in action:

$ knife environment create production

As soon as you execute this command, an editor will open up. The choice of which editor to make use of can be configured by editing the value of knife[:editor] in your knife.rb file.

The file will look something like this:

   "name": "production",
   "description": "Production Environment...