Find the Best Cosmetic Hospitals

Explore trusted cosmetic hospitals and make a confident choice for your transformation.

“Invest in yourself — your confidence is always worth it.”

Explore Cosmetic Hospitals

Start your journey today — compare options in one place.

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

TFS Interview Questions and Answers: Practical DevOps Guide

A structured, interview-focused guide to Team Foundation Server (TFS), including TFVC vs Git, build and reporting topics, and practical command examples. Use it to prepare concise, technically strong answers for common TFS interview scenarios.

Read More

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

SVN Interview Questions and Answers: Trunk, Branch, Tag, Update, Commit, Patch, Backup, and Authentication

A practical, interview-focused guide to Subversion (SVN) concepts and commands. Learn how to explain trunk/branch/tag, update vs commit, conflict handling, patching, backup/restore, and auth setup with confidence.

Read More

Jenkins Interview Questions, Answered: CI, APIs, Installation, Backups, and Essential Plugins

This revised guide turns common Jenkins interview prompts into practical answers you can explain with confidence. It covers CI fundamentals, API usage, setup on Ubuntu and RHEL-like systems, backup strategy, and key plugins.

Read More

Git, GitHub, and GitLab Interview Questions: Practical Answers and Command Guide

A practical interview-prep guide covering core Git concepts, essential commands, and common GitHub/GitLab questions. Includes workflow diagrams, comparisons, and troubleshooting checklists.

Read More

Build and Release Engineer Interview Guide: Questions, Answer Frameworks, and Tool Comparisons

A practical, updated interview guide for Build, Release, and Configuration Engineering roles. Use it to prepare better answers or run more consistent technical interviews.

Read More
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
0
Would love your thoughts, please comment.x
()
x