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          ""
cache_type               'BasicFile'
cache_options( :path => "#{ENV['HOME']}/.chef/checksums" )
cookbook_path            ["#{current_dir}/../"]      

Test the Chef connection.

~/cookbooks$ knife environment list

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

~/cookbooks$ tar -zxvf apache_example.tar.gz
x Webserver/
x Webserver/attributes/
x Webserver/
x Webserver/files/
x Webserver/libraries/
x Webserver/metadata.rb
x Webserver/
x Webserver/recipes/
x Webserver/roles/
x Webserver/templates/
x Webserver/templates/default/
x Webserver/templates/default/index.html.erb
x Webserver/templates/default/vhost-2.2.conf.erb
x Webserver/templates/default/vhost-2.4.conf.erb
x Webserver/roles/acme-webserver.rb
x Webserver/roles/acme-windows-webserver.rb
x Webserver/recipes/default.rb
x Webserver/files/default/
x Webserver/files/default/acme_logo.jpg
x Webserver/attributes/default.rb

Upload the Webserver cookbook to the Chef server.

~/cookbooks$ knife cookbook upload Webserver
Uploading Webserver      [0.1.0]
Uploaded 1 cookbook.

Create the ACME-Windows-Webserver Chef role.

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