A cookbook is the fundamental unit of work 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 5 different components:
How do I create a new Cookbook
Where can I find some pre-made Cookbooks?
We're working on a solution to this (a site that will let you share not only your Chef cookbooks, but your Puppet recipes, Capistrano scripts, and anything else that's infrastructure management related). For now, you can check out these places:
Recipes created by Opscode
Read more about the Opscode Cookbooks.
Sometimes, people will fork the opscode repository to add their own cookbooks but these changes don't always get pulled immediately back into the opscode repository. If you're feeling adventurous, try the github network graph which shows these repositories at http://github.com/opscode/cookbooks/network .
How Do I Customize pre-made Cookbooks for my site?
That's pretty simple, actually! Create a site-cookbooks directory in Your 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.
You can also use
site-cookbooks for setting up other site-specific cookbooks, such as a set of web server recipes. For example,
Then add "web_server" to
recipes for the node in the webui, and it will apply the configuration.