Run Lists, Roles, Environments & Testing
Run List & Roles
A run list is the ordered set of recipes/roles applied to a node. A role bundles a reusable run list + attribute set for a class of nodes (e.g. "web_server") so servers with the same job don't duplicate configuration.
# roles/web_server.rb
name 'web_server'
run_list 'recipe[nginx]', 'recipe[my_app]'
default_attributes 'nginx' => { 'port' => 80 }Environments
Groups nodes by deployment stage (dev/staging/production), constraining cookbook versions and overriding attributes per stage — e.g. pinning a tested cookbook version in production while staging tests a newer one.
Chef Server vs. chef-solo/chef-zero
The client-server model: a central Chef Server stores cookbooks/node metadata; Chef Client on each node periodically checks in and converges. chef-solo/chef-zero apply cookbooks directly from the local filesystem without a central server — useful for smaller setups or local dev.
Test Kitchen & InSpec
# InSpec compliance test — spun up and verified by Test Kitchen
# against an isolated VM/container before touching production
describe package('nginx') do
it { should be_installed }
end
describe service('nginx') do
it { should be_running }
it { should be_enabled }
endCustom Resources & Habitat
A custom resource lets you define a new, reusable resource type encapsulating repeated logic behind a clean interface. Chef Habitat takes a different, application-centric approach — packaging an app with its runtime and behavior into a portable artifact, rather than configuring the underlying OS.
Keep your own version of these notes — editable, searchable, and organised by your stack.
Start free