Skip to main content

Get Started

[edit on GitHub]

The cookbooks/ directory of your Chef Infra repository is used to store the cookbooks that Chef Infra Client uses in configuring the various systems in the organization.

Chef Repository

The the \cookbook directory is automatically generated as part of your Chef Infra repository.

chef generate repo REPO_NAME

Cookbook Commands

Use the following commands to create a cookbook, install a cookbook from Supermarket, and/or download cookbooks.

Create

To create a cookbook (including all default components), run the following command:

chef generate cookbook COOKBOOK_NAME

where COOKBOOK_NAME is the name of the cookbook that will be created. Any unneeded directory components can be left unused or deleted, if preferred.

Cookbook Directory Structure

A cookbook generated withchef generate cookbook 4thcafe_web creates a cookbook named 4thcafe_web with the directory structure:

4thcafe_web
 ├ .delivery
 | └ project.toml
 ├ recipes
 | └ default.rb
 ├ test
 | └ integration
 | | └ default
 | | | └ default_test.rb
 ├ .gitignore
 ├ CHANGELOG.md
 ├ LICENSE
 ├ Policyfile.rb
 ├ README.md
 ├ chefignore
 ├ kitchen.yml
 └ metadata.rb

Install

To download a cookbook when git is used for version source control, run the following command:

knife supermarket install COOKBOOK_NAME

where COOKBOOK_NAME is the name of a cookbook on Chef Supermarket. This will start a process that:

  • downloads the cookbook from Chef Supermarket as a tar.gz archive
  • ensures that its using the git master branch, and then checks out the cookbook from a vendor branch (creating a new vendor branch, if required)
  • removes the old (existing) version
  • expands the tar.gz archive and adds the expanded files to the git index and commits
  • creates a tag for the version that was downloaded
  • checks out the master branch
  • merges the cookbook into the master (to ensure that any local changes or modifications are preserved)

Download

To download a cookbook when git is not used for version source control, run the following command:

knife supermarket download COOKBOOK_NAME

where COOKBOOK_NAME is the name of a cookbook on Chef Supermarket. This will download the tar.gz file associated with the cookbook and will create a file named COOKBOOK_NAME.tar.gz in the current directory (e.g., ~/chef-repo). Once downloaded, using a version source control system is recommended.

Was this page helpful?

×








Search Results