Skip to end of metadata
Go to start of metadata
You are viewing an old version of this page. View the current version. Compare with Current ·  View Page History

A cookbook is the fundamental unit of distribution in Chef. They are how you encapsulate all the different resources you need to automate your infrastructure, and they are the component that is easily sharable between different Chef users.

What's in a Cookbook

Cookbooks contain 6 different components:

Each of these components is a directory or file. An example cookbook directory after running the new_cookbook rake task:

Cookbook Contents

How do I create a new Cookbook?

See the Chef Repository page for details on creating a cookbook with rake. We encourage you to make your cookbooks useful to others by documenting them with a README.rdoc.

Where can I find some pre-made Cookbooks?

We are working on a site that will let you share Chef cookbooks, Capistrano scripts, Rake tasks, and anything else that is infrastructure-management related. For now, you might check out the Cookbooks created by Opscode.




Recipes created by Opscode


While people can fork this GitHub project and make their own changes, not everything gets merged back into the Opscode repository. If you're feeling adventurous, try the github network graph which shows these repositories at Some people may be interested in the use of Headless Branches for Cookbook Repositories.

Tell me more about Opscode's cookbooks

We provide a default set of cookbooks on GitHub for people to get started. The set is considered "feature complete". You can deploy a number of services without having to write a lot of cookbooks yourself. These cookbooks are used for installing Chef (we drink our koolaid!), and building a complete Rails application stack.

(by default if you're using the Chef Repository, the cookbooks directory will exist but has no cookbooks. You can safely delete it.)

If you would also like to contribute changes, or new features to our cookbooks, read more about setting up a git repository to do so.

How Do I Customize pre-made Cookbooks for my site?

That's pretty simple, actually! Create a site-cookbooks directory in Chef Repository. Make sure /etc/chef/server.rb cookbooks_path is correct:


Next, copy the entire contents of the cookbook you want to customize, go forth and customize it. When Chef runs, it will only use the cookbook from site-cookbooks, not the one in cookbooks. For example, say you have:

When Chef runs, it will cache /srv/chef/site-cookbooks/djbdns and apply that configuration.

Customizing Templates and Files

If you would like to customize just the files or templates used by a cookbook, you can create just those as well, copying them over from the upstream version and making your local changes. For example, you're deploying OpenLDAP and want to customize the slapd.conf and add your own certificates. Assuming you've followed along with the Chef Repository and have created the ldap certificate:

Make changes, update the repository and install the cookbooks, and when Chef runs, it will get the certificte and slapd.conf from the site-cookbooks, but otherwise use the rest of the openldap cookbook.

Other Site-specific Cookbooks

You can also use site-cookbooks for setting up other site-specific cookbooks


Then add "web_server" to recipes for the node in the webui, and it will apply the configuration. Prior to Chef 0.7.0, you might have a cookbook that merely includes several other recipes/cookbooks. Now you'll use Roles to define that.

  • None