Get Started (original) (raw)

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 Directory Structure

The default structure of the cookbooks directory is:

. chef-repo
└── cookbooks
    ├── README.md
    └── example
        ├── README.md
        ├── attributes
        │   ├── README.md
        │   └── default.rb
        ├── metadata.rb
        └── recipes
            ├── README.md
            └── default.rb

Cookbook Commands

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

Create

Chef Workstation generates the cookbooks directory as part of your Chef Infra repository, the chef-repo.

Generate a chef-repo/cookbooks directory with the command:

chef generate template PATH_TO_COOKBOOKS COOKBOOK_NAME

For example, this command generates a custom_web cookbook:

chef generate cookbook cookbooks/custom_web

The custom_web cookbook directory has the structure:

. cookbooks
└── custom_web
    ├── CHANGELOG.md
    ├── LICENSE
    ├── Policyfile.rb
    ├── README.md
    ├── chefignore
    ├── compliance
    │   ├── README.md
    │   ├── inputs
    │   ├── profiles
    │   └── waivers
    ├── kitchen.yml
    ├── metadata.rb
    ├── recipes
    │   └── default.rb
    └── test
        └── integration
            └── default
                └── default_test.rb

Any unneeded directory components can be left unused or deleted, if preferred.

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:

Download

To download a cookbook when git isn’t 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 namedCOOKBOOK_NAME.tar.gz in the current directory (~/chef-repo). Once downloaded, using a version source control system is recommended.

How can we improve this document?

Thank you for your feedback!