From 11c15deac723ed1e08f13dc687cbb3fdc5f0e523 Mon Sep 17 00:00:00 2001 From: jtimberman Date: Mon, 16 Aug 2010 18:18:20 -0600 Subject: [PATCH] Clarify / update documentation to be in line with new wiki page. --- README | 67 +++++++++++++++++++++++++++++++++++++--- certificates/README | 21 ++++++++++--- config/client.rb.example | 15 --------- config/knife.rb.example | 18 ----------- config/solo.rb.example | 12 ------- cookbooks/README | 44 ++++++++++++++++++++++++-- data_bags/README | 26 +++++++++------- roles/README | 7 ++--- site-cookbooks/README | 2 -- 9 files changed, 138 insertions(+), 74 deletions(-) delete mode 100644 config/client.rb.example delete mode 100644 config/knife.rb.example delete mode 100644 config/solo.rb.example delete mode 100644 site-cookbooks/README diff --git a/README b/README index cf84548..3a554a7 100644 --- a/README +++ b/README @@ -1,7 +1,64 @@ -This is a blank repository you can use as a starting point for your -local chef configuration. +Overview +======== -For full details on the parts aside from information contained in the -README files, see the Chef wiki documentation at: +Every 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. We strongly recommend storing this repository in a version control system such as Git and treat it like source code. -http://wiki.opscode.com/display/chef/Chef+Repository +While we prefer Git, and make this repository available via GitHub, you are welcome to download a tar or zip archive and use your favorite version control system to manage the code. + +Repository Directories +====================== + +This 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. + +* `certificates/` - SSL certificates generated by `rake ssl_cert` live here. +* `config/` - Contains the Rake configuration file, `rake.rb`. +* `cookbooks/` - Cookbooks you download or create. +* `data_bags/` - Store data bags and items in .json in the repository. +* `roles/` - Store roles in .rb or .json in the repository. + +Rake Tasks +========== + +The 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. + +* `bundle_cookbook[cookbook]` - Creates cookbook tarballs in the `pkgs/` dir. +* `install` - Calls `update`, `roles` and `upload_cookbooks` Rake tasks. +* `ssl_cert` - Create self-signed SSL certificates in `certificates/` dir. +* `update` - Update the repository from source control server, understands git and svn. + +The following tasks duplicate functionality from knife and may be removed in a future version of Chef. + +* `metadata` - replaced by `knife cookbook metadata -a`. +* `new_cookbook` - replaced by `knife cookbook create`. +* `role[role_name]` - replaced by `knife role from file`. +* `roles` - iterates over the roles and uploads with `knife role from file`. +* `test_cookbooks` - replaced by `knife cookbook test -a`. +* `test_cookbook[cookbook]` - replaced by `knife cookbook test COOKBOOK`. +* `upload_cookbooks` - replaced by `knife cookbook upload -a`. +* `upload_cookbook[cookbook]` - replaced by `knife cookbook upload COOKBOOK`. + +Configuration +============= + +The repository uses two configuration files. + +* config/rake.rb +* .chef/knife.rb + +The first, `config/rake.rb` configures the Rakefile in two sections. + +* Constants used in the `ssl_cert` task for creating the certificates. +* Constants that set the directory locations used in various tasks. + +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 you're using the Opscode Platform, you can download one 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 Steps +========== + +Read the README file in each of the subdirectories for more information about what goes in those directories. diff --git a/certificates/README b/certificates/README index 27d9a16..c6856e6 100644 --- a/certificates/README +++ b/certificates/README @@ -1,6 +1,19 @@ -Creating 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. To generate a -certificate set for a new monitoring server, for example: +Creating 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: rake ssl_cert FQDN=monitoring.example.com + +Once the certificates are generated, copy them into the cookbook(s) where you want to use them. + + cp certificates/monitoring.example.com.* cookbooks/COOKBOOK/files/default + +In the recipe for that cookbook, create a `cookbook_file` resource to configure a resource that puts them in place on the destination server. + + cookbook_file '/etc/apache2/ssl/monitoring.example.com.pem' + owner 'root' + group 'root' + mode 0600 + end diff --git a/config/client.rb.example b/config/client.rb.example deleted file mode 100644 index f023566..0000000 --- a/config/client.rb.example +++ /dev/null @@ -1,15 +0,0 @@ -# -# Example Chef Client Config File -# -# You can generate the client.rb with correct settings with knife: -# -# knife configure client ./config - -log_level :info -log_location STDOUT -ssl_verify_mode :verify_none -chef_server_url "https://api.opscode.com/organizations/ORGNAME" - -client_key "/etc/chef/client.pem" - -validation_client_name "ORGNAME-validator" diff --git a/config/knife.rb.example b/config/knife.rb.example deleted file mode 100644 index b742fa4..0000000 --- a/config/knife.rb.example +++ /dev/null @@ -1,18 +0,0 @@ -# This file is provided as an example when using the Opscode Platform -# as the Chef Server. You were prompted to download a config file -# when you signed up for the Opscode Platform that looks like this. -# -# Replace USERNAME with your Opscode username and ORGNAME -# with your Opscode Platform organization name. -# -current_dir = File.dirname(__FILE__) -log_level :info -log_location STDOUT -node_name "USERNAME" -client_key "#{current_dir}/USERNAME.pem" -validation_client_name "ORGANIZATION-validator" -validation_key "#{current_dir}/ORGANIZATION-validator.pem" -chef_server_url "https://api.opscode.com/organizations/ORGANIZATION" -cache_type 'BasicFile' -cache_options( :path => "#{ENV['HOME']}/.chef/checksums" ) -cookbook_path ["#{current_dir}/../cookbooks"] diff --git a/config/solo.rb.example b/config/solo.rb.example deleted file mode 100644 index 3654685..0000000 --- a/config/solo.rb.example +++ /dev/null @@ -1,12 +0,0 @@ -# -# Chef Solo Config File -# -# This file is provided as an example of /etc/chef/solo.rb. - -log_level :info -log_location STDOUT -file_cache_path "/var/chef/cookbooks" - -# Optionally store your JSON data file and a tarball of cookbooks remotely. -#json_attribs "http://chef.example.com/dna.json" -#recipe_url "http://chef.example.com/cookbooks.tar.gz" diff --git a/cookbooks/README b/cookbooks/README index 2dcf2fd..63370ed 100644 --- a/cookbooks/README +++ b/cookbooks/README @@ -1,2 +1,42 @@ -Download cookbooks into this directory from the Opscode Cookbooks site -using knife, or remove this file to clone an upstream Git Repository. +This 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. Add the following lines to `~/chef-repo/.chef/knife.rb`. + + cookbook_copyright "Example, Com." + cookbook_email "cookbooks@example.com" + cookbook_license "apachev2" + +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. + + knife cookbook create COOKBOOK + +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 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 is automatically handled with Knife. + + knife cookbook site vendor COOKBOOK + +This will: + +* Download the cookbook tarball from cookbooks.opscode.com. +* Ensure its on the git master branch. +* Checks for an existing vendor branch, and creates if it doesn't. +* Checks out the vendor branch (chef-vendor-COOKBOOK). +* Removes the existing (old) version. +* Untars the cookbook tarball it downloaded in the first step. +* Adds the cookbook files to the git index and commits. +* Creates a tag for the version downloaded. +* Checks out the master branch again. +* Merges the cookbook into master. + +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. + + knife cookbook site download COOKBOOK + +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. diff --git a/data_bags/README b/data_bags/README index 0b75620..7a02046 100644 --- a/data_bags/README +++ b/data_bags/README @@ -1,21 +1,23 @@ -First, create the data bag. Name it whatever you want. +This 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. - knife data bag create BAG +First, create a directory for the data bag. + + mkdir data_bags/BAG -Next, create data bag JSON files in subdirectories by data bag name. Then -upload the items to the Chef Server with knife: +Then create the JSON files for items that will go into that bag. - knife data bag from file BAG FILE + $EDITOR data_bags/BAG/ITEM.json -For example, create a bag named 'apps' with an item named 'instiki': +The JSON for the ITEM must contain a key named "id" with a value equal to "ITEM". For example, - mkdir data_bags/apps - echo '{ "id": "instiki" }' > data_bags/apps/instiki.json + { + "id": "foo" + } -Then upload it to the server: +Next, create the data bag on the Chef Server. - knife data bag from file apps instiki.json + knife data bag create BAG -For more information about data bags, see the Chef wiki. +Then upload the items in the data bag's directory to the Chef Server. -http://wiki.opscode.com/display/chef/Data+Bags + knife data bag from file BAG ITEM.json diff --git a/roles/README b/roles/README index 3eed6cc..b0ee0b4 100644 --- a/roles/README +++ b/roles/README @@ -1,14 +1,13 @@ -Create roles here, in either .rb or .json files. To install roles on the -server, use knife. For example, create roles/base_example.rb: +Create 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`: name "base_example" description "Example base role applied to all nodes." # List of recipes and roles to apply. Requires Chef 0.8, earlier versions use 'recipes()'. #run_list() - # Attributes applied if the node doesn't have it set already. #default_attributes() - # Attributes applied no matter what the node has set already. #override_attributes() diff --git a/site-cookbooks/README b/site-cookbooks/README deleted file mode 100644 index 5163db2..0000000 --- a/site-cookbooks/README +++ /dev/null @@ -1,2 +0,0 @@ -This directory contains cookbooks that modify upstream ones in cookbooks/, -or that are specific to your site.