darrylcauldwell.com On a journey around the datacenter and public cloud.

Configuring Project Hanlon On CentOS 6.5

Since the company I work for CSC got a new CEO then CTO its changed direction and the latest change has been to full participate with the Open Source community.  With this news shortly followed an updated version of a tool our new CTO Dan worked on at EMC with Nick Weaver it was formerly called Razor and the new release is Hanlon.

I chose CentOS 6.5 64bit to host Hanlon and configured this as a VM with two vNICs one normal internet facing and one on a new private vSwitch with no uplinks,  the private is where DHCP\PXE\TFTP will be setup on and where the ESXi VMs will hopefully get built.  All these sit on an nested ESXi 5.0 configured with 12GB of vRAM and access to 1TB of NFS  disk running inside VMware Fusion 6 on a Mac.

I don’t work with Linux so some of my commands might be sub optimal, I’ll try and record all I use here for reference,  and if you see anything I’m doing badly please do say.

First task to the new VM is to start VMware tools installer which mounts the correct ISO,  then install the tools via putty session (or via console).

yum -y install perl
mkdir /mnt/cdrom
mount /dev/cdrom /mnt/cdrom
cp /mnt/cdrom/VMwareTools-*.tar.gz /tmp
tar -zxf /tmp/VMwareTools-*.tar.gz -C /tmp
cd /tmp/vmware-tools-distrib/
./vmware-install.pl --default
rm -f /tmp/VMwareTools-*.tar.gz
rm -rf /tmp/vmware-tools-distrib

I then changed from DHCP to static IP addressing,  to note shown here are only the lines I changed or added the rest I left as they populated by OS

vi /etc/sysconfig/network-scripts/ifcfg-eth0
NETWORK=<Internet Facing Network Address>
NETMASK=<Internet Facing Subnet Mask>
IPADDR=<Internet Facing IP Address>
vi /etc/sysconfig/network-scripts/ifcfg-eth1
NETWORK=<Private Network Address>
NETMASK=<Private Subnet Mask>
IPADDR=<Private IP Address>

My next port of call was to add a DHCP server to the VM, I chose ISC as that was recommended for Razor and appeared simple and well documented.

yum install dhcp
vi /etc/sysconfig/dhcpd

Then change that to listen on eth1


And create a new config file

vi /etc/dhcp/dhcpd.conf

the config file I populate with following (altering with your ID address ranges)

subnet netmask {
option tftp-server-name "";
if exists user-class and option user-class = "iPXE" {
filename "hanlon.ipxe";
} else {
filename "undionly.kpxe";

Start DHCP using

/etc/init.d/dhcpd start

Test ISC DHCP and option by creating a VM with no OS,  and with only a NIC on the private network and it should now pickup a PXE address.

It will fail as there is no PXE or TFTP server setup yet on the Hanlon server. So next step is to add a PXE and TFTP server,  so first task is to install it.

yum -y install tftp-server tftp

Then enable it

sed -i 's/disable\t\t\t= yes/disable\t\t\t= no/g' /etc/xinetd.d/tftp
service xinetd restart

Install Java

yum -y install java-1.7.0-openjdk

Add MongoDB Repo Details

vi /etc/yum.repos.d/mongodb.repo

Then populate new file with

name=MongoDB Repository

And Install MongoDB

yum -y install mongodb-org

Torquebox Ruby Application Platform

curl -L -O http://torquebox.org/release/org/torquebox/torquebox-dist/3.0.1/torquebox-dist-3.0.1-bin.zip
yum -y install unzip
unzip torquebox-dist-3.0.1-bin.zip -d $HOME
echo 'export TORQUEBOX_HOME=$HOME/torquebox-3.0.1' >> ~/.bashrc
echo 'export JBOSS_HOME=$TORQUEBOX_HOME/jboss' >> ~/.bashrc
echo 'export JRUBY_HOME=$TORQUEBOX_HOME/jruby' >> ~/.bashrc
echo 'export PATH=$JRUBY_HOME/bin:$PATH' >> ~/.bashrc
exec $SHELL -l

Download Hanlon

mkdir /opt/hanlon
cd /opt/hanlon
yum -y install git
git clone https://github.com/csc/Hanlon.git

Install Requisite Ruby Gems for Hanlon

cd /opt/hanlon/Hanlon
bundle install
gem update --system

Just need now to finalise the configuration of the Hanlon Microkernel, configure TFTP & iPXE.

Install GCC

yum -y install gcc gcc-c++

Download iPXE & Make Files

git clone https://github.com/ipxe/ipxe.git
curl -O https://gist.githubusercontent.com/jcpowermac/7cc13ce51816ce5222f4/raw/4384911a921a732e0b85d28ff3485fe18c092ffd/image_comboot.patch
yum -y install patch genisoimage
patch -p0 < image_comboot.patch
cd ipxe/src

Move new iPXE files to correct place for TFTP

cd bin
cp undionly.kpxe /var/lib/tftpboot/undionly.kpxe
cp ipxe.pxe /var/lib/tftpboot/ipxe.kpxe
cp ipxe.iso /var/lib/tftpboot/ipxe.iso

Get Syslinux files and move to correct place

curl -O https://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-6.02.tar.gz
tar -zxvf syslinux-6.02.tar.gz --strip-components 3 -C /var/lib/tftpboot syslinux-6.02/bios/core/pxelinux.0
tar -zxvf syslinux-6.02.tar.gz --strip-components 4 -C /var/lib/tftpboot syslinux-6.02/bios/com32/menu/menu.c32

Create Hanlon.pxe

yum -y install wget
wget https://github.com/csc/Hanlon-Microkernel/releases/download/v1.0/hnl_mk_prod-image.1.0.iso<
/opt/hanlon/Hanlon/cli/hanlon image add -t mk -p hnl_mk_prod-image.1.0.iso
/opt/hanlon/Hanlon/cli/hanlon config ipxe > /var/lib/tftpboot/hanlon.ipxe

Configure TFTBoot

mkdir /var/lib/tftpboot/pxelinux.cfg
cat > /var/lib/tftpboot/pxelinux.cfg/default <<EOF
default menu.c32
prompt 0
menu title Hanlon Boot Menu
timeout 50
f1 help.txt
f2 version.txt
label hanlon-boot
menu label Automatic hanlon Node Boot
kernel ipxe.lkrn
append initrd=hanlon.ipxe
label boot-else
menu label Bypass hanlon
localboot 1

Bind TFTP to eth1

vi /etc/xinetd.d/tftp
add bind = <ipaddress> of eth1
chkconfig dhcpd on
service xinetd restart

Test TFTP is working

tftp localhost4
get hanlon.ipxe

If TFTP Times Out Try Disable Firewall

service iptables stop

At this point you should be able to create a test VM bound to same Host Only network and it should pick up a DHCP address then connect to TFTP server and download and boot an image.

Be social and share this post!