Getting Started with Cobbler

I’m not a full-time system administrator and my knowledge is really limited in this domain, especially when it comes close to hardware. But I need to re-install several servers in a data center without physically accessing them. They’re using CentOS 6 now, and I want clean installs of CentOS 7.

I started looking into Cobbler. To avoid making the physical servers inaccessible through network, I played a while with Cobbler in some VirtualBox VMs in my MacBook and here are some notes.

Preparing VMs

  1. Download an iso image of CentOS. The minimal iso suffices. I installed cobbler in a 6.5 VM but I think it also works in 7.
  2. Install VirtualBox. Make sure you also install the correct VirtualBox Extension Pack if you want PXE install later. But PXE is not the only choice for remote install.
  3. Create two VMs: cobbler and test. Configure the VMs to use bridged network, since they need to interact with each other. Install CentOS on cobbler. We’ll install the “bare-metal” test VM with cobbler.

Cobbler Installation

There’re some instructions on installation in RHEL/CentOS in cobbler’s official manual but it seems to be incomplete.

In CentOS 7, the commands needed are actually:

# rpm -Uvh http://ftp.jaist.ac.jp/pub/Linux/Fedora/epel/7/x86_64/e/epel-release-7-2.noarch.rpm
# yum install cobbler cobbler-web dnsmasq syslinux pykickstart
# systemctl enable cobblerd
# systemctl start cobblerd
# systemctl enable httpd
# systemctl start httpd

cobbler-web package is optional, but it helped me to get familiar with cobbler’s object structure and configurations.

Check firewall configuration if you’re not able to access the web interface. When it’s started, visit with a browser:

https://{SERVER_IP}/cobbler_web

Note that you’ll get “403 forbidden” message if you access via HTTP instead of HTTPS scheme. The default username and password are both “cobbler”. See how to change the default password.

Cobbler Configuration

IBM devloperWorks has a good article about cobbler. It’s a great introduction and has an example of installing Fedora 17. It also uses fence-tools to talk to remote management systems (Dell’s iDRAC, HP’s iLO, for example), but such systems doesn’t exist on every server so we’ll ignore it in this article.

The most useful options in /etc/cobbler/settings:

