Cobbler and kickstart on CentOS 6 linux

Prerequisites
vi /etc/sysconfig/selinux
SELINUX=disabled

or
sed -i 's/SELINUX\=enforcing/SELINUX\=disabled/g'/etc/selinux/config

Turn off the iptables.
service iptables stop
chkconfig iptables off

Or Allow the following ports, if you want it enabled.
vi /etc/sysconfig/iptables

#Allow the http ports(80/443), Cobbler’s ports 69, and 25151.

-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 69 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 25151 -j ACCEPT

Installation

Cobbler is not available on CentOS default repositories, so let us add EPEL repository first, and install Cobbler.
yum install epel-release

Now, install cobbler, cobbler web interface ,and its dependencies as shown below.
yum -y install cobbler cobbler-web dhcp pykickstart system-config-kickstart mod_python tftp wget cman

Enable TFTP and rsync

vi /etc/xinetd.d/tftp #change disable = yes to disable = no

vi /etc/xinetd.d/rsync #change disable = yes to disable = no

Restart xinetd Now we can restart xinetd to make the changes take affect.
/etc/init.d/xinetd restart

Start xinetd on boot
/sbin/chkconfig xinetd on

Start cobbler services Now lets start the apache webserver (httpd), and cobbler itself. Apache is required by cobbler to serve up the OS images.
/etc/init.d/httpd start
/etc/init.d/cobblerd start
/sbin/chkconfig httpd on
/sbin/chkconfig cobblerd on

Configure Cobbler

Generate a password hash
openssl passwd -1 -salt ‘random-phrase-here’ ‘your-password-here’

I get the hash below for the password motorrobot
openssl passwd -1 -salt

vi /etc/cobbler/settings
Change: next_server: 127.0.0.1 to next_server: 192.168.1.64
Change: server: 127.0.0.1 to server: 192.168.1.64
Change: default_password_crypted: “$1$mF86/UHC$WvcEcX3s9crCz2inWryabc.” to above generated hash default_password_crypted: “$1$centosho$06Gedn1z8BjSu2ZbV4fS.0″
Change: manage_dhcp: 0 to manage_dhcp: 1

sed -i ‘s/server\:\ 127\.0\.0\.1/server\:\ 192\.168\.1\.64/g’ /etc/cobbler/settings
sed -i ‘s/default\_password\_crypted\:\ \”\$1\$mF86\/UHC\$WvcEcX3s9crCz2inWryabc\.\”/default\_password\_crypted\:\ \”\$1\$centosho\$06Gedn1z8BjSu2ZbV4fS\.0\”/g’ /etc/cobbler/settings
sed -i ‘s/manage_dhcp: 0/manage_dhcp: 1/g’ /etc/cobbler/settings

Now, edit file /etc/cobbler/dhcp.template,

vi /etc/cobbler/dhcp.template
ddns-update-style interim;

allow booting;
allow bootp;

ignore client-updates;
set vendorclass = option vendor-class-identifier;

option pxe-system-type code 93 = unsigned integer 16;

subnet 192.168.1.0 netmask 255.255.255.0 {
    option routers             192.168.1.99;
    option domain-name-servers 192.168.2.31,192.168.2.32;
    option subnet-mask         255.255.255.0;
    range dynamic-bootp        192.168.1.150 192.168.1.250;
    default-lease-time         21600;
    max-lease-time             43200;
    next-server                $next_server;
    class "pxeclients" {
         match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
         if option pxe-system-type = 00:02 {
                 filename "ia64/elilo.efi";
         } else if option pxe-system-type = 00:06 {
                 filename "grub/grub-x86.efi";
         } else if option pxe-system-type = 00:07 {
                 filename "grub/grub-x86_64.efi";
         } else {
                 filename "pxelinux.0";
         }
    }
}

Next, we should enable Cobbler’s web interface, and set username and password for Cobbler’s web interface.

To enable, Cobbler’s web interface, edit file /etc/cobbler/modules.conf,

vi /etc/cobbler/modules.conf
[authentication]
module = authn_configfile

[authorization]
module = authz_allowall

Next, we have to setup the setup the username and password for the cobbler web interface. To do that, run the following command. Input your preferred password twice.
htdigest /etc/cobbler/users.digest "Cobbler" cobbler

Download the required network boot loaders using the following command.
cobbler get-loaders

cobbler check
/etc/init.d/cobblerd restart
cobbler sync

Importing multiple CentOS Linux DVDs into Cobbler

Linux distributions are getting larger and larger; CentOS 6.0 64-bit won’t fit on a single DVD anymore. A Cobbler-based provisioning server will normally import only one DVD. So, how do you get around this?
Import the first DVD as usual
Manually add content from the second DVD

Import the first DVD (ISO image):
mkdir /mnt/dvd1; mount -o ro,loop /tmp/CentOS-6.6-x86_64-bin-DVD1.iso /mnt/dvd1

DISTRO=centos66
cobbler import --name=${DISTRO} --arch=x86_64 --path=/mnt/dvd1

Watch the output from Cobbler closely – it will basically shows you the commands you need to import the second DVD

Import the second DVD (ISO image):
mkdir /mnt/dvd2; mount -o ro,loop /tmp/CentOS-6.6-x86_64-bin-DVD2.iso /mnt/dvd2

rsync -a '/mnt/dvd2/' /var/www/cobbler/ks_mirror/${DISTRO} --exclude-from=/etc/cobbler/rsync.exclude --progress
COMPSXML=$(ls /var/www/cobbler/ks_mirror/${DISTRO}/repodata/*comps*.xml)
createrepo -c cache -s sha --update --groupfile ${COMPSXML} /var/www/cobbler/ks_mirror/${DISTRO}

Adding Kickstart file to Cobbler server

vi /var/lib/cobbler/kickstarts/centos65test.ks

url --url http://192.168.1.80/cobbler/ks_mirror/centos66-x86_64/

And then, add the kickstart file(centos65test.ks) to the pxe server.
cobbler profile add --name=CentOS_6.5_KS --distro=CentOS_6.5 --kickstart=/var/lib/cobbler/kickstarts/centos65test.ks

Restart cobbler once again, and run “cobble sync” command to save the changes.
service cobblerd restart
cobbler sync

Local repo on cobbler server

vi /etc/yum.repos.d/centos-6.6-local.repo
[Centos-6.6-local]
name=CentOS 6.5 local repository
baseurl=http://192.168.1.80/cobbler/ks_mirror/centos66-x86_64/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=1

Leave a comment

You must be logged in to post a comment.