Book Image

Chef Essentials

By : John Ewart
Book Image

Chef Essentials

By: John Ewart

Overview of this book

<p>Chef is a configuration management tool that turns IT infrastructure into code. Chef provides tools to manage systems at scale. With this book, you will learn how to use the same tools that companies such as Facebook, Riot Games, and Ancestry.com use to manage and scale their infrastructure.</p> <p>This book takes you on a comprehensive tour of Chef's functionality, ranging from its core features to advanced development. You will be brought up to speed with what's new in Chef and how to set up your own Chef infrastructure for individuals, or small or large teams. Once you have the core components, you will get to grips with bootstrapping hosts to then develop and apply cookbooks. If you want to fully leverage Chef, this book will show you advanced recipes to help you handle new types of data providers and resources. By the end of this book, you will be confident in how to manage your infrastructure, scale using the cloud, and extend the built-in functionality of Chef itself.</p>
Table of Contents (15 chapters)
Chef Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Defining roles


Here we will construct our three roles, one each for our base server configuration, database server, and web server. Each role will have a set of recipes to run, with the base server providing the user accounts, SSH keys, and other common components, and then the others providing configuration data for PostgreSQL and nginx, respectively.

Creating the base server role

The key bits that are of interest in our base server role are the run list and the configuration data that specify which group to populate users for. If you look at the file roles/base_server.json, you will see that we have defined one group of users to pull from our data bags:

"override_attributes": {
  "shell_users": {
    "group": "webapp"
  }
}

And then, the recipe we want to use that will populate the users on the host is in the run list:

"run_list": [
  "users::shell_users"
],

In order to load the role into Chef, you can issue a from file command:

knife role from file base_server.json
Updated Role base _server...