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          "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

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

for package in chef_handler chef-sugar iis openssl "sql_server 2.4.0" windows; do knife cookbook site download $package; done
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 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 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 openssl from Supermarket at version 4.4.0 to /Users/gforghetti/Cookbooks/openssl-4.4.0.tar.gz
Cookbook saved: /Users/gforghetti/Cookbooks/openssl-4.4.0.tar.gz
Downloading sql_server from Supermarket at version 2.4.0 to /Users/gforghetti/Cookbooks/sql_server-2.4.0.tar.gz
Cookbook saved: /Users/gforghetti/Cookbooks/sql_server-2.4.0.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 chef-sugar-3.3.0.tar.gz extracted.
Chef cookbook chef_handler-1.4.0.tar.gz extracted.
Chef cookbook iis-4.1.7.tar.gz extracted.
Chef cookbook openssl-4.4.0.tar.gz extracted.
Chef cookbook sql_server-2.4.0.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 chef-sugar     [3.3.0]
Uploading chef_handler   [1.4.0]
Uploading iis            [4.1.7]
Uploading openssl        [4.4.0]
Uploading sql_server     [2.4.0]
Uploading windows        [1.43.0]
Uploaded all cookbooks.

Download the tutorial Chef roles at this link Chef Windows IIS Roles and extract it into the cookbooks directory.

~/cookbooks$ tar -zxvf windows_iis_roles.tar.gz
x acme-iis-sql-server.rb
x acme-iis-webserver.rb

Create the ACME-IIS-Webserver Chef role.

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

Create the ACME-IIS-SQL-Server Chef role.

~/cookbooks$ knife role from file acme-iis-sql-server.rb
Updated Role ACME-IIS-SQL-Server!