Cobbler on Ubuntu

Selection and Installation

Coming into a new environment is always interesting. One of the first tasks that came up coming into this one was to throw up a provisioning server. Since we're already standardized on Ubuntu I didn't want to immediately jump to Cobbler as the tool of choice. Imagine my surprise when, after reviewing the options, I realized that a tool designed for Redhat is actually the best choice anyway.

Luckily for us Ubuntu 13.10 upgraded to Cobbler 2.4, so when 14.04 LTS is released the upgrade path should be easier. The list of packages is pretty easy:

  • cobbler
  • cobbler-common
  • cobbler-web
  • python-cobbler
  • debmirror
  • mkisofs

As you might expect, installation is as easy as:

aptitude install cobbler cobbler-web debmirror mkisofs

Cobbler is the service itself and cobbler-web is the web interface to the tool. Anything you can do from the web can also be done from the command line, however, personally I find the web interface a bit less cumbersome. The last two packages we'll discuss later.

Once the packages install everything should be good to go. It will pull in a fair number of dependencies. Included in the list is apache which will also be minimally configured and started for you. By default it only runs over non-SSL. If you want encryption, and you probably do, that will have to be set up separately.

Before you go to the web interface we'll need to tell it how you want to authenticate. It supports a number of options, including none. For our purposes we'll just use system accounts. In a corporate environment you'll probably want to configure LDAP, against Active Directory. For our purposes we'll just use local system accounts. So we need to edit the file /etc/cobbler/modules.conf and change the authentication type. Find the appropriate section (line 23 on my system) and make it look like the following.

[authentication]
module = authn_pam

Now restart cobbler so it will see what we changed, service cobbler restart. At this point it's probably worth noting that the "authorization" section also has some useful bits in it. Here we can also configure actual user level access to certain things. It can be a bit of a complicated component and will require research of your own to enact.

Adding a Distro

Before we actually go to it, however, we need to add a distribution. To explain we need to go into a little bit about how Cobbler arranges it's internal objects. In truth it's a fairly simple, and short, hierarchy. At the lowest level we have ‘Distros'. This is a combination of OS and architecture, so Ubuntu 13.10 on amd64. Next we have ‘Profiles'. A profile would be a general configuration of a Distro. That is, we might have a profile called ‘ubuntu13.10-x86_64 Prod Sever and another ‘ubuntu13.10-x86_64 Developer Server. Next we have systems. A system would be a specific install instance and uses a single profile. So we would create a system called ‘www.example.com' that uses the ‘ubuntu13.10-x86_64 Server' profile, has a single network interface called ‘eth0' with MAC address 00:11:22:33:44:55, etc.

For our purposes we really only care about the 64-bit Server instance of 13.10. So we'll insert the install CD, or mount the install iso, and run the command:

cobbler import --name=ubuntu13.10 --arch=x86_64 --path=/media/cdrom

Cobbler will read the install media and generate a distro and profile for you. It also creates a ‘Repo' for that distribution as well. This ‘Repo' will be a locally hosted version of the software tree. When you're to the point of doing automated installations having a local mirror is pretty handy. It saves you some of your upstream bandwidth, since you can download all the packages to your provisioning server and then everything installs against it. It also allows you to be a bit more careful about your software versions, you synchronize your tree today and freeze it. No matter if you install a system today, or 3 months from now, it will be consistent.

Local Mirror Setup

What it won't do is actually download all the packages. This is good for us because, by default, the distro contains gobs more packages than we actually want. Ubuntu distributes packages under three names:

  • main - Officially supported packages
  • universe - Boatloads of other software packages that aren't supported
  • multiverse - Somehow even less supported and may not even have a "free license"

The above import wants to pull in ‘main' and ‘universe', and the categories called saucy, ‘saucy-updates', and ‘saucy-security'. The ‘security' category are all software updates that are labeled as security fixes and ‘updates' is the combined list of all updates. This is where some configuration time questions come into place. How much space do you have and how much do you want to store locally? If you took the defaults you'll be storing quite a lot of data, certainly more than the 80GB my system had available.

