Chef interviews and day-to-day operations often revolve around the same fundamentals: resources, recipes, cookbooks, run-lists, node bootstrapping, and local testing. This guide is for DevOps engineers who want clear, interview-ready answers plus production-oriented examples.
Originally published on 2015-09-02; fully revised and updated.
Source material: learn.chef.io (original Q&A format), reorganized here into a structured reference.
Core Chef concepts interviewers ask most often
| Concept | What it means in practice | Interview-ready answer |
|---|---|---|
| Resource | A unit of desired state (package, service, file, template, user, etc.). | A resource describes what state must exist, not just a command to run. |
| Recipe | An ordered collection of resources. | A recipe defines configuration policy for part of a system. |
| Cookbook | A package of recipes plus templates, files, attributes, and metadata. | A cookbook is the reusable delivery unit; a recipe is one part inside it. |
| Run-list | Ordered list of recipes/roles a node applies. | Run-list controls what runs and in which order. |
| Node | Any managed machine (VM, bare metal, or instance). | A node is the compute target that runs chef-client and converges policy. |
| Starter Kit | Workstation files and credentials for secure Chef Server access. | It contains keys/config needed for authenticated communication. |
Why resource order and action order matter
Chef applies resources in the order they are declared during convergence. That means ordering can decide whether a run succeeds or fails.
package 'httpd'
service 'httpd' do
action [:enable, :start]
endCode language: JavaScript (javascript)
The example above typically works because the package is installed before the service is managed.
service 'httpd' do
action [:enable, :start]
end
package 'httpd'Code language: JavaScript (javascript)
This order can fail if the service provider cannot manage httpd before the package exists.
| Case | Equivalent? | Why |
|---|---|---|
| package then service | No (vs service then package) | Resource declaration order changes convergence behavior. |
| action [:enable, :start] vs [:start, :enable] | Not strictly identical | Actions are executed in listed order; boot/runtime side effects may differ. |
| Different ordering of attributes inside one resource | Usually yes | Attribute line order inside the same resource does not typically change outcome. |
file '/etc/motd' do
owner 'root'
group 'root'
mode '0755'
action :create
end
file '/etc/motd' do
action :create
mode '0755'
group 'root'
owner 'root'
endCode language: JavaScript (javascript)
chef-apply vs chef-client
| Command | Best for | Typical scope | Common use |
|---|---|---|---|
| chef-apply | Quick local experiments | Single recipe file | Learning, prototyping, one-off validation |
| chef-client | Managed node convergence | Run-list and cookbook content | Production configuration runs via Chef Server or local mode |
Chef Server options and bootstrap prerequisites
The original material describes two common server patterns: self-hosted Chef Server and hosted Chef offerings.
| Option | Control | Operational overhead |
|---|---|---|
| Self-hosted Chef Server | High | You manage installation, upgrades, backup, and availability. |
| Hosted Chef service | Lower | Provider operates the control plane; you focus on policy and nodes. |
For bootstrapping a node from your workstation, you generally need:
- Node host name or reachable IP address
- A login user with privilege to install software
- Password authentication or (preferably) SSH key authentication
- Workstation credentials (Starter Kit) to talk to Chef Server
Bootstrap workflow from workstation to managed node
flowchart TD
A[Workstation with knife] --> B[Bootstrap target node]
B --> C[Install chef-client]
C --> D[Register node with Chef Server]
D --> E[Assign run list]
E --> F[Converge resources in order]
F --> G[Node checkin completes]
G --> H[Verify node in knife or console]
knife bootstrap <NODE_IP> -x <SSH_USER> -i <PATH_TO_PRIVATE_KEY> --sudo --node-name <NODE_NAME> --run-list 'recipe[apache::default]'
knife node list
knife node show <NODE_NAME>Code language: HTML, XML (xml)
Common knife commands from the original Q&A
| Command | Purpose |
|---|---|
| knife node list | List registered nodes |
| knife node show NODE | View details for a specific node |
| knife cookbook upload COOKBOOK | Upload cookbook content to Chef Server |
| knife ssh QUERY CMD | Run remote commands across matching nodes |
| knife cookbook site show NAME | Query cookbook metadata from the community site |
Reusable community cookbooks are published on Chef Supermarket.
Template and versioning example
The original article shows rendering node facts into an HTML template. The ERB below mirrors that pattern.
<html>
<body>
<h1>hello from <%= node['fqdn'] %></h1>
<pre>
<%= node['hostname'] %>
<%= node['platform'] %> - <%= node['platform_version'] %>
<%= node['memory']['total'] %> RAM
<%= node['cpu']['total'] %> CPUs
</pre>
</body>
</html>Code language: HTML, XML (xml)
# metadata.rb
version '1.0.0'Code language: PHP (php)
Using 1.0.0 for a production-ready first stable release matches Semantic Versioning practice.
Testing on multiple platforms with Test Kitchen
Test Kitchen helps run the same cookbook across a platform matrix. The source example uses CentOS 6.x; treat that as historical and map to currently supported images in your environment.
---
driver:
name: vagrant
provisioner:
name: chef_zero
platforms:
- name: centos-6.6
- name: centos-6.5
suites:
- name: default
run_list:
- recipe[motd::default]Code language: CSS (css)
kitchen list
kitchen converge
kitchen login default-centos-66
kitchen login default-centos-65Code language: PHP (php)
Best practices for interviews and real Chef usage
- Explain Chef in terms of desired state and idempotent resources, not shell scripts.
- Call out ordering explicitly: recipe order matters; attribute line order inside a resource usually does not.
- Use
chef-applyfor quick experiments, but describechef-clientfor managed production convergence. - Show verification habits: check run-list, inspect node data, and test across multiple platforms with Test Kitchen.
- Version cookbooks deliberately and promote through environments instead of ad-hoc edits on servers.
I’m Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms.
I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.
Find Trusted Cardiac Hospitals
Compare heart hospitals by city and services — all in one place.
Explore Hospitals