2013-11-18

Razor - DHCP and TFTP

This is part 2 of a series of posts on the new version of razor-server

1. Installing Razor - Yes the New Version..
2. Razor - DHCP and TFTP
3. Installing the Razor client and creating a repository
4. Installers, Policies and Tags
5. Razor - What Lies Within the installer?
6. Installing ESXi with Razor

In the previous part we installed the razor-server component.

But what use is razor without TFTP and DHCP servers that will allow you to boot your machines and install their OS? Because the architecture is modular, this can be done on different machines, or in this case - a single VM.

Here is my layout of my environment.

Environment

My razor server has two NICs - one for access to the outside world and the other to provision my nodes. The reason I did it this way was because I do not control the allocation of IP addresses outside of my network and here I needed full control.

Install dnsmasq

apt-get install dnsmasq -y

dnsmasq

The configuration files of dnsmasq needs to modified.

  • The first 3 lines take care of the iPXE boot.
  • Enable the TFTP Server.
  • Root directory where the boot files will be located.
  • Set a DHCP range (this should be customized according to your environment).

To add this basic configuration to the dnsmasq server you can use the following:

cat >> /etc/dnsmasq.conf << __DNSMASQ_CONF__

# This works for dnsmasq 2.45
# iPXE sets option 175, mark it for network IPXEBOOT
dhcp-match=IPXEBOOT,175
dhcp-boot=net:IPXEBOOT,bootstrap.ipxe
dhcp-boot=undionly.kpxe
# TFTP setup
enable-tftp
tftp-root=/var/lib/tftpboot
dhcp-range=192.168.1.50,192.168.1.150,12h

__DNSMASQ_CONF__

dnsmasq.conf

The directory we defined above is not present by default - so it must be created, and then restart the dnsmasq service to start with the correct settings

mkdir -p /var/lib/tftpboot
service dnsmasq restart

tftpboot directory

Get the iPXE boot firmware and put it in the tftpboot directory..

cd /tmp
curl -L -O
http://boot.ipxe.org/undionly.kpxe
mv undionly.kpxe /var/lib/tftpboot/

iPXE

Create the razor iPXE bootstrap script. The nic_max parameter indicates the maximum number of NICs for which bootstrap.ipxe will report MAC's back to the razor server. In my case 3 was enough. File is generated on the fly according to the URL and parameters passed.
(In order to eliminate problems with name resolution - it is easier to use an IP address instead of a hostname)

curl -L -O http://192.168.1.5:8080/api/microkernel/bootstrap?nic_max=3
mv bootstrap* /var/lib/tftpboot/bootstrap.ipxe

bootstrap.ipxe

Download and unpack the razor microkernel. This will create a microkernel folder under the root directory of your repo-store.

curl -L -O http://links.puppetlabs.com/razor-microkernel-003.tar
tar xf razor-microkernel-002.tar -C /var/lib/razor/repo-store/
rm -rf razor-microkernel-002.tar

microkernel

microkernel files

So just to recap. You should now have a DHCP/TFTP server with the correct configuration, iPXE, the razor bootstrap and also the razor microkernel. You are now ready to PXE boot your first node.

When powering up a node and booting on the 192.168.1.0/24 network you should see something similar to the following.

boot process

Here you can see that the node received an IP, contacted the TFTP server, and started the bootstrap file. It then contacts the razor server, and starts to boot the microkernel.

Within a short time you will have booted into the microkernel and should end up at this screen

login

How can you verify the that razor has recognized your node? Through the API.

Looking at the collection of nodes - http://razor:8080/api/collections/nodes you should see the node you just brought up.

node1

What does razor know about the node? - http://razor:8080/api/collections/nodes/node1 

node1 details

Of course we could send API calls all day through a web browser, but that is not so convenient.

In the next post we will install the razor-client and start create a installation repository.