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 Nagios Chef cookbook into the cookbooks directory.

~/cookbooks$ ls -la nagios_example.tar.gz
-rw-r--r--  1 gforghetti  staff  1460 Jan 21 10:32 nagios_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 2.9.2" bluepill "build-essential 2.0.6" chef_handler chef-sugar compat_resource iis mingw \
'mysql 7.2.0' nagios nginx nginx_simplecgi nrpe "ohai 2.0.4" packagecloud perl php rbac rsyslog runit seven_zip smf windows \
xml yum yum-epel yum-mysql-community zap; 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 2.9.2 to /Users/gforghetti/Cookbooks/apt-2.9.2.tar.gz
Cookbook saved: /Users/gforghetti/Cookbooks/apt-2.9.2.tar.gz
Downloading bluepill from Supermarket at version 2.4.3 to /Users/gforghetti/Cookbooks/bluepill-2.4.3.tar.gz
Cookbook saved: /Users/gforghetti/Cookbooks/bluepill-2.4.3.tar.gz
Downloading build-essential from Supermarket at version 2.0.6 to /Users/gforghetti/Cookbooks/build-essential-2.0.6.tar.gz
Cookbook saved: /Users/gforghetti/Cookbooks/build-essential-2.0.6.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 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 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.8 to /Users/gforghetti/Cookbooks/iis-4.1.8.tar.gz
Cookbook saved: /Users/gforghetti/Cookbooks/iis-4.1.8.tar.gz
Downloading mingw from Supermarket at version 1.2.0 to /Users/gforghetti/Cookbooks/mingw-1.2.0.tar.gz
Cookbook saved: /Users/gforghetti/Cookbooks/mingw-1.2.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 nagios from Supermarket at version 7.2.6 to /Users/gforghetti/Cookbooks/nagios-7.2.6.tar.gz
Cookbook saved: /Users/gforghetti/Cookbooks/nagios-7.2.6.tar.gz
Downloading nginx from Supermarket at version 2.7.6 to /Users/gforghetti/Cookbooks/nginx-2.7.6.tar.gz
Cookbook saved: /Users/gforghetti/Cookbooks/nginx-2.7.6.tar.gz
Downloading nginx_simplecgi from Supermarket at version 0.1.2 to /Users/gforghetti/Cookbooks/nginx_simplecgi-0.1.2.tar.gz
Cookbook saved: /Users/gforghetti/Cookbooks/nginx_simplecgi-0.1.2.tar.gz
Downloading nrpe from Supermarket at version 1.5.2 to /Users/gforghetti/Cookbooks/nrpe-1.5.2.tar.gz
Cookbook saved: /Users/gforghetti/Cookbooks/nrpe-1.5.2.tar.gz
Downloading ohai from Supermarket at version 2.0.4 to /Users/gforghetti/Cookbooks/ohai-2.0.4.tar.gz
Cookbook saved: /Users/gforghetti/Cookbooks/ohai-2.0.4.tar.gz
Downloading packagecloud from Supermarket at version 0.2.3 to /Users/gforghetti/Cookbooks/packagecloud-0.2.3.tar.gz
Cookbook saved: /Users/gforghetti/Cookbooks/packagecloud-0.2.3.tar.gz
Downloading perl from Supermarket at version 3.0.0 to /Users/gforghetti/Cookbooks/perl-3.0.0.tar.gz
Cookbook saved: /Users/gforghetti/Cookbooks/perl-3.0.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 rsyslog from Supermarket at version 4.0.0 to /Users/gforghetti/Cookbooks/rsyslog-4.0.0.tar.gz
Cookbook saved: /Users/gforghetti/Cookbooks/rsyslog-4.0.0.tar.gz
Downloading runit from Supermarket at version 1.7.8 to /Users/gforghetti/Cookbooks/runit-1.7.8.tar.gz
Cookbook saved: /Users/gforghetti/Cookbooks/runit-1.7.8.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
Downloading zap from Supermarket at version 0.11.4 to /Users/gforghetti/Cookbooks/zap-0.11.4.tar.gz
Cookbook saved: /Users/gforghetti/Cookbooks/zap-0.11.4.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-2.9.2.tar.gz extracted.
Chef cookbook bluepill-2.4.3.tar.gz extracted.
Chef cookbook build-essential-2.0.6.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.8.tar.gz extracted.
Chef cookbook mingw-1.2.0.tar.gz extracted.
Chef cookbook mysql-7.2.0.tar.gz extracted.
Chef cookbook nagios-7.2.6.tar.gz extracted.
Chef cookbook nagios_example.tar.gz extracted.
Chef cookbook nginx-2.7.6.tar.gz extracted.
Chef cookbook nginx_simplecgi-0.1.2.tar.gz extracted.
Chef cookbook nrpe-1.5.2.tar.gz extracted.
Chef cookbook ohai-2.0.4.tar.gz extracted.
Chef cookbook packagecloud-0.2.3.tar.gz extracted.
Chef cookbook perl-3.0.0.tar.gz extracted.
Chef cookbook php-1.9.0.tar.gz extracted.
Chef cookbook rbac-1.0.3.tar.gz extracted.
Chef cookbook rsyslog-4.0.0.tar.gz extracted.
Chef cookbook runit-1.7.8.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 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.
Chef cookbook zap-0.11.4.tar.gz extracted.

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

knife cookbook upload --all
Uploading acme-nagios-server [0.1.0]
Uploading apache2      [3.2.2]
Uploading apt          [2.9.2]
Uploading bluepill     [2.4.3]
Uploading build-essential [2.0.6]
Uploading chef-sugar   [3.3.0]
Uploading chef_handler [1.4.0]
Uploading compat_resource [12.10.6]
Uploading iis          [4.1.8]
Uploading mingw        [1.2.0]
Uploading mysql        [7.2.0]
Uploading nagios       [7.2.6]
Uploading nginx        [2.7.6]
Uploading nginx_simplecgi [0.1.2]
Uploading nrpe         [1.5.2]
Uploading ohai         [2.0.4]
Uploading packagecloud [0.2.3]
Uploading perl         [3.0.0]
Uploading php          [1.9.0]
Uploading rbac         [1.0.3]
Uploading rsyslog      [4.0.0]
Uploading runit        [1.7.8]
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]
Uploading zap          [0.11.4]
Uploaded all cookbooks.

Create the ACME-Monitoring Chef role.

knife role from file acme-nagios-server/roles/acme-nagios-server.rb
Updated Role ACME-Monitoring!