Categories: Automation

How to setup Cobbler and deploy operating systems using Cobbler?

Cobbler is a Linux installation server that allows for rapid setup of network installation environments. It glues together and automates many associated Linux tasks so you do not have to hop between many various commands and applications when deploying new systems, and, in some cases, changing existing ones. It can help with provisioning, managing DNS and DHCP, package updates, power management, configuration management orchestration, and much more.

We will now learn how to install Cobbler and boot a new linux box using PXE boot.

For simplicity and testing purposes, disable SELinux. However, SELinux is an added security and it is recommended not to disable it. You may face issues with the Cobbler setup if SELinux is enforced. If you decide to keep SELinux enforced, visit https://goo.gl/2PyuBZ to ensure it works correctly in your SELinux environment.

root@cobblerhost ~]# vi /etc/sysconfig/selinux
selinux=disabled

Reboot your system after applying SELinux Changes

To install the Cobbler packages, we first need to install the EPEL repository.

root@cobblerhost ~]# rpm -ivh http://epel.mirror.net.in/epel/6/i386/epel-release-6-8.noarch.rpm

Now we will install the required packages

root@cobblerhost ~]# yum install dhcp cobbler pykickstart mod_python tftp -y

Enable xinetd tftp and rsync services

root@cobblerhost ~]# vi /etc/xinetd.d/tftp
disable = no <- Change this line to “no”

root@cobblerhost ~]# vi /etc/xinetd.d/rsync
disable = no <- Change this line to “no”

Start the xinetd, httpd, cobbler services and start the necessary services at boot time

root@cobblerhost ~]# for i in xinetd httpd cobblerd; do service $i restart; chkconfig $i on; done;
root@cobblerhost ~]# chkconfig tftp on
root@cobblerhost ~]# chkconfig rsync on

Download the network boot-loaders for cobbler

root@cobblerhost ~]# cobbler get-loaders

Change the default template of the dhcp file included with cobbler to match your network

root@cobblerhost ~]# cp /etc/cobbler/dhcp.template /etc/cobbler/dhcp.template.org

root@cobblerhost ~]# vi /etc/cobbler/dhcp.template
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.10.0 netmask 255.255.255.0 {
option routers 192.168.10.1;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.10.100 192.168.10.254;
default-lease-time 21600;
max-lease-time 43200;
next-server 192.168.10.222;
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”;
}
}

Now, we will modify the settings file.

root@cobblerhost ~]# vi /etc/cobbler/settings
manage_dhcp: 1
next_server: 192.168.10.222
server: 192.168.10.222

Mount your CentOS 6.7 DVD to a mount point, here I am mounting on /mnt

root@cobblerhost ~]# mount /dev/sr0 /mnt

Import the Distro details into cobbler using the below command.

root@cobblerhost ~]# cobbler import –path=/mnt –name=CentOS_6.7_x86_64

Copy the default anaconda-ks.cfg to the default location of cobbler kickstart files

root@cobblerhost ~]# cp anaconda-ks.cfg /var/lib/cobbler/kickstarts/centos67.ks

Modify the centos67.ks file to the following or according to your requirement

root@cobblerhost ~]# vi /var/lib/cobbler/kickstarts/centos67.ks
install
url –url http://192.168.10.222/cobbler/ks_mirror/CentOS_6.7_x86_64/
lang en_US.UTF-8
zerombr
keyboard us
network –onboot yes –device eth0 –bootproto dhcp –noipv6
rootpw –iscrypted $6$4t6CgzQlwQKVFUEb$.mWJx35kMLobSabwpoKzlVpTvmTjxapy5GjSJdWkWANgV9J0SE4tm/oYMQjOYFdAyp5FgpevxXmzyy5/3xcHS.
firewall –service=ssh
authconfig –enableshadow –passalgo=sha512
selinux –enforcing
timezone Asia/Kolkata
bootloader –location=mbr –driveorder=sda –append=”crashkernel=auto rhgb quiet”

clearpart –linux –drives=sda
repo –name=”CentOS” –baseurl=cdrom:sr0 –cost=100
%packages –nobase
@core
%end

Add the distro information to the cobbler for PXE Boot

root@cobblerhost ~]# cobbler distro add –name=CentOS_6.7_x86_64 –kernel=/var/www/cobbler/ks_mirror/CentOS_6.7_x86_64/isolinux/vmlinuz –initrd=/var/www/cobbler/ks_mirror/CentOS_6.7_x86_64/isolinux/initrd.img

Add the kickstart profile to the distro

root@cobblerhost ~]# cobbler profile add –name=CentOS_6.7_KS –distro=CentOS_6.7_x86_64 –kickstart=/var/lib/cobbler/kickstarts/centos67.ks

Restart and synchronize the changes that were made into cobbler

root@cobblerhost ~]# service cobblerd restart
root@cobblerhost ~]# cobbler sync

Configure the firewall to allow ports 80 (HTTP) and 69 (TFTP)

root@cobblerhost ~]# iptables -I INPUT -p tcp -s 192.168.75.0/24 -d 192.168.75.222 –dport 80 -j ACCEPT
root@cobblerhost ~]# iptables -I INPUT -p udp -s 192.168.75.0/24 -d 192.168.75.222 –dport 69 -j ACCEPT
root@cobblerhost ~]# service iptables save

Restart the below services once again to make sure all the changes are applied to the services

root@cobblerhost ~]# for i in xinetd httpd cobblerd; do service $i restart; chkconfig $i on; done;

Boot a new linux box and make sure it boots via Network and at the menu prompt select the CentOS_6.7_KS option

Nitesh Shah

Share
Published by
Nitesh Shah

Recent Posts

How to setup first Azure Virtual Machine?

Setting up your first Azure Virtual Machine can be done by following these steps: Create…

1 year ago

How to setup Amazon Cloudfront and S3 to serve static resources

Amazon CloudFront is a content delivery network (CDN) that helps you serve static content such…

1 year ago

Step-By-Step Guide To Setting Up An AWS Application Load Balancer

Step-By-Step Guide To Setting Up An AWS Application Load Balancer Are you looking for a…

1 year ago

How to restore MySQL database from .frm and .ibd files?

MySQL databases often get corrupted due to issues like hardware failure, file system failure etc.…

4 years ago

SQL Server Replication

SQL Server Replication is the process of copying databases from one node to another to…

5 years ago

101 System Admin Tools to make life easy

Here are 101 System Admin tools which make System Admins' life easy.

7 years ago

This website uses cookies.