Kahibaro
Discord Login Register

6.3.4 Chef overview

What Chef Is in the Configuration Management Landscape

Chef is a configuration management and automation tool that treats your infrastructure as code using Ruby-based DSLs. Compared with other tools:

In the context of this course, see Chef as one of the major CM tools alongside Ansible and Puppet, but with its own model and terminology.

Key Concepts and Terminology

Node

A node is any system managed by Chef: physical server, VM, container, cloud instance, etc.
Each node typically runs the Chef client and periodically contacts the Chef server to:

  1. Authenticate
  2. Retrieve its configuration
  3. Apply changes to match the desired state

Chef Server

The Chef Server is the central place where:

In small labs you might also see Chef Solo or Chef Zero, which remove the central server and let you run locally for testing or simple setups.

Workstation

The workstation is where you, the administrator or DevOps engineer, work from. From the workstation you:

Cookbooks, Recipes, and Resources

These are the heart of Chef:

Chef resources describe the desired state, and Chef figures out what needs to be changed to achieve that state.

Run List

The run list tells Chef what to apply on a node during a run. It can include:

Example conceptually: “this node should run recipe[base] and recipe[webserver]”.

Attributes

Attributes are key–value data that affect how recipes behave. They can describe things like:

Attributes can come from multiple sources and have a precedence model (node, role, environment, etc.).

Roles and Environments

How Chef Works: The Basic Workflow

At a high level, the workflow looks like this:

  1. On the workstation
    • Install Chef tooling.
    • Create or modify cookbooks (and recipes).
    • Test changes locally.
    • Upload cookbooks and related data to the Chef Server.
  2. On each node
    • Install the Chef client.
    • Register the node with the Chef server (usually once).
    • Assign a run list (and possibly roles and environment).
  3. During a Chef run (convergence)
    • Node’s Chef client:
      • Authenticates with Chef server.
      • Retrieves its run list and relevant cookbooks.
      • Compiles all recipes into a resource collection.
      • Executes resources in order to reach the desired state.
    • Chef sends updated node data back to the server (attributes, run status, etc.).

Chef calls this process convergence: bringing a node into compliance with the declared configuration.

Example: A Minimal Recipe

Even though other chapters might show more complex examples, a simple recipe illustrates how Chef feels:

package 'nginx' do
  action :install
end
service 'nginx' do
  action [:enable, :start]
end
file '/var/www/html/index.html' do
  content "<h1>Hello from Chef</h1>\n"
  mode '0644'
  owner 'www-data'
  group 'www-data'
end

Conceptually this says:

If you run this recipe multiple times, Chef will only make changes when something is out of sync.

Chef’s Architecture Style

Pull-Based Model

Chef is primarily pull-based:

Some workflows can appear “pushy” using tools like knife ssh or chef-push, but the core design is pull.

Ruby DSL and Flexibility

Chef recipes are Ruby code, not pure data descriptions. This gives:

Where Chef Fits Best

Chef is often used in:

Typical tasks handled by Chef:

Comparison Points (High-Level)

Without going deep into other tools’ internals (which are covered elsewhere in the course), keep these high-level distinctions in mind:

These differences affect how you design your workflows and what skills your team needs.

Learning and Using Chef as a Beginner

If you want to get hands-on with Chef in a simple way:

  1. Set up a workstation on a Linux VM.
  2. Use local modes (like Chef Solo/Chef Zero) to:
    • Write a small cookbook.
    • Create a recipe that installs a package and sets up a file.
  3. Try running the recipe repeatedly to see the idempotent behavior.
  4. Explore how to define a run list and apply different recipes to different nodes in a small lab.

Even without building a full Chef server setup, this gives you a sense of:

Views: 115

Comments

Please login to add a comment.

Don't have an account? Register now!