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