In my previous post I explained the VMs installation and network configuration needed for installing Chef. In this second part, I’ll show how to install and configure the Chef Server, the two Nodes and the Chef Workstation. An overview and an explanation of these components can be seen here.

In order to get the DEB packages for Ubuntu, it’s needed to register and you’ll get an e-mail with the links to download them. Once all the packages are in the Chef Server, the installation can start.

Chef Server

My Chef Server is an Ubuntu Server. It has installed an Apache server using the port 80. Chef uses Nginx in the ports 80 and 443 so I need to stop the apache server before configuring Chef:
sudo /etc/init.d/apache2 stop
sudo update-rc.d apache2 disable

Now I can proceed with the installation and configuration of Chef:

sudo dpkg -i private-chef_11.2.2-1_amd64.deb
sudo private-chef-ctl reconfigure
sudo private-chef-ctl test

sudo dpkg -i opscode-reporting_1.1.6-1_amd64.deb
sudo opscode-reporting-ctl reconfigure
sudo private-chef-ctl restart opscode-reporting
sudo opscode-reporting-ctl test

sudo dpkg -i opscode-push-jobs-server_1.1.3-1_amd64.deb
sudo opscode-push-jobs-server-ctl reconfigure
opscode-push-jobs-server-ctl test

Don’t use root for running the previous commands or there will be an error. I got rid of the error just by using sudo as it’s explained in the documentation.

chef_test_no_errors

User and Organization

The user and organization can be created through the Chef Server Web interface. In my case, I can go to https://chefserver.alberto.com and sign up for a new user. The key for that user is needed for the Workstation configuration.

chef server create userThe user key can be generated and downloaded from the User section:
 chef server user key
The organization can be created as well from the web interface. The validation key for the organization is needed as well.
chef server create organization

Chef Workstation

As the Chef Workstation is an Ubuntu Desktop, I can use “sudo apt-get install chef” for installing the chef client. In my example, I’m using again https://chefserver.alberto.com as the Chef Server URL. Remember that I have added all the IPs and names in the /etc/hosts file.

The Chef Development Kit is also needed in the Worksation:

sudo dpkg -i chefdk_0.2.2-1_amd64.deb

I need to copy the user key file, the organization validation file and the initial knife configuration file to the Chef Workstation. I have copied them into /home/abian/.chef as it can be seen in the following screenshot:

chef worksation knife configuration

The content of the knife.rb should be something like this

abian@chefws:~/.chef$ cat knife.rb
current_dir = File.dirname(__FILE__)
log_level                :info
log_location           STDOUT
node_name           “abian”
client_key               “#{current_dir}/abian.pem”
validation_client_name   “albertoorg-validator”
validation_key           “#{current_dir}/albertoorg-validator.pem”
chef_server_url          ‘https://chefserver.alberto.com/organizations/albertoorg’
cache_type               ‘BasicFile’
cache_options( :path => “#{ENV[‘HOME’]}/.chef/checksums” )
cookbook_path            [“#{current_dir}/../cookbooks”]

Chef Nodes

I needed to install libc >= 2.14 in the two Debian servers to use the chef client. If you have installed Debian 7.6 in the nodes you’ll need to do the next three steps:

– Add sources.list: sudo echo ‘deb http://ftp.ie.debian.org/debian/ testing non-free contrib main’ >> /etc/apt/sources.list
– Check that it doesn’t break anything: sudo apt-get -t testing install libc6-dev –dry-run
– Install the new version: sudo apt-get -t testing install libc6-dev

The Chef Nodes are ready to be added to the chef environment. From the Chef Workstation run the following commands:

knife bootstrap debian1.alberto.com -x root -P password -N debian1
knife bootstrap debian2.alberto.com -x root -P password -N debian2

The new nodes appear now in the Chef web interface:
chef server with two nodesThe environment is ready for the addition of cookbooks and recipes.