septiembre 2014


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.

I has been a good while since I don’t update my blog. The first change you’ll notice is that I’m writing in English now. After nearly three years living in Ireland I somehow got used to it :-) Apologies for my Spanish speaking readers and welcome to the English speaking readers!

I’ve been reading lately a lot of documentation about Chef. It’s really easy getting started with it just by copying and pasting the examples given in the documentation page. I’ll write in this post what I’ve done to play a little bit with Chef with my laptop.

I’m using VirtualBox for the virtual machines but another solution can be used. My host machine is a Dell XPS 13 Developer Edition with Ubuntu Desktop 12.04. VirtualBox can be downloaded from here.

Step 1: Virtual Machines

The first step is creating 4 new virtual machines:

  1. Chef Server:
    • OS: Ubuntu Server 64 bits
    • Memory: 3GB RAM
    • HD: 30 GB of HD
    • Network: Adapter 1 Bridged Adapter, Adapter 2:  Internal Network “chefnet”
  2. Chef Workstation:
    • OS: Ubuntu Desktop 64 bits
    • Memory: 1GB RAM
    • HD: 20 GB of HD
    • Network: Adapter 1 NAT, Adapter 2:  Internal Network “chefnet”
  3. Chef Node 1:
    • OS: Debian 7.6 (wheezy) 64 bits
    • Memory: 1GB RAM
    • HD: 20 GB of HD
    • Network: Adapter 1 NAT, Adapter 2:  Internal Network “chefnet”
  4. Chef Node 2:
    • OS: Debian 7.6 (wheezy) 64 bits
    • Memory: 1GB RAM
    • HD: 20 GB of HD
    • Network: Adapter 1 NAT, Adapter 2:  Internal Network “chefnet”

I’m using different Linux versions for adding a little bit of variety to the testing environment.

It’s needed that all the virtual machines can communicate between each other. Each virtual machine has two network adapters. Adapter 1 is used to give Internet connection to the virtual machine. It’s handy for downloading and installing new packages using APT.

First network adapter

The second network interface is present to have all the virtual machines in the same subnet. VirtualBox gives the option of having an internal network for the virtual machines:

VirtualBox internal network adapterThe second network adapter creates the following internal network:

chef eth1I’m using “Bridged Adapter” to allow me to do SSH and SCP from my host laptop into the Chef Server. I could use the shared folders functionality that VirtualBox offers but I prefer the old fashion ssh way.

The final configuration of the network looks like this

chef_networkStep 2: Install the OS in each machine.

Step 3: Root user and SSH server

After installing the OS in the four virtual machines, I have installed as well the VirtualBox additions in the two Ubuntu VMs. I have installed Gnome in the Chef Server and Unity in the Chef Workstation. The graphical interface is not needed at all in the Chef Server but I added it anyway just in case I needed it later on.

The root account is needed in the four VMs. In Ubuntu Desktop, you’ll need to do “sudo bash” put the password of your user and then “passwd” to create the password for the root user.

The SSH server is needed as well. As all the VMs have connection to internet, I can use the command: apt-get install openssh-server
The root user should be able to be used in a SSH connection. Modify the /etc/ssh/sshd_config file to include this line: PermitRootLogin yes

Step 4: Network

The Chef Server needs to have a Fully Qualified Domain Name. In the Chef Server, use as root: hostname chefserver.alberto.com

As I don’t have a DNS server in this environment. The content of the /etc/hosts should be the same for the four VMs:

192.168.1.10    chefserver.alberto.com
192.168.1.11    debian1.alberto.com
192.168.1.12    debian2.alberto.com
192.168.1.13    chefws.alberto.com

The content of the file /etc/network/interfaces should be:

auto eth0
iface eth0 inet dhcp

auto eth1
iface eth1 inet static
     # Change the las digit in the other machines
     address 192.168.1.10
     netmask 255.255.255.0

In the Ubuntu Desktop machine, probably you’ll need to remove the network manager because it overrides the content of the /etc/network/interfaces file. Try something like: apt-get remove network-manager network-manager-gnome

Final step: Review

The final step is reviewing that the communications are possible between the VMs. This is the summary of my VirtualBox VMs and the four of them running at the same time.
VirtualBox summaryVMs final setup