Chef DevOps Chef DevOps Version Control & Pipeline Management 1 — Questions and Answers
Question 1: What is Berkshelf used for in Chef cookbook development?
- Running integration tests
- Managing and resolving cookbook dependencies (Correct answer)
- Bootstrapping nodes
- Encrypting data bags
Correct answer: Managing and resolving cookbook dependencies
Berkshelf is Chef's cookbook dependency manager that resolves, downloads, and caches required cookbooks and their transitive dependencies.
Question 2: Where are cookbook dependencies declared when using Berkshelf?
- Policyfile.rb
- metadata.rb
- Berksfile (Correct answer)
- Cheffile
Correct answer: Berksfile
The `Berksfile` is where you declare cookbook sources and dependencies that Berkshelf reads to resolve and fetch the correct versions.
Question 3: What does `berks install` do when run in a cookbook directory?
- Installs Berkshelf itself
- Downloads and caches all declared cookbook dependencies locally (Correct answer)
- Uploads cookbooks to Chef Server
- Creates a new cookbook skeleton
Correct answer: Downloads and caches all declared cookbook dependencies locally
`berks install` reads the Berksfile, resolves dependency versions, and downloads them to the local Berkshelf cache (~/.berkshelf).
Question 4: In Chef semantic versioning (e.g., 1.2.3), what does incrementing the first number signify?
- A patch fix with no API changes
- A backward-compatible new feature
- A breaking or incompatible change (Correct answer)
- A build metadata update
Correct answer: A breaking or incompatible change
In semantic versioning, the first (major) version number is incremented when introducing breaking or backward-incompatible changes.
Question 5: What is a Chef Policyfile used for?
- A compliance policy document for auditors
- Pinning specific cookbook versions and run lists to a named policy for nodes (Correct answer)
- A network firewall policy configuration
- A security key management file
Correct answer: Pinning specific cookbook versions and run lists to a named policy for nodes
A Policyfile pins exact cookbook versions and a run list into a named, versioned policy that is applied consistently to targeted nodes.
Question 6: Which command compiles and uploads a Policyfile and its cookbooks to the Chef Server?
- knife policy upload
- chef push (Correct answer)
- berks upload
- knife upload policy
Correct answer: chef push
The `chef push` command compiles the Policyfile, resolves cookbook versions, and pushes the policy archive to a policy group on the Chef Server.
What is Berkshelf used for in Chef cookbook development?