|
OverviewEvery Chef installation needs a Chef Repository. This is the place where cookbooks, roles, config files and other artifacts for managing systems with Chef will live.
|
|
Getting the chef-repoTo create your own repository, start by cloning Opscode's chef-repo from GitHub. If you don't want to install Git, you can download a tarball. Cloning Opscode's Chef Repo from GitHubGit Clone chef-repo If you want to wipe out the existing history and start fresh, feel free to remove the .git directory after you clone. Then you can initialize a new git repository, or create a subversion (or mercurial, or bazaar) repository. If you don't want Git...You can grab the tarball directly off GitHub: Grab Tarball of Chef Repo You'll need to extract the tarball, and move the directory it creates (by default, username-project-commit/) to chef-repo. The commit ID may be different than this. Extract Tarball We still strongly recommend you use some kind of version control tool to manage the source code in your chef-repo, so use your favorite tool to initialize the repository for tracking. If you do use Git, there is more info on Working with Git and Cookbooks. Repository DirectoriesThis repository contains several directories, and each directory contains a README file that describes what it is for in greater detail, and how to use it for managing your systems with Chef.
configContains the Rake config file. See Configuration below. cookbooksThis directory contains the cookbooks used to configure systems in your infrastructure with Chef. Configure knife to use your preferred copyright holder, email contact and license by adding the following lines to ~/chef-repo/.chef/knife.rb: Supported values for cookbook_license are "apachev2" or "none". These settings are used to prefill comments in the default recipe, and the corresponding values in the metadata.rb. You are free to change these in those files. Create new cookbooks in this directory with Knife. This will create all the cookbook directory components. You don't need to use them all, and can delete the ones you don't need. It also creates a README file, metadata.rb and default recipe. You can also download cookbooks directly from the Opscode Community Cookbook Site. There are two subcommands to help with this depending on what your preference is. The first and recommended method is to use a vendor branch if you're using Git, this step is automatically handled with Knife. This will:
The last step will ensure that any local changes or modifications you have made to the cookbook are preserved, so you can keep your changes through upstream updates. If you're not using Git, use the site download subcommand to download the tarball. This creates the COOKBOOK.tar.gz from in the current directory (e.g., ~/chef-repo). We recommend following a workflow similar to the above for your version control tool. data_bagsThis directory contains directories of the various data bags you create for your infrastructure. Each subdirectory corresponds to a data bag on the Chef Server, and contains JSON files of the items that go in the bag. First, create a directory for the data bag. Then create the JSON files for items that will go into that bag. The JSON for the ITEM must contain a key named "id" with a value equal to "ITEM". For example, Next, create the data bag on the Chef Server. Then upload the items in the data bag's directory to the Chef Server. rolesCreate roles here, in either the Role Ruby DSL (.rb) or JSON (.json) files. To install roles on the server, use knife. For example, create roles/base_example.rb: Then upload it to the Chef Server: certificatesCreating SSL certificates is a common task done in web application infrastructures, so a rake task is provided to generate certificates. These certificates are stored here by the ssl_cert task. Configure the values used in the SSL certificate by modifying config/rake.rb. To generate a certificate set for a new monitoring server, for example: Once the certificates are generated, copy them into the cookbook(s) where you want to use them. In the recipe for that cookbook, create a cookbook_file resource to configure a resource that puts them in place on the destination server. Rake TasksThe repository contains a Rakefile that includes tasks that are installed with the Chef libraries. To view the tasks available with in the repository with a brief description, run rake -T. The default task (default) is run when executing rake with no arguments. It will call the task test_cookbooks. The following tasks are not directly replaced by knife sub-commands:
The following tasks duplicate functionality from knife and may be removed in a future version of Chef:
ConfigurationThe repository uses two configuration files.
The first, config/rake.rb configures the Rakefile in two sections.
If you use the ssl_cert task, change the values in the config/rake.rb file appropriately. These values were also used in the new_cookbook task, but that task is replaced by the knife cookbook create command which can be configured below. The second config file, .chef/knife.rb is a repository specific configuration file for knife. If it exists, it will override your primary knife configuration file (in ~/.chef/knife.rb). You do not need to have a knife.rb in your chef-repo if your primary knife configuration file is correct. If you're using the Opscode Platform, you can download a knife configuration for your organization from the management console. If you're using the Open Source Chef Server, you can generate a new one with knife configure. For more information about configuring Knife, see the Knife documentation. Next StepsLearn more about Chef Basics or get started on working with Cookbooks at the Cookbook Fast Start Guide. If you did proceed with Git, we have a guide on Working with Git and Cookbooks that you may want to review.
|
|
|

