Chef Certified cheat sheet
Chef Certified · Keep the key ideas within reach.
Chef Automation and Infrastructure Management
Chef Infra operates in two modes: client-server (Chef Infra Server with PostgreSQL and RabbitMQ) and chef-solo/chef-zero for local, serverless convergence.
Convergence order: compile phase builds the resource collection, then converge phase executes resources in the order declared; compile-time Ruby runs before any resource actions.
Resource execution is idempotent: each resource has a load_current_value or current state comparison, and actions run only when the desired state differs.
Notification types:
notifies :action, 'resource[name]', :immediatelyruns at once; default:delayedqueues the notification to run at the end of the converge.Subscribes is the inverse of notifies:
subscribes :restart, 'service[nginx]', :immediatelymakes the current resource trigger the named resource.Chef Infra Client runs are recorded as a node object on the Chef Infra Server, including normal, default, override, and automatic attribute precedence levels.
Attribute precedence (low to high): default, force_default, normal, override, force_override, automatic;
node.force_defaultandnode.force_overrideare set in recipes.Recipes use
include_recipefor static composition;dependsin metadata.rb declares cookbook dependency and is required forinclude_recipeacross cookbooks.Chef Habitat packages applications with a plan.sh, a studio build environment, and a supervisor that exports runtime configuration and service bindings.
Infrastructure Management
Node object attributes:
automatic(Ohai data),normal(persisted by chef-client),default,override; onlynormalandautomaticsurvive a run and are searchable.Search indexes are built from the Chef Infra Server Solr backend;
search(:node, 'role:web')returns node objects from the index, refreshed after each client run.Environments pin cookbook versions via
cookbook_versionsconstraints;knife environment createandknife environment editmanage them.Roles and environments are JSON; roles can set
default_attributesandoverride_attributesand list arun_list.knife bootstrapinstalls chef-client on a target via SSH/WinRM;knife bootstrap -N NAME -r 'role[base]'sets node name and initial run list.Data bags store JSON objects in
data_bags/<bag>/<item>.json;data_bag_item('bag', 'item')loads them, and encrypted data bags useencrypted_data_bag_secret.Chef Infra Server components: Erchef (API), Bookshelf (cookbook storage), Solr (search), PostgreSQL (data), RabbitMQ (queues), and Chef Manage (web UI).
knife cookbook uploaduploads cookbooks;berks uploadandchef supermarketmanage dependencies from a Berksfile or Policyfile.Policyfiles replace roles/environments:
chef installresolves a lockfile,chef pushuploads a policy group, andchef-client -zruns locally with policy.
Compliance Management
Chef InSpec profiles contain controls; each control has an impact (0.0-1.0), title, description, and one or more
describeblocks with matchers.Impact thresholds: 0.0-0.3 informational, 0.4-0.6 low, 0.7-0.8 medium, 0.9-1.0 high/critical; the
--thresholdflag fails the run when the score falls below it.InSpec resources include
file,service,package,port,sshd_config,auditd,os, andusers;describe file('/etc/passwd') { it { should exist } }.inspec exec profile.tar.gz -t ssh://user@hostruns a profile remotely;-t docker://containertargets a container;--reporter cli json htmlsets output formats.Chef Automate ingests compliance reports via the
automatereporter and data collector token; the compliance dashboard shows control status by node and profile.Waivers:
inspec exec --waiver-file waivers.yamlsuppresses specified controls;control 'id' do ... endcan also useonly_iforskip_control.inspec checkvalidates profile syntax and metadata;inspec vendorpackages dependencies;inspec jsonemits the profile as JSON for automation.The
compliancecookbook orinspecresource in a recipe can run profiles during convergence, andchef-client --audit-moderuns audits without converging.
Job Orchestration
Chef Automate includes a workflow engine (formerly Chef Delivery) with pipeline stages: verify, build, unit, lint, syntax, publish, provision, deploy, smoke, and functional.
A
.delivery/cli.tomldefines the project, pipeline, and channel;.delivery/build-cookbooksupplies the build recipes for each stage.delivery reviewcreates a review pipeline;delivery jobruns a stage locally;delivery setupconfigures the project in Automate.Chef Push Jobs (push-jobs-client) executes commands on nodes on demand via the push-jobs server;
knife job start 'chef-client' --nodes 'role:web'.Push jobs use the
push-jobscookbook and apush_jobsdata bag for whitelisted commands; the server is a Chef Infra Server add-on.chef-client --onceruns a single convergence and exits;--intervaland--splaycontrol the daemon schedule;--why-runsimulates without changing state.Chef Infra Server's
chef-server-ctlcommands manage services:reconfigure,status,tail, andrestart;knife statusreports last check-in times.Cron and systemd timers are common orchestration triggers for chef-client; the
cronresource writes entries andsystemd_unitmanages timers.