PXE virtual network with Virtualbox and Cobbler

2009 March 16
by Dick

A while back I set up a virtual kickstart network with VMware Fusion and Cobbler on my Mac.

But Fusion (unlike VMware server/workstation) made tweaking low-level settings hard, so I’ve switched to  VirtualBox, which is free (for non-commercial/eductional use), has a kick-ass command line interface and much better networking options.

Here’s a revised howto.

why?

I’ll just cover the install of Cobbler, NAT, and BIND , along with a quick ‘hey look, it works’ test.

Cobbler is a toolkit for kickstarting servers, building package repos, etc. The plan is to kickstart the bare minimum so that Puppet or Chef can take over and do configuration management.

The ‘master’ server, shoemaker will run Cobbler (and eventually puppetmasterd/chef-server) and NAT out to the world via VirtualBox.app. The Mac sees traffic as coming from that process.

shoemakers other interface is on a virtual VLAN (or ‘intnet’), where the kickstarted VMs will live. For bonus points, they’ll all route and do DNS queries via  shoemaker. It looks a bit like:

cobbler virtual VLAN

Once we’re done, we’ll have an easy way to kickstart test CentOS servers on a private test network. I’m going to use that to finally master chef/puppet.

get VirtualBox and CentOS

Get Virtualbox here – it’s a straightforward install. I used the full CentOS DVD.

build a VM to run Cobbler

The “VBoxManage” command lets you build VMs on the commandline (the GUI exposes these settings if you’d rather). Open Terminal.app and run this:

VBoxManage createvm -name shoemaker -ostype RedHat -register -memory 512
# NIC1 (eth0) is NATted, NIC2 (eth1) is on the 'pxeland' intnet
VBoxManage modifyvm shoemaker -nic1 nat -nic2 intnet -intnet2 pxeland
# make a 10Gb disk image
VBoxManage createhd -filename  shoemaker.vdi -size 10240 -register
# attach the disk to the VM : '-sataportcount 1' stops linux probing 30-odd virtual SATA ports
VBoxManage modifyvm shoemaker -sata on -sataport1 shoemaker.vdi -sataportcount 1
# attach a CentOS ISO and boot the VM
VBoxManage modifyvm shoemaker -dvd ~/Downloads/CentOS-5.2-i386-bin-DVD.iso
VBoxManage startvm shoemaker

The install shouldn’t be too suprising; let eth0 DHCP and set eth1 to a static IP (10.0.0.254/24):

2 NICs

2 NICs

Once you’re done, eject the dvd (‘VBoxManage modifyvm centos -dvd none’) and reboot. On first boot, you get the chance to disable SELinux; I’d take it, unless you enjoy cryptic errors.

install Cobbler (from EPEL)

Now we can login to shoemaker and setup Cobbler.

Tell yum about the EPEL repo we’ll pull Cobbler from:

rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm
yum update -y
yum install -y cobbler

and install some other bits too:

yum install -y dhcp yum-utils bind
for i in xinetd cobblerd httpd named dhcpd
do
chkconfig $i on
/etc/init.d/$i start
done

Then you configure Cobbler, which involves running “cobbler check” and making the changes it suggests, and repeating until it stops moaning :)

I did:

  • /etc/xinetd.d/tftp : “disable : yes” -> ‘disable : no’
  • /etc/cobbler/settings : set “server : 10.0.0.254” and “next_server : 10.0.0.254”
  • /etc/cobbler/settings: “manage_dhcp : 0” -> “manage_dhcp : 1”
  • /etc/cobbler/settings: “manage_dns : 0” -> “manage_dns : 1”
  • /etc/cobbler/settings: (watch out for whitespace, it’s YAML: 3 spaces then a ’-’)
    manage_forward_zones:
       - 'pixie'
    manage_reverse_zones:
       - '10.0.0'
    

Just use my files if you like : here’s cobbler.settings . We’ll also run DHCP, DNS and NAT for the other boxes on the network,so I setup the subnet 10.0.0/24 in /etc/cobbler/dhcp.template. tweaked /etc/cobbler/named.template and added an A record for shoemaker itself to /etc/cobbler/zone.template . I’d like shoemaker to find hosts in the ‘.pixie’ domain (the internal network), I point it at its own (Cobbler-managed) BIND with

echo 'prepend domain-name-servers 10.0.0.254;' >> /etc/dhclient-eth0.conf
Restarted all the bits with:
/etc/init.d/xinetd restart
cobbler sync

and that should be it. I ran NAT with this /etc/sysconfig/iptables

chkconfig iptables on
# edit /etc/sysctl.conf and set "net.ipv4.ip_forward = 0" -> "net.ipv4.ip_forward = 1"
reboot

create a test PXE VM

First, have Cobbler ‘import’ the CentOS 5.2 DVD. This creates a repository and some default kickstart profiles.

# shell into the shoemaker VM and import the repo
mount /dev/cdrom /mnt
cobbler import --mirror=/mnt --name=centos52
cobbler sync

Next, we define a system that is based off the centOS profile (by default a kickstarting system presents a menu of available profiles, we’re tying this one down) :

cobbler system add --name=clobberella --profile=centos52-i386 --dns-name clobberella.pixie
cobbler system edit --name=clobberella --ip=10.0.0.250 --mac=aa:aa:bb:bb:cc:01
cobbler sync # to regenerate DHCP tables

Finally we build a VM with the right MAC address (note there are no colons in this one) and boot it. Back to Terminal.app :

VBoxManage createvm -name clobberella -ostype RedHat -register
VBoxManage modifyvm clobberella -memory 512 -boot1 disk -boot2 net -nic1 intnet -intnet1 pxeland
VBoxManage modifyvm clobberella -macaddress1 aaaabbbbcc01
# make a disk image and attach it to SATA port 1
VBoxManage createhd -filename  clobberella.vdi -size 6000 -register
VBoxManage modifyvm clobberella -sata on -sataport1 clobberella.vdi -sataportcount 1
VBoxManage startvm clobberella

‘clobberella’ should boot, get the IP you specified for it, PXE down a kickstart and install a base CentOS build. “tail -f /var/log/cobbler/syslog/10.0.0.200” lets you track the install process from shoemaker.

The clobberella root password defaults to ‘cobbler’ when it’s done.

next?

Next job is to build a custom Cobbler profile (kickstart, essentially) that will get puppet or chef installed on freshly PXEed VMs.  UPDATE: here’s how to kickstart Puppet using Cobbler.

3 Responses leave one →

Trackbacks & Pingbacks

  1. PXE testbed with Cobbler and VMware Fusion | number 9
  2. PXE virtual network with Virtualbox and Cobbler | The Linux Blog : Applications beginner browser canonical codeblocks Command Line compile debian disk space download editor firefix General generate gnome GRAPHICS graphics editors graphics other Howto humo
  3. bootstrapping Puppet from Cobbler | number 9

Leave a Reply

Note: You can use basic XHTML in your comments. Your email address will never be published.

Subscribe to this comment feed via RSS