default_password_crypted: "{root password for installed systems. Encrypt your own with openssl passwd -1}"
manage_dhcp: 1
manage_dns: 1
manage_tftpd: 1
restart_dhcp: 1
restart_dns: 1
pxe_just_once: 1
next_server: {server's IP address}
server: {server's IP address}

In /etc/cobbler/modules.conf:

[dns]
module = manage_dnsmasq

[dhcp]
module = manage_dnsmasq

[tftpd]
module = manage_in_tftpd

And edit /etc/cobbler/dnsmasq.template to configure a simple DHCP server following the article. Pay attention to the line “dhcp-option=3,$next_server” – this is the gateway and the article assumes that the cobbler server acts as gateway, which is not always the case, so probably you want to put the correct gateway there. When you think you’re all set, run:


# systemctl restart cobblerd
# cobbler sync
# systemctl enable xinetd
# systemctl start xinetd

It starts dnsmasq and does a bunch of other configuration things.

Then run "cobbler check" to see what cobbler checker says. You may safely ignore entries like:

  • some network boot-loaders are missing - all we need are provided by syslinux
  • debmirror package is not installed - I'm not installing debian distros
  • fencing tools were not found - we don't talk to remote management systems
  • file /etc/xinetd.d/rsync does not exist - we don't need rsyncd

As of this writing CentOS 7 isn't well supported by the checker of cobbler 2.6.5 and I saw false alerts like "Unknown distribution type" and "Apache (httpd) is not installed and/or in path".

Now if you check open ports of the cobbler server with "netstat -lnutp" you'll see DNS, DHCP, tftp, etc. Our DHCP server runs bootp protocol to communicate with PXE so it doesn't matter if you already have a DHCP in the same LAN.

Import a Distro

Open the cobbler VM's settings in VirtualBox and go to Storage to find its CD Drive, and "insert" the iso previously downloaded. Then mount and import this distro (CentOS 7):

# mkdir /mnt/iso
# mount -o loop /dev/dvd /mnt/iso
# cobbler import --arch=x86_64 --path=/mnt/iso --name=CentOS-7
# cobbler distro list
# cobbler profile list

The last two commands show that importing a distro also creates a new profile with the distro associated. Now these two objects are also shown in the web interface. A profile also has a kickstart property and by default it's /var/lib/cobbler/kickstarts/sample.ks. Let's create a new one in the same directory for easy management (and an extra benefit if you want to view/edit it in web interface). The kickstart script can be a plain one, but checkout the devloperWorks article again to see how template variables are used. Here I'll omit the details of kickstart.

To use another kickstart in our profile:

# cobbler profile edit --name=CentOS-7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-7.ks

Create and Install a System

Create a system and enable netboot:

# cobbler system add --name=centos7-test --profile=CentOS-7-x86_64  --interface={bios interface name} --mac={mac address} --ip-address={ip address you want to assign it} --netboot-enabled=1

In "test" VM's settings - system - boot order, enable network and move it to the top of the list, so that we can PXE boot (requires VirtualBox Extension Pack) the VM. Now start the VM and it should boot into network installation, using cobbler server as source.

pxe_just_once Does not Work?

pxe_just_once should prevent the machine from entering an installation loop when effective. But it's not a magic - the client system ("test" in this case) has to tell cobbler that it's done installation. If it doesn't work, you must be missing this snippet in your kickstart %post section:

$SNIPPET('kickstart_done')

The template engine actually will replace this line with a wget request to send cobbler the message. See the snippets shipped with cobbler at /var/lib/cobbler/snippets.

The snippet uses wget to communicate with cobbler, so also make sure that you have wget installed on the system before it. You can put it into %packages section, or just use "yum install -y wget".

Netboot a System Without PXE - koan

I have no idea of the boot orders of the servers I'm going to install, so PXE doesn't really help in my case. But since the servers already have working operating systems, koan comes to the rescue.

Install koan:

# rpm -Uvh http://ftp.jaist.ac.jp/pub/Linux/Fedora/epel/7/x86_64/e/epel-release-7-2.noarch.rpm
# yum install koan

koan doesn't support CentOS 7's version numbering, so in os_release function of /usr/lib/python2.7/site-packages/koan/utils.py, replace

      for t in tokens:
         try:
             return (make,float(t))
         except ValueError, ve:
             pass
      raise CX("failed to detect local OS version from /etc/redhat-release")

with

      for t in tokens:
         try:
             match = re.match('^\d+(?:\.\d+)?', t)
             if match:
                 return (make, float(match.group(0)))
         except ValueError, ve:
             pass
      raise CX("failed to detect local OS version from /etc/redhat-release")

Then let koan create a netboot entry in grub:

# koan --replace-self --system=centos7-test

Now shutdown "test" and disable "Network" in settings - boot order. This is to ensure that we're using grub. Start the VM and it also installs from cobbler (you should see an extra boot entry on top of grub's boot menu).

Hope it helps people not so familiar with system administration.

One thought on “Getting Started with Cobbler”

  1. good afternoon friend ‘m new with CentOS and I have days trying to set it up and I can not … When I want to Import the iso .. gives me error and days have nothing … I installed centos 6.6 in a virtual machine and I’m trying to import debian iso 7.7 and 7.5 ubuntu 14.10 and no … let me check the shoemaker solo Ask mistake shows me that UN is the one who gave q no shoemaker and Installed loaders meetings but since I have installed it , and when I shoemaker I synchronize entire task sale. since they can not do if you have any suggestions that could help me I would appreciate it ….

    PS: Sorry if English is bad .. But I ‘m from Venezuela and google translator Using Power para write ..
    I leave my mail for me can you help me thank you very much ….
    ronaldjose1987@gmail.com

Leave a Reply

Your email address will not be published. Required fields are marked *

Prove your intelligence before hitting * Time limit is exhausted. Please reload CAPTCHA.