Setup ChefΒΆ

Create a directory to store the cookbooks needed for this tutorial and change to 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 WordPress Chef custom cookbooks (two) at this link WordPress Chef cookbook into the cookbooks directory.

~/cookbooks$ ls -la wordpress_example.tar.gz
-rw-r--r--  1 gforghetti  staff  36418 Jul 10 10:24 wordpress_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-client chef-sugar chef_handler compat_resource iis mingw 'mysql 7.2.0' php rbac seven_zip smf windows xml yum yum-epel yum-mysql-community ; do knife cookbook site download $package; done
Downloading apache2 from Supermarket at version 3.2.2 to /Users/gforghetti/Cookbooks/apache2-3.2.2.tar.gz
Cookbook saved: /Users/gforghetti/Cookbooks/apache2-3.2.2.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-client from Supermarket at version 4.6.0 to /Users/gforghetti/Cookbooks/chef-client-4.6.0.tar.gz
Cookbook saved: /Users/gforghetti/Cookbooks/chef-client-4.6.0.tar.gz
Downloading chef-sugar from Supermarket at version 3.3.0 to /Users/gforghetti/Cookbooks/chef-sugar-3.3.0.tar.gz
Cookbook saved: /Users/gforghetti/Cookbooks/chef-sugar-3.3.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.6 to /Users/gforghetti/Cookbooks/compat_resource-12.10.6.tar.gz
Cookbook saved: /Users/gforghetti/Cookbooks/compat_resource-12.10.6.tar.gz
Downloading iis from Supermarket at version 4.1.7 to /Users/gforghetti/Cookbooks/iis-4.1.7.tar.gz
Cookbook saved: /Users/gforghetti/Cookbooks/iis-4.1.7.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 mysql from Supermarket at version 7.2.0 to /Users/gforghetti/Cookbooks/mysql-7.2.0.tar.gz
Cookbook saved: /Users/gforghetti/Cookbooks/mysql-7.2.0.tar.gz
Downloading php from Supermarket at version 1.9.0 to /Users/gforghetti/Cookbooks/php-1.9.0.tar.gz
Cookbook saved: /Users/gforghetti/Cookbooks/php-1.9.0.tar.gz
Downloading rbac from Supermarket at version 1.0.3 to /Users/gforghetti/Cookbooks/rbac-1.0.3.tar.gz
Cookbook saved: /Users/gforghetti/Cookbooks/rbac-1.0.3.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 smf from Supermarket at version 2.2.8 to /Users/gforghetti/Cookbooks/smf-2.2.8.tar.gz
Cookbook saved: /Users/gforghetti/Cookbooks/smf-2.2.8.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
Downloading xml from Supermarket at version 2.0.0 to /Users/gforghetti/Cookbooks/xml-2.0.0.tar.gz
Cookbook saved: /Users/gforghetti/Cookbooks/xml-2.0.0.tar.gz
Downloading yum from Supermarket at version 3.11.0 to /Users/gforghetti/Cookbooks/yum-3.11.0.tar.gz
Cookbook saved: /Users/gforghetti/Cookbooks/yum-3.11.0.tar.gz
Downloading yum-epel from Supermarket at version 0.7.0 to /Users/gforghetti/Cookbooks/yum-epel-0.7.0.tar.gz
Cookbook saved: /Users/gforghetti/Cookbooks/yum-epel-0.7.0.tar.gz
Downloading yum-mysql-community from Supermarket at version 0.2.0 to /Users/gforghetti/Cookbooks/yum-mysql-community-0.2.0.tar.gz
Cookbook saved: /Users/gforghetti/Cookbooks/yum-mysql-community-0.2.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.2.2.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-client-4.6.0.tar.gz extracted.
Chef cookbook chef-sugar-3.3.0.tar.gz extracted.
Chef cookbook chef_handler-1.4.0.tar.gz extracted.
Chef cookbook compat_resource-12.10.6.tar.gz extracted.
Chef cookbook iis-4.1.7.tar.gz extracted.
Chef cookbook mingw-1.1.0.tar.gz extracted.
Chef cookbook mysql-7.2.0.tar.gz extracted.
Chef cookbook php-1.9.0.tar.gz extracted.
Chef cookbook rbac-1.0.3.tar.gz extracted.
Chef cookbook seven_zip-2.0.1.tar.gz extracted.
Chef cookbook smf-2.2.8.tar.gz extracted.
Chef cookbook windows-1.43.0.tar.gz extracted.
Chef cookbook wordpress_example.tar.gz extracted.
Chef cookbook xml-2.0.0.tar.gz extracted.
Chef cookbook yum-3.11.0.tar.gz extracted.
Chef cookbook yum-epel-0.7.0.tar.gz extracted.
Chef cookbook yum-mysql-community-0.2.0.tar.gz extracted.

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

knife cookbook upload --all
Uploading apache2      [3.2.2]
Uploading apt          [4.0.0]
Uploading build-essential [6.0.0]
Uploading chef-client  [4.6.0]
Uploading chef-sugar   [3.3.0]
Uploading chef_handler [1.4.0]
Uploading compat_resource [12.10.6]
Uploading iis          [4.1.7]
Uploading mingw        [1.1.0]
Uploading mtd-db-wordpress [0.1.0]
Uploading mtd-web-wordpress [0.1.0]
Uploading mysql        [7.2.0]
Uploading php          [1.9.0]
Uploading rbac         [1.0.3]
Uploading seven_zip    [2.0.1]
Uploading smf          [2.2.8]
Uploading windows      [1.43.0]
Uploading xml          [2.0.0]
Uploading yum          [3.11.0]
Uploading yum-epel     [0.7.0]
Uploading yum-mysql-community [0.2.0]
Uploaded all cookbooks.

Create the apache-wordpress Chef role. This role will be used to install the WordPress Web Application.

~/cookbooks$ knife role from file mtd-web-wordpress/roles/apache-wordpress.rb
Updated Role apache-wordpress!

Create the mysql-wordpress Chef role. This role will be used to install the MySQL database server.

~/cookbooks$ knife role from file mtd-db-wordpress/roles/mysql-wordpress.rb
Updated Role mysql-wordpress!