MYHOSPITALNOW.COM

Find Trusted Doctors & Hospitals

Discover healthcare providers, compare hospitals, and explore treatment options worldwide.

Free Treatment Quotes • Doctor Search • Hospital Comparison

Find Healthcare Options

www.myhospitalnow.com

Chef Interview Questions, Explained: Resources, Run-Lists, Bootstrapping, and Test Kitchen

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

ConceptWhat it means in practiceInterview-ready answer
ResourceA unit of desired state (package, service, file, template, user, etc.).A resource describes what state must exist, not just a command to run.
RecipeAn ordered collection of resources.A recipe defines configuration policy for part of a system.
CookbookA package of recipes plus templates, files, attributes, and metadata.A cookbook is the reusable delivery unit; a recipe is one part inside it.
Run-listOrdered list of recipes/roles a node applies.Run-list controls what runs and in which order.
NodeAny managed machine (VM, bare metal, or instance).A node is the compute target that runs chef-client and converges policy.
Starter KitWorkstation 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.

CaseEquivalent?Why
package then serviceNo (vs service then package)Resource declaration order changes convergence behavior.
action [:enable, :start] vs [:start, :enable]Not strictly identicalActions are executed in listed order; boot/runtime side effects may differ.
Different ordering of attributes inside one resourceUsually yesAttribute 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

CommandBest forTypical scopeCommon use
chef-applyQuick local experimentsSingle recipe fileLearning, prototyping, one-off validation
chef-clientManaged node convergenceRun-list and cookbook contentProduction 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.

OptionControlOperational overhead
Self-hosted Chef ServerHighYou manage installation, upgrades, backup, and availability.
Hosted Chef serviceLowerProvider 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

CommandPurpose
knife node listList registered nodes
knife node show NODEView details for a specific node
knife cookbook upload COOKBOOKUpload cookbook content to Chef Server
knife ssh QUERY CMDRun remote commands across matching nodes
knife cookbook site show NAMEQuery 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-apply for quick experiments, but describe chef-client for 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.

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals
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.

Related Posts

Chef Interview Q&A (Part 2): Resources, Run-Lists, Bootstrap, and Test Kitchen

A practical rewrite of classic Chef interview questions, focused on how Chef resources converge, how run-lists drive node configuration, and how to test cookbooks safely. Includes command examples, workflow diagrams, and comparison tables.

Read More

Chef Configuration Management Training: 3-Day Hands-On Curriculum for DevOps Teams

This revised guide turns a legacy Chef course post into a clear 3-day learning roadmap for DevOps teams. It covers the agenda, toolchain, workflow, and practical commands learners should expect.

Read More

Chef Training Roadmap for DevOps Engineers: Course Tracks, Lab Workflow, and Practical Commands

This guide turns a promotional Chef training post into a practical roadmap for engineers. Compare course levels, understand the learning workflow, and use hands-on commands you can run in a lab.

Read More

Chef Command-Line Reference: Essential chef-solo, chef-client, and Knife Workflows

A task-oriented reference for frequently used Chef and Knife commands, from cookbook scaffolding to node bootstrap and run-list management. Includes workflow guidance and copy-ready command examples.

Read More

Chef Training in Bangalore

DevOpsSchool introduce advance Chef Training in Bangalore with most experts professionals. Our Teams of Chef trainers offers chef online and classroom training from essential to advance level….

Read More

Provision an AWS EC2 Instance with Chef (Legacy ChefDK Workflow)

A practical, step-by-step walkthrough for provisioning an AWS EC2 VM using the classic ChefDK and chef-provisioning approach. Includes workflow, commands, recipe examples, and validation checks for legacy environments.

Read More
Subscribe
Notify of
guest
2 Comments
Newest
Oldest Most Voted
Puja kushwaha
Puja kushwaha
28 days ago

Understanding Chef concepts matters more than memorizing interview answers. Try explaining how a cookbook manages a service or keeps a configuration file consistent across servers. It is also useful to know how attributes, recipes, and resources work together. Practicing safe tests and handling failed runs can help you answer real-world questions with confidence. These examples show that you can apply configuration management skills, not just describe them.

Sunil Rajak
Sunil Rajak
1 month ago

Beyond interview preparation, it is worth understanding how Chef fits into infrastructure testing and change governance. In larger environments, a cookbook can affect hundreds of machines, so even a small logic error may create widespread configuration problems. I would focus on techniques such as Test Kitchen for validating changes before deployment, InSpec for checking the resulting system state, and staged rollouts to limit the impact of unexpected behavior. Being able to explain how these practices reduce operational risk demonstrates a much stronger understanding of configuration management than knowing definitions alone.

2
0
Would love your thoughts, please comment.x
()
x