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.
\cookbook directory is automatically generated as part of your Chef Infra repository.
chef generate repo REPO_NAME
Cookbook Directory Structure
The default structure of the cookbooks directory is:
. chef-repo - cookbooks - example - attributes - default.rb - recipes - default.rb - metadata.rb - README.rb
Use the following commands to create a cookbook, install a cookbook from Supermarket, and/or download cookbooks.
Chef Workstation generates the
cookbooks directory as part of your Chef Infra repository, the
chef-repo/cookbooks directory with the command:
chef generate template PATH_TO_COOKBOOKS COOKBOOK_NAME
For example, this command generates a
chef generate cookbook cookbooks/custom_web
custom_web cookbook directory has the structure:
. cookbooks - custom_web - recipes - default.rb - test - integration - default - default_test.rb - .gitignore - CHANGELOG.md - chefignore - kitchen.yml - LICENSE - metadata.rb - Policyfile.rb - README.md
Any unneeded directory components can be left unused or deleted, if preferred.
To download a cookbook when git is used for version source control, run the following command:
knife supermarket install COOKBOOK_NAME
COOKBOOK_NAME is the name of a cookbook on ChefSupermarket. This will start a process
- downloads the cookbook from ChefSupermarket 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)
To download a cookbook when git is not used for version source control, run the following command:
knife supermarket download COOKBOOK_NAME
COOKBOOK_NAME is the name of a cookbook on ChefSupermarket. 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 (
Once downloaded, using a version source control system is recommended.
Was this page helpful?