ThorneLabs

Install and Configure Cobbler on Ubuntu 14.04

• Updated February 27, 2019


Cobbler has always been my goto for provisioning bare metal servers. This is due in large part to its ability to provision CentOS, RHEL, Ubuntu, and Debian easily and quickly.

This post will cover setting up Cobbler on Ubuntu 14.04 and how to provision a server with Ubuntu Server 14.04.

Pick a Server

First and foremost, find and setup a server to act as your build server. The rest of this post will assume you are installing everything on that server.

Install Cobbler

Install the necessary packages:

apt-get install cobbler dhcp3-server

Configure the DHCP Server

A key part of PXE booting is the DHCP server. Cobbler supports both dhcp3-server and dnsmasq. This post will only cover dhcp3-server.

Open /etc/cobbler/settings and set the following parameters (you will need to search for these parameters in the configuration file):

manage_dhcp: 1
restart_dhcp: 1
next_server: <IP address of the network interface you want the PXE services to listen on>
server: <IP address of the network interface you want the PXE services to listen on>

Open /etc/cobbler/modules.conf and set the following parameter (you will need to search for this parameter):

[dhcp]
module = manage_isc

Open /etc/default/isc-dhcp-server and configure the network interface for the DHCP server to listen on:

INTERFACES="Network interface you want the DHCP server to listen on"

Open /etc/cobbler/dhcp.template and configure your DHCP settings. Change the network, network ranges, and subnet mask to match your network:

subnet 192.168.236.0 netmask 255.255.255.0 {
     option routers             192.168.236.1;
     option domain-name-servers 8.8.8.8;
     option subnet-mask         255.255.255.0;
     range dynamic-bootp        192.168.236.100 192.168.236.254;
     default-lease-time         21600;
     max-lease-time             43200;
     next-server                $next_server;

Import Bootable ISOs

With the configuration files in place, it is now time to download the bootable ISOs and create a cobbler distro. This post will only cover importing Ubuntu Server 14.04.3.

Download the Ubuntu Server 14.04.3 ISO:

wget http://releases.ubuntu.com/14.04.3/ubuntu-14.04.3-server-amd64.iso

Mount the Ubuntu ISO:

mount -o loop ubuntu-14.04.3-server-amd64.iso /mnt

Import the Ubuntu ISO into cobbler to create a cobbler distro:

cobbler import --name=ubuntu-14.04.3-server-amd64 --path=/mnt

Unmount the Ubuntu ISO:

umount /mnt

Replace sources.list

Whether you use the included Preseed files with Cobbler or your own, unless explicitly set, Cobbler will rewrite the provisioned server’s sources.list file to pull packages from the Cobbler server. Unless you use Cobbler as a repository mirror, this is not a useful change.

The custom Preseed file in the next section will reference the default sources.list file to ensure the provisioned server’s apt repositories download from archive.ubuntu.com instead of the Cobbler server.

Run the following command to create file trusty-sources.list containing the contents from the default Ubuntu 14.04 sources.list file (the comments from the default file have been removed):

cat << EOF > /var/www/html/trusty-sources.list
deb http://archive.ubuntu.com/ubuntu trusty main restricted
deb-src http://archive.ubuntu.com/ubuntu trusty main restricted

deb http://archive.ubuntu.com/ubuntu trusty-updates main restricted
deb-src http://archive.ubuntu.com/ubuntu trusty-updates main restricted

deb http://archive.ubuntu.com/ubuntu trusty universe
deb-src http://archive.ubuntu.com/ubuntu trusty universe
deb http://archive.ubuntu.com/ubuntu trusty-updates universe
deb-src http://archive.ubuntu.com/ubuntu trusty-updates universe

deb http://archive.ubuntu.com/ubuntu trusty multiverse
deb-src http://archive.ubuntu.com/ubuntu trusty multiverse
deb http://archive.ubuntu.com/ubuntu trusty-updates multiverse
deb-src http://archive.ubuntu.com/ubuntu trusty-updates multiverse

deb http://archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse

deb http://security.ubuntu.com/ubuntu trusty-security main restricted
deb-src http://security.ubuntu.com/ubuntu trusty-security main restricted
deb http://security.ubuntu.com/ubuntu trusty-security universe
deb-src http://security.ubuntu.com/ubuntu trusty-security universe
deb http://security.ubuntu.com/ubuntu trusty-security multiverse
deb-src http://security.ubuntu.com/ubuntu trusty-security multiverse
EOF

Configure a Cobbler Profile

A cobbler profile maps a Kickstart or Preseed file to a particular cobbler distro.

The default Preseed file included with a Ubuntu based cobbler profile is not unattended and will require user interaction during installation. Download the following custom Preseed which is unattended:

wget https://raw.githubusercontent.com/jameswthorne/preseeds/master/ubuntu-server-14.04-unattended-cobbler.seed -O /var/lib/cobbler/kickstarts/ubuntu-server-14.04-unattended-cobbler.seed

Next, create a new cobbler profile using the new Preseed file with the following command:

cobbler profile add \
--name ubuntu-14.04.3-server-unattended \
--distro ubuntu-14.04.3-server-x86_64 \
--kickstart /var/lib/cobbler/kickstarts/ubuntu-server-14.04-unattended-cobbler.seed

Finally, restart and sync Cobbler:

service cobbler restart

cobbler sync

At this point, you can PXE boot any server that is on the same network as the Cobbler services ((tftpd, dhcpd, httpd) are listening on. Each server will PXE boot to a menu where you can select to continue to local boot or boot to the cobbler profile you created above.

If you are setting up a Cobbler server in Virtual Box and are having issues obtaining a DHCP address for PXE booting, you may need to enable Promiscuous Mode in Virtual Box for the interface the Cobbler services are listening on.

Configure a Cobbler System

If you want to be able to reboot a server and have it automatically begin installing Ubuntu Server without user interaction, you are going to need to setup a cobbler system.

First, get the MAC address of the network interface enabled to PXE boot from the to be provisioned server.

Second, figure out a hostname for the server and figure out what IP address you want to assign it. In this example, I will use www1.example.com for the hostname, 192.168.236.50 for the IP address, and em1 as the network interface enabled to PXE boot.

Finally, with that information, create the cobbler system:

cobbler system add \
--name=www1.example.com \
--mac=00:01:02:03:04:05 \
--profile=ubuntu-14.04.3-server-unattended \
--hostname=www1.example.com \
--interface=em1 \
--ip-address=192.168.236.50 \
--subnet=255.255.255.0 \
--gateway=192.168.236.1 \
--name-servers=8.8.8.8 8.8.4.4 \
--kopts="interface=em1"

Reboot the server you want to provision and it should begin PXE booting on its own. After about 10 minutes, you should be at the Ubuntu login screen.

Cobbler Gotchas

Static DHCP Entry Disappears

If you created a cobbler system with static=1 and assigned it a static IP address, then use cobbler system edit to set netboot to false, and run cobbler sync, the static DHCP entry in /etc/dhcp/dhcpd.conf will disappear.

The fix is to remove static=1 from the cobbler system entry.