Chef DevOps Chef DevOps Version Control & Pipeline Management 2 — Questions and Answers
Question 1: What is the primary purpose of a `metadata.rb` file in a Chef cookbook?
- Storing encrypted secrets for the cookbook
- Defining the cookbook's name, version, author, and dependencies (Correct answer)
- Running the cookbook's test suites
- Configuring knife connection settings
Correct answer: Defining the cookbook's name, version, author, and dependencies
The `metadata.rb` file declares essential cookbook information including its name, version, author, license, dependencies, and supported platforms.
Question 2: In a CI/CD pipeline for Chef cookbooks, which stage typically runs first?
- Deploy cookbook to production nodes
- Upload cookbook to Chef Server
- Lint checks and ChefSpec unit tests (Correct answer)
- Test Kitchen integration tests
Correct answer: Lint checks and ChefSpec unit tests
Linting (Cookstyle) and unit tests (ChefSpec) run first in a Chef CI pipeline because they are fast, cheap, and catch most issues before spinning up real instances.
Question 3: What does `berks upload` do after dependencies have been installed locally?
- Installs cookbook dependencies to the local cache
- Uploads all resolved cookbooks from the local cache to Chef Server (Correct answer)
- Runs Berkshelf integration tests
- Creates a Berksfile.lock file
Correct answer: Uploads all resolved cookbooks from the local cache to Chef Server
`berks upload` takes the locally cached cookbooks resolved by Berkshelf and uploads them and their dependencies to the Chef Server.
Question 4: What is the purpose of the `Berksfile.lock` file in a cookbook repository?
- Locking the Chef Server API connection
- Recording exact resolved cookbook versions to ensure reproducible dependency installs (Correct answer)
- Encrypting data bag secret keys
- Blocking unauthorized cookbook uploads
Correct answer: Recording exact resolved cookbook versions to ensure reproducible dependency installs
The `Berksfile.lock` records the exact resolved versions of all cookbook dependencies, ensuring every developer and CI run uses identical versions.
Question 5: What Chef community tool automates cookbook version bumping, Git tagging, and Supermarket publishing?
- knife
- chef
- stove (Correct answer)
- berkshelf
Correct answer: stove
Stove is the Chef cookbook release tool that automates bumping the version in metadata.rb, creating a Git tag, and publishing to the Chef Supermarket.
Question 6: What does `knife cookbook upload` do on a Chef workstation?
- Downloads cookbooks from Supermarket to the workstation
- Uploads a specific cookbook from the workstation to the Chef Server (Correct answer)
- Tests cookbook syntax locally
- Creates a new cookbook skeleton with default files
Correct answer: Uploads a specific cookbook from the workstation to the Chef Server
`knife cookbook upload` takes a cookbook from the local workstation cookbook path and uploads it to the Chef Server for use by nodes.
What is the primary purpose of a `metadata.rb` file in a Chef cookbook?