45 Most Asked Chef Infra Interview Questions (2027)
45 most asked Chef Infra interview questions for freshers and experienced engineers: resources, client run, attributes, Policyfiles, testing.
The most asked Chef interview questions cover Chef Infra basics (resources, recipes, cookbooks, the Chef Infra Server and client run), then attributes, Policyfiles, testing with Test Kitchen and InSpec, and for senior roles, scaling, compliance and migration decisions. This guide has 45 of those questions for freshers and experienced engineers, with direct answers and scenarios.
This page is about Chef the configuration management tool, now part of Progress Software. Progress completed its acquisition of Chef Software in October 2020, and chef.io describes Chef as part of the Progress product portfolio, with the Chef 360 platform alongside the long-standing tools: Chef Infra Client and Server, Chef InSpec, Chef Habitat, Chef Automate and Chef Workstation. The Chef docs listed Chef Infra Client 19 as the newest version when this guide was checked in November 2026. For the wider field, see our configuration management tools comparison.
Key takeaways
- Chef Infra uses Ruby-based recipes made of resources. Each resource declares a desired state, and the client changes the node only when it differs.
- A Chef Infra Client run gathers node data with Ohai, synchronises cookbooks, compiles recipes into a resource collection, then converges.
- Attribute precedence runs default, force_default, normal, override, force_override, automatic, with automatic (Ohai data) highest.
- Policyfiles lock cookbook versions in
Policyfile.lock.jsonand are the recommended replacement for roles and environments. - Expect testing questions: Cookstyle for linting, ChefSpec for unit tests, Test Kitchen with InSpec for integration tests.
Chef components at a glance
| Component | What it does |
|---|---|
| Chef Workstation | Developer toolkit: Chef CLI, knife, Chef Infra Client, Chef InSpec, Test Kitchen (listed as Chef Test Kitchen Enterprise), Cookstyle, Berkshelf, Chef Vault, Ohai, Fauxhai |
| Chef Infra Server | Central store for cookbooks, policies, node data, roles, environments and data bags |
| Chef Infra Client | Agent on each node that pulls its configuration and converges the system |
| Chef InSpec | Compliance and test language for checking system state |
| Chef Habitat | Application packaging and runtime automation |
| Chef Automate | Dashboards for infrastructure and compliance data |
| Chef 360 | Progress's newer platform that groups Chef management products (see chef.io for current editions) |
Freshers: Chef Infra basics
1. What is Chef Infra?
Chef Infra is a configuration management tool that defines server configuration as code. You write recipes in a Ruby DSL, and Chef Infra Client applies them to nodes so each node reaches the declared state.
2. What is a resource?
A resource is a single piece of configuration with a desired state, such as a package installed, a service running or a file with certain content. Examples: package, service, template, file, user, directory, execute.
3. What is a recipe?
A recipe is a Ruby file containing resources in the order they should be applied. Recipes live in cookbooks.
4. What is a cookbook?
A cookbook is the unit of distribution in Chef. It holds recipes, attributes, templates, files, custom resources, tests and a metadata.rb with its name, version and dependencies.
5. What is a node?
Any machine managed by Chef: a physical server, VM, cloud instance or container. Each node has a run-list or a policy that says what to apply.
6. What does idempotent mean in Chef?
Running the same recipe many times leaves the system in the same state, and resources only take action when the current state differs. An execute resource is not idempotent by itself, so it needs guards.
7. What are guards?
not_if and only_if properties that run a check before a resource acts. For example, run a database init command only if a marker file does not exist.
8. What is Ohai?
Ohai collects system data such as platform, IP addresses, memory and CPU at the start of each run. This data becomes automatic attributes, which have the highest precedence.
9. What is a run-list?
An ordered list of recipes and roles that a node should apply. With Policyfiles, the run-list is defined in the policy instead of on the node.
10. What is knife?
knife is the command-line tool for working with Chef Infra Server: uploading cookbooks, bootstrapping nodes, editing node data and managing data bags.
11. What does knife bootstrap do?
It connects to a machine over SSH or WinRM, installs Chef Infra Client and registers the node with Chef Infra Server, optionally with a policy or run-list.
12. What is a template resource?
It renders an ERB template from the cookbook with variables (often attributes) and writes it to a file on the node, for example an Nginx configuration.
13. What is a data bag?
A global JSON store on Chef Infra Server for data that is not tied to one node, such as user lists. Secrets should be stored as encrypted data bags or with Chef Vault.
14. What is Chef Supermarket?
The community site for sharing cookbooks. Many companies also run a private Supermarket for internal cookbooks.
15. How do you run Chef without a server?
Run Chef Infra Client in local mode (chef-client -z), which uses a local in-memory server, or use the Agentless Mode described in the Chef Infra Client 19 docs, which runs over SSH without installing the client on the target.
2 to 5 years: attributes, policies and testing
16. Describe the steps of a Chef Infra Client run.
Load configuration, run Ohai to build the node object, authenticate to Chef Infra Server, get the node's policy or run-list, synchronise cookbooks, compile all recipes into a resource collection (the compile phase), converge each resource (the converge phase), then save the node and run handlers.
17. Why does the compile and converge split matter?
Ruby code in a recipe runs at compile time, while resources act at converge time. Reading a file in plain Ruby before a resource creates it fails. The fix is lazy evaluation (lazy), a ruby_block, or unified mode in custom resources.
18. What is unified mode?
Unified mode, used in custom resources, combines the compile and converge stages into one phase so code runs in the order it is written. It removes many surprises with ordering.
19. Explain attribute precedence.
From lowest to highest: default, force_default, normal, override, force_override, automatic. Default and override reset each run; normal persists on the node object. Automatic attributes from Ohai always win.
20. Why avoid normal attributes?
They persist on the node between runs, so a value set once stays even after you remove it from code. That causes drift that is hard to trace.
21. What are notifications?
notifies and subscribes let one resource trigger another, for example restart a service when its template changes. Timing can be :delayed (default, at the end of the run), :immediately or :before.
22. What is a Policyfile?
A Policyfile.rb declares a policy name, run-list, cookbook sources and attributes. chef install resolves dependencies and writes Policyfile.lock.json with exact versions and content hashes, so every node in the group gets the same cookbooks.
23. Which Policyfile commands should you know?
chef install Policyfile.rb
chef update Policyfile.rb
chef push staging Policyfile.rb
chef push uploads the locked policy and its cookbooks to Chef Infra Server for the named policy group.
24. What is a policy group?
A set of nodes that share the same locked policy, such as dev, staging or prod. Nodes set policy_name and policy_group in client.rb or through knife node policy set.
25. Policyfiles versus roles and environments?
The Chef docs say Policyfiles effectively replace roles and environments. Roles and environments are still documented, but they do not lock cookbook versions per node group, which leads to "works in staging, breaks in prod" surprises. Policyfiles promote one tested lock file.
26. What is Berkshelf for?
Berkshelf manages cookbook dependencies in a Berksfile. With Policyfiles, dependency resolution is built into chef install, so new projects often do not need Berkshelf.
27. How do you test cookbooks?
Cookstyle for style and common mistakes, ChefSpec for fast unit tests of the resource collection, and Test Kitchen to converge the cookbook on real instances, then verify them with InSpec tests.
28. What is the Test Kitchen workflow?
kitchen create
kitchen converge
kitchen verify
kitchen destroy
# or all at once
kitchen test
The kitchen.yml file defines the driver (for example Vagrant, Docker or a cloud), the platforms and the suites.
29. What is an InSpec control?
A named test block with an impact score and checks against resources such as package, service, port or file. Controls are grouped into profiles.
30. What is the Compliance Phase?
A feature of Chef Infra Client that runs Chef InSpec profiles during every client run, so configuration and compliance checks happen together.
31. How do you write a custom resource?
Create a file under resources/ with properties and actions, using built-in resources inside the actions. Custom resources replace repeated recipe code and the older LWRP and definition patterns.
32. How do you handle secrets in Chef?
Use encrypted data bags, Chef Vault (which encrypts the data bag key for specific nodes and admins), or fetch secrets at runtime from an external manager such as HashiCorp Vault. Never commit plain secrets to a cookbook.
Senior: scale, compliance and strategy
33. How do you design a cookbook structure for many teams?
Separate library cookbooks (reusable custom resources, versioned and tested) from wrapper or role cookbooks that set attributes for one application. Use Policyfiles per application and policy groups per environment.
34. How do you promote a change from dev to prod?
Update the cookbook, run tests in CI, run chef update, push the lock to the dev policy group, then push the same lock file to staging and prod. The same lock file guarantees the same cookbook content.
35. How do you keep Chef runs safe on thousands of nodes?
Run the client as a service or scheduled task with a splay so runs do not all start together, roll out by policy group, watch run failures in Chef Automate or your log platform, and keep a quick rollback by pushing the previous lock file.
36. What is why-run mode?
Why-run mode does everything up to the point where configuration would change and reports what would have changed. It is useful for reviews, though results can be inaccurate when later resources depend on earlier changes.
37. How does Chef compare with Ansible?
Chef uses a pull model with an agent and Ruby DSL, which suits large fleets that converge on a schedule. Ansible is agentless, push-based and uses YAML, which many teams find easier to start with. Our Ansible interview questions cover the other side.
38. How do you integrate Chef with CI/CD?
Run Cookstyle and ChefSpec on each pull request, Test Kitchen on merge, then chef push to a policy group from the pipeline. Our CI/CD pipeline examples show similar promotion stages.
39. When would you move away from Chef?
When the workload has moved to containers and immutable images, configuration management on long-lived servers matters less. Many teams keep Chef for base OS hardening and compliance while application config moves into images and Kubernetes manifests. Give reasons tied to your environment rather than a general opinion.
40. How do you check Chef product status before recommending it?
Read chef.io and docs.chef.io for current product names, supported versions and licensing terms. Progress has changed packaging and licensing since the acquisition, so check those pages rather than relying on older blog posts.
Scenarios
41. A service restarts on every Chef run.
A resource is reporting a change each run, often a template whose content changes (timestamps, unordered hashes) or an execute without a guard. Find it in the run output, make it idempotent, and the notification will stop firing.
42. A node gets an old cookbook version.
Check which policy group the node is in and which lock file is pushed there. With roles and environments, check environment version constraints.
43. A recipe fails because a file it reads does not exist yet.
The read happens at compile time. Use lazy for the property, move the logic into a ruby_block, or use unified mode in a custom resource.
44. Chef runs time out on some nodes.
Check network access to Chef Infra Server, slow package mirrors and long execute commands. Add timeouts to resources that call external systems.
45. An attribute set in a role is ignored.
A higher precedence level is setting it, such as a cookbook override, a persisted normal attribute, or Ohai automatic data. Inspect the node with knife node show and trace where the value comes from.
How to prepare for a Chef interview
- Install Chef Workstation, generate a cookbook with
chef generate cookbook, and build an Nginx cookbook with a template and a service notification. - Write a Policyfile, run
chef install, and read the lock file so you can explain it. - Add a ChefSpec test and a Test Kitchen suite with one InSpec control.
- Prepare one story about drift or a failed run you fixed.
Chef appears alongside Ansible and Terraform in many job descriptions. Our Ansible training and DevOps training cover configuration management and CI/CD, in a classroom in Kharadi, Pune and live online across India. For other DevOps topics, start from the DevOps interview questions hub, or compare with infrastructure as code tools.
FAQ
Is Chef still used in 2027?
Yes. Progress continues to develop Chef, the docs list Chef Infra Client 19, and many organisations still run Chef on server fleets. Check job descriptions in your target market to judge demand.
Who owns Chef now?
Progress Software, which completed its acquisition of Chef Software in October 2020.
What is the most asked Chef interview question?
Explaining resources, recipes and cookbooks, followed by the compile and converge phases of a Chef Infra Client run.
Should I learn Policyfiles or roles and environments?
Learn Policyfiles first, since the docs recommend them, but understand roles and environments because older estates still use them.
Do I need Ruby for Chef?
Basic Ruby helps: variables, hashes, arrays, blocks and conditionals. Recipes are a Ruby DSL.
What is the difference between Chef Infra and Chef InSpec?
Chef Infra changes systems to a desired state. Chef InSpec checks systems against tests and compliance rules without changing them.
References
What's Your Reaction?
Like
0
Dislike
0
Love
0
Funny
0
Angry
0
Sad
0
Wow
0