Setup ChefΒΆ

Create a directory to store the cookbook needed for this tutorial and change to that directory.

~$ mkdir cookbooks
~$ cd cookbooks

Create a subdirectory named .chef.

~/cookbooks$ mkdir .chef

Put your Chef credentials into the .chef subdirectory. Here is what that subdirectory contains after I stored my Chef credentials there.

~/cookbooks$ ls .chef
DCM-validator.pem   gforghetti.pem      knife.rb
~/cookbooks$ cat .chef/knife.rb
current_dir = File.dirname(__FILE__)
log_level                :info
log_location             STDOUT
node_name                "gforghetti"
client_key               "#{current_dir}/gforghetti.pem"
validation_client_name   "DCM-validator"
validation_key           "#{current_dir}/DCM-validator.pem"
chef_server_url          "https://api.opscode.com/organizations/gaf"
cache_type               'BasicFile'
cache_options( :path => "#{ENV['HOME']}/.chef/checksums" )
cookbook_path            ["#{current_dir}/../"]      

Test the Chef connection.

~/cookbooks$ knife environment list
_default

Download the tutorial Chef cookbook at this link Apache Chef cookbook into the cookbooks directory.

~/cookbooks$ ls -la apache_example.tar.gz
-rw-r--r--  1 gforghetti  staff  13690 Jan  5 17:09 apache_example.tar.gz

Run the following command to download the additional cookbooks required for this tutorial from the Chef Supermarket.

for package in apache2 apt build-essential chef_handler compat_resource mingw seven_zip windows; do knife cookbook site download $package; done
Downloading apache2 from Supermarket at version 3.1.0 to /Users/gforghetti/Cookbooks/apache2-3.1.0.tar.gz
Cookbook saved: /Users/gforghetti/Cookbooks/apache2-3.1.0.tar.gz
Downloading apt from Supermarket at version 4.0.0 to /Users/gforghetti/Cookbooks/apt-4.0.0.tar.gz
Cookbook saved: /Users/gforghetti/Cookbooks/apt-4.0.0.tar.gz
Downloading build-essential from Supermarket at version 6.0.0 to /Users/gforghetti/Cookbooks/build-essential-6.0.0.tar.gz
Cookbook saved: /Users/gforghetti/Cookbooks/build-essential-6.0.0.tar.gz
Downloading chef_handler from Supermarket at version 1.4.0 to /Users/gforghetti/Cookbooks/chef_handler-1.4.0.tar.gz
Cookbook saved: /Users/gforghetti/Cookbooks/chef_handler-1.4.0.tar.gz
Downloading compat_resource from Supermarket at version 12.10.5 to /Users/gforghetti/Cookbooks/compat_resource-12.10.5.tar.gz
Cookbook saved: /Users/gforghetti/Cookbooks/compat_resource-12.10.5.tar.gz
Downloading mingw from Supermarket at version 1.1.0 to /Users/gforghetti/Cookbooks/mingw-1.1.0.tar.gz
Cookbook saved: /Users/gforghetti/Cookbooks/mingw-1.1.0.tar.gz
Downloading seven_zip from Supermarket at version 2.0.1 to /Users/gforghetti/Cookbooks/seven_zip-2.0.1.tar.gz
Cookbook saved: /Users/gforghetti/Cookbooks/seven_zip-2.0.1.tar.gz
Downloading windows from Supermarket at version 1.43.0 to /Users/gforghetti/Cookbooks/windows-1.43.0.tar.gz
Cookbook saved: /Users/gforghetti/Cookbooks/windows-1.43.0.tar.gz

Run the following command to extract the cookbooks from their archive files.

for cookbook in `ls -1 *.tar.gz`; do tar -zxf $cookbook && echo "Chef cookbook ${cookbook} extracted."; done
Chef cookbook apache2-3.1.0.tar.gz extracted.
Chef cookbook apache_example.tar.gz extracted.
Chef cookbook apt-4.0.0.tar.gz extracted.
Chef cookbook build-essential-6.0.0.tar.gz extracted.
Chef cookbook chef_handler-1.4.0.tar.gz extracted.
Chef cookbook compat_resource-12.10.5.tar.gz extracted.
Chef cookbook mingw-1.1.0.tar.gz extracted.
Chef cookbook seven_zip-2.0.1.tar.gz extracted.
Chef cookbook windows-1.43.0.tar.gz extracted.

Run the following command to upload the cookbooks to your Chef server.

knife cookbook upload --all
Uploading Webserver      [0.1.0]
Uploading apache2      [3.1.0]
Uploading apt          [4.0.0]
Uploading build-essential [6.0.0]
Uploading chef_handler [1.4.0]
Uploading compat_resource [12.10.5]
Uploading mingw        [1.1.0]
Uploading seven_zip    [2.0.1]
Uploading windows      [1.43.0]
Uploaded all cookbooks.

Create the ACME-Webserver Chef role.

~/cookbooks$ knife role from file apache/roles/acme-webserver.rb
Updated Role ACME-Webserver!