Installing Community Cookbooks in vanilla Chef
One of the big advantages of using Chef is the availability of a wide arrange of existing recipes. This page explains how to install cookbooks written and maintained by other people using vanilla Chef.
For Berkshelf; see here.
Installing an Opscode Community Cookbook
Installing a cookbook from the Opscode Community Cookbook site is simple:
- Identify the cookbook that you want to install. Go to the Opscode Community site and either search or browse the cookbook catalogue. Each cookbook include documentation describing what the cookbook's recipes (and other things) do, and how to use them. There are links to the cookbook's development site, and various other useful information such as platform dependencies, versions, user ratings, and download counts.
- Change directory to your "chef-repo"
Install the cookbook by running:
knife cookbook site install <cookbook-name>
This will do the following (copied from the "knife help"):
- A new "pristine copy" branch is created in git for tracking the upstream.
- All existing versions of a cookbook are removed from the branch.
- The cookbook is downloaded from https://cookbooks.opscode.com in the tar.gz format.
- The downloaded cookbook is untarred and its contents are committed to git and a tag is created.
- The "pristine copy" branch is merged into the master branch.
This process allows the upstream cookbook in the master branch to be modified while letting git maintain changes as a separate patch. When an updated upstream version becomes available, those changes can be merged while maintaining any local modifications.
- Push the newly installed cookbook to the relevant places. For example:
- Push the commits to your upstream Git repository.
- Transfer to the "/var/chef-solo" directories on Chef solo managed machines.
- Upload the cookbook to your Chef server.
- You can now add recipes from the newly installed cookbook to your node's run-lists, and so on.
Installing Cookbooks from Github
The "knife cookbook site" command only understands how to install cookbooks from the Community Cookbook site. To install them from other sites, you need to install the "knife-github-cookbooks" plugin from here. The procedure for installing a knife plugin is described here.
Once you have done that, you can use "knife" to install and maintain cookbooks from any Github repo; e.g.
knife cookbook github install cookbooks/yum