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 Q&A (Part 2): Resources, Run-Lists, Bootstrap, and Test Kitchen

Chef interview rounds usually go beyond definitions and test whether you understand convergence behavior, resource order, and node lifecycle operations. This revised guide turns the original Q&A into a concise field reference for interview prep and real operations work.

Originally published on 2015-09-02; fully revised and updated.

Original source attribution in the post pointed to learn.chef.io. Community cookbooks referenced in the material are available through Chef Supermarket.

Core Chef concepts interviewers expect

  • Resource: A unit of desired state (for example, a package, service, or file).
  • Recipe: An ordered collection of resources that applies configuration policy.
  • Cookbook: A package of recipes plus supporting files (templates, attributes, libraries, etc.).
  • Node: A managed compute instance (VM, physical host, or container host context).
  • Run-list: The ordered list of recipes/roles a node applies during a Chef run.

Resource execution order and default actions

Chef processes resources in the order they appear in a recipe. That ordering can be the difference between a successful converge and a failed run.

Default action behavior

If you omit an explicit action, Chef uses that resource type’s default action. For example, package resources typically default to install behavior.

package 'httpd'
# No action specified; package resource uses its default action.Code language: PHP (php)

Order-sensitive versus order-insensitive cases

# Works in expected sequence: package first, service second
package 'httpd'

service 'httpd' do
  action [:enable, :start]
endCode language: PHP (php)
# Risky sequence: service before package
service 'httpd' do
  action [:enable, :start]
end

package 'httpd'Code language: PHP (php)
ComparisonEquivalent?Why
package then service vs service then packageNoChef executes top-to-bottom; service actions may fail if package/service unit is not present yet.
action [:enable, :start] vs action [:start, :enable]Not strictlyBoth can reach similar end state, but operation order differs and can matter for notifications/timing.
Same file resource attributes in different orderYesAttribute line order inside a single resource block is not the key behavior driver in this case.
service 'httpd' do
  action [:stop, :disable]
endCode language: JavaScript (javascript)

Recipe, cookbook, and run-list relationships

Interviews often probe whether you can connect authoring to execution: resources live in recipes, recipes are packaged as cookbooks, and run-lists define what each node applies and in what order.

knife node run_list add web1 'recipe[apache::default]'
knife node show web1 -a run_listCode language: JavaScript (javascript)

The original material also highlights two server consumption models: running Chef Server on your own infrastructure or using a hosted offering, and using the Starter Kit credentials to securely connect with knife.

chef-apply vs chef-client vs knife

ToolBest forTypical scope
chef-applyQuick local testing/learning of a single recipeOne recipe at a time
chef-clientNormal node convergence in managed environmentsApplies node run-list (one or more cookbooks/recipes)
knifeWorkstation-to-server operationsBootstrap, upload cookbooks, inspect nodes, remote execution
chef-apply ./example.rb
chef-client
knife node listCode language: PHP (php)

Node bootstrap and first converge workflow

flowchart TD
    A[Prepare workstation credentials] --> B[Run knife bootstrap]
    B --> C[Node installs chef-client]
    C --> D[Node registers with Chef Server]
    D --> E[Node pulls assigned run-list]
    E --> F[Chef Infra Client converges resources]
    F --> G{Configuration drift remains}
    G -- yes --> H[Update cookbook and upload]
    H --> F
    G -- no --> I[Node stays in desired state]
knife bootstrap NODE_IP \
  -x USER \
  -P 'PASSWORD' \
  --sudo \
  --node-name web1 \
  --run-list 'recipe[apache::default]'Code language: PHP (php)

Uploading and applying cookbook updates

After editing a cookbook, upload it to Chef Server and trigger a converge on target nodes.

knife cookbook upload awesome_customers
knife ssh 'name:web1' 'sudo chef-client'
ssh user@web1.example.com 'sudo chef-client'Code language: JavaScript (javascript)

The source also references Semantic Versioning guidance: setting cookbook version 1.0.0 once it is considered production-ready.

Template example: render node data into an HTML page

This ERB example from the original content demonstrates using node attributes in a template:

<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)

Then upload the cookbook and run chef-client on the node to apply the updated template.

Local cookbook testing with Test Kitchen

For faster development cycles, Test Kitchen can create ephemeral instances, converge cookbooks, and tear instances down after validation.

ComponentRoleHow it fits the workflow
Test KitchenTest orchestratorDefines platform/suite matrix and runs converge/verify lifecycle.
VagrantEnvironment managerBridges Kitchen and local providers; handles VM definitions and lifecycle commands.
VirtualBoxVirtualization providerRuns the actual local virtual machines used by Kitchen in this setup.
---
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-65
kitchen destroyCode language: PHP (php)

Best practices and common pitfalls

  • Explain resource order clearly in interviews; it is one of the most common failure patterns.
  • Use run-lists intentionally; sequence across cookbooks can affect service readiness.
  • Test cookbook changes in ephemeral environments before production convergence.
  • Keep cookbook versions meaningful and increment with change impact.
  • Do not assume old platform examples (for example, CentOS 6.x) are suitable for current production baselines.

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 Questions, Explained: Resources, Run-Lists, Bootstrapping, and Test Kitchen

This updated guide converts classic Chef interview Q&A into a practical reference for real infrastructure work. It covers core concepts, execution order, bootstrap flow, key knife commands, and Test Kitchen testing patterns.

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

Chef interview preparation is stronger when you can explain how recipes work in real environments. Practice examples involving cookbooks, attributes, templates, and resources to show your problem-solving skills. It also helps to understand idempotency and why repeated runs should keep systems in the desired state. Be ready to discuss how you test changes before applying them to production. Real examples from troubleshooting configuration issues can make your answers more clear and convincing.

Punam sharma
Punam sharma
1 month ago

A useful way to prepare for Chef-related interviews is to practice diagnosing configuration drift rather than memorizing command definitions alone. For example, consider a node that repeatedly changes a configuration file back to an unexpected value after every Chef run. Understanding how cookbook attributes, resource notifications, execution order, and environment-specific settings interact helps explain why this happens. I would also practice testing cookbook changes in an isolated environment before applying them to production nodes, since safe, repeatable infrastructure changes are a major part of real configuration management work.

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