Chef

Back to Production-Engineering/Chef

A configuration management tool in Ruby and Erlang.

TL;DR, chef configures and provisions nodes (a network of machines known to the chef server) on a chef-client run, by building a run-list (from roles and recipes, to bring the node to the desired state) and a set of attributes to check the node's state (defined by the node, cookbooks and roles).

Background

Provisioning != Configuration

Workstations (developer tools, knife)

Chef Development kit bundles all tools together, for setting up a developer environment.

chef-repo

Master repo of all cookbooks, roles, data bags, environments, config files for clients, workstations, and servers. knife loads data to the chef server from the chef-repo.

Cooker runs on the Chef Server, and modifies this structure, by handling interaction with the chef server (automatic uploading cookbooks, roles and data bags). It creates separate chef environments for each branch.

Sub-directories:

Nodes and Chef Clients

chef-client Run

A series of steps taken by the chef-client when it is configuring a node.

chef run diagram

Run-list

The run-list defines all of the info necessary for Chef to configure a node into the desired state

Node Object

For the chef-client, two important aspects of nodes are groups of attributes and run-lists.

Chef Server

Cookbooks

A fundamental unit of configuration and policy distribution. Defines a scenario (specific application for example) and contains everything required to support it. Cookbooks are combined in the configuration process

Policy

Policy maps operational requirements, process, and workflow to settings and objects stored on the Chef server:

Roles

A role is some set of basic configurations that may be applied to similar servers, playing a similar "role".

Roles use the ruby DSL (a bunch of methods with parameters):

name "web_server"
description "A role to configure our front-line web servers"
run_list "recipe[apt]", "recipe[nginx]"

Attributes

Used by the chef-client to understand

during every chef-client run, the chef client builds attribute list, defined by:

Environment

Taken care of by Cooker, but in regular setup, found in /environments

Read setup next