Cobbler handles kickstarts on my VirtualBox network , but I need it to take care of Puppet too.

setup puppetmasterd

I’ll run puppetmasterd on my Kickstart server (‘shoemaker’, also my Cobbler server).

By default, puppetd expects puppetmasterd to be on a host called ‘puppet’. That’s easy to arrange.

  # setup a CNAME of 'puppet' that points to shoemaker (the puppetmaster)
  echo 'puppet	IN	CNAME	shoemaker' >> /etc/cobbler/zone.template
  cobbler sync

Now enable puppetmasterd on shoemaker (autosigning makes unattended installs much simpler).

  # install and enable puppetmaster
  yum install -y puppet-server ruby-rdoc
  chkconfig puppetmaster on
  /etc/init.d/puppetmaster start
  # turn on autosigning for our domain
  echo '*.pixie' > /etc/puppet/autosign.conf

puppet aware kickstarts

To tailor a kickstart using Cobbler, you :

  1. setup a distro (make install media available to kickstarting machines)
  2. (optionally) define extra repos (for 3rd party RPMs)
  3. create a profile (a custom kickstart) that uses your distro and repos
  4. define a system (MAC address/IP) that uses that profile

In my case

  • distro == CentOS
  • repo == EPEL (for Puppet RPMs)
  • profile == puppet.ks (installs/enables puppetd on a kickstarted VM)
  • system == toy VMs to play around with

1. setup a distro

I did that last post using ‘cobbler import’ and a CentOS DVD.

2. setup centos and EPEL repos

Tell cobbler about CentOS (OS updates) and EPEL (puppet RPMs). On a ‘real’ system, I’d make local mirrors for consistency (—mirror-locally=1); I’m cheating to save disk and time.

cobbler repo add --name=centos5-updates
  --mirror=http://www.mirrorservice.org/sites/mirror.centos.org/5/updates/i386/
  --mirror-locally=0
cobbler repo add --name=centos5-epel
  --mirror=http://www.mirrorservice.org/sites/download.fedora.redhat.com/pub/epel/5/i386/
  --mirror-locally=0
cobbler reposync; cobbler sync

3. build a puppet.ks and profile

You can use my puppet.ks. or just tweak the latest Cobbler  one (in case they added features):

cd /var/lib/cobbler/kickstarts
cp sample.ks puppet.ks

The only differences are we add ‘puppet’ to the packagelist and enable puppet at system boot.  The puppet wiki has voodoo to set the hostname during kickstart so puppet generates a good keypair. I skipped that; puppet will do that when it starts at first boot anyway.

Next, we need to make a profile that uses this kickstart.

cobbler profile add --name=puppet
 --repos=’centos5-updates centos5-epel’ --distro=centos52-i386
 --kickstart=/var/lib/cobbler/kickstarts/puppet.ks
cobbler sync

(the  ‘–repos’ clause tells Cobbler to take care of making those repos available during kickstart).

4. define some systems and boot them

I’ll build 3 systems in cobbler  (node01, node02, and node03) by running this on shoemaker

for i in 01 02 03
do
  NAME=node$i
  cobbler system add --name=$NAME --profile=puppet --dns-name=$NAME.pixie
  cobbler system edit --name=$NAME --ip=10.0.0.2$i --mac=aa:aa:bb:bb:ff:$i
done
cobbler sync

Cobbler will sort out DNS, PXE and puppetd-enabled kickstart configs for them.

NB: you can make the puppet profile the default by running

cobbler system edit --name=default --profile=puppet

I prefer explicitly defining systems when I’m in Virtualbox, since Cobbler is managing DHCP/BIND. In my ‘real’ system, Cobbler is independant of DNS/DHCP so a default profile is probably worthwhile.

Now build 3 VMs with the right MAC addresses and boot them:

for i in 01 02 03
do
  NAME=node$i
  VBoxManage createvm -name $NAME -ostype RedHat -register
  VBoxManage modifyvm $NAME -memory 256 -boot1 disk -boot2 net -nic1 intnet -intnet1 pxeland
  # no colons in the MAC address her
  VBoxManage modifyvm $NAME -macaddress1 aaaabbbbff$i
  VBoxManage createhd -filename  $NAME.vdi -size 6000 -register
  VBoxManage modifyvm $NAME -sata on -sataport1 $NAME.vdi -sataportcount 1
  VBoxManage startvm $NAME
done

And off they go :

fly, my pretties

All three build and auto-register with puppetmaster in under 30 minutes, and I’ve got 3 puppet nodes I can carry around on my Mac along with the puppetmaster (which is handy, as I’m off to darkest West Wales tomorrow morning where dialup still rules the Earth).