For our purposes we only wanted to pull in main RTM.

  • Log into the web interface (finally)
  • On the left hand side under Configuration click on "Repos"
  • edit ubuntu13.10-x86_64, click on "Advanced"
  • Set "Apt Components (apt only)" to be main only.
  • Set "Apt Dist Names (apt only)" to be saucy only.

Now that we've limited ourselves down a bit drop back down to the command line and run:

cobbler reposync

This tells cobbler to do a few things in the background. First it will use the application debmirror to download all the packages in the main channel for 13.10. Then it will turn that into a local repository that apt-get can use. All told the local repository will be about 10GB, so expect this to take a while. I ate lunch and chatted with the fellow in the next cube.

Assuming nothing exploded and threw nasty error messages yet yell hooray because we're ready to start actually provisioning systems.

Creating Systems

Go back to the web interface and under ‘Configuration' select ‘Systems'. Click the ‘Create New System' button and let's define our box. In the ‘General' tab we need to give it a name and set what kind of install this is. The ‘Name' is entirely for your benefit and is only a label that cobbler uses, so let's call it "My First Provision". Change the profile from ‘None' to ‘ubuntu13.10-x86_64'.

Flip over to the ‘Networking' tab. Type ‘eth0' into the ‘Add Interface' box and click ‘Add'. Now make sure ‘eth0' is selected in the ‘Edit Interface' drop-down and insert the MAC address into the ‘MAC Address' field. If this will be a DHCP assigned interface you can leave the rest alone, otherwise click the ‘Static' checkbox and fill out the page. Once done click the ‘Save' button.

Fixing The Boot Disc Environment

Next up is to build the bootable CD that we'll use to kick off the installer. Before we can actually create the CD we need to do a couple of steps. Drop back down to the command line again and run:

cobbler get-loaders

This tells cobbler to go out to the Internet and download a bunch of files necessary to create a bootable CD. There's a bit of a hitch, though. If you pay close attention to the output you'll see this line come through.

downloading http://www.cobblerd.org/loaders/menu.c32-3.61 to /var/lib/cobbler/loaders/menu.c32

The file menu.c32 belongs to a program called syslinux which is what we'll later use to create the bootable install CD. The get-loaders command downloads the menu.c32 file from syslinux version 3.61 but this version of Ubuntu uses version 4.05. Since syslinux is very dependent on consistent versioning we'll need to replace that file with the right one. Cobbler doesn't kill the original version so replacing it is as easy as copying over the right file.

cp /usr/lib/syslinux/menu.c32 /var/lib/cobbler/loaders/menu.c32

Provisioning

Now we're ready to make ourselves a boot disc. Run the command:

cobbler buildiso

A few seconds later you should have a file called generated.iso in your directory. Congratulations! This is what you'll use to actually install your new server. Copy the file off your Cobbler server and burn it to disc. Or, if you're installing into a virtual machine, mount it on the guest.

Once you boot from CD you'll be presented with a nice curses menu that should include all the profiles and systems you've created. Select "My First Provision" and press enter. You should be treated with a series of progress screens displaying what step of the install is happening. Since we never told Cobbler what the root password should be, it's really pretty ok since we give it a hash, you'll be prompted to enter the password. Except for that your system should entirely install by itself and, once finished, reboot.

At this point you should have a fully functional server installed entirely from your Cobbler server. By default the configuration is pretty boring, for how boring see it yourself at http://your_ipaddr/cblr/svc/op/ks/profile/ubuntu13.10-x86_64. This is the default preseed file that ships with the install.

Getting More Awesome

Now that we've gotten Cobbler set up and working I highly encourage you to look into some of the more interesting features. First read up on preseed, since that will let you tailor the install to your environment. Next look into Cobbler Snippets. These are little bits of code that will get included into your preseed and let you do fun things like autodetect the size of the hard drive and create different partitions. Or change the system's timezone dependent on the DNS name. In my opinion the templating is where the real power of Cobbler shows itself and is definitely worth your time.