CentOS 6 Cobbler Server
Introduction
This article will be a step-by-step guide of how to set up a Cobbler server on CentOS 6. Once the server is complete, you will be able to have CentOS 6 automatically installed onto client computers when they are PXE booted on a private network.
Table of Contents
Server and Environment Attributes
I used a VMWare virtual machine for the server. The VMWare environment has two networks: a public and private. The Public network had full access to the Internet while the private was a standard host-only network.
The VMWare virtual machine had two NICs — one for the public and one for the private.
The purpose of the two networks is to allow clients to initially boot up in the private network where Cobbler will handle the installation. Since Cobbler utilizes DHCP and TFTP, making these services listen on a Private network will ensure that they don’t interfere with any other DHCP or TFTP server on the Public network. Once the installation has finished, the client can be moved to the Public network.
Installation
Use any CentOS 6 installation medium you wish.
Network
For the Network Configuration, I renamed System eth0 and System eth1 to Public and Private respectively. I configured each NIC with static information and made sure to check the Connect Automatically checkbox for each — otherwise NetworkManager will not bring the NICs up.
Package Selection
I chose Minimal Desktop.
Post-Install Steps
Disable the Firewall
It’s possible to have the firewall running — you just need to ensure that the proper ports are opened. For simplicity, and since this server is in a private network, I chose to have the firewall turned off.
You can disable the firewall by doing:
$ system-config-firewall-tui
and unselecting “Enabled”
Disable SELinux
I tried to have Cobbler run properly with SELinux, but in the end, I could not get the two to work together. If anyone has success with this, please let me know.
You can disabled SELinux by editing the /etc/sysconfig/selinux file and changing:
SELINUX=enforcing
to
SELINUX=disabled
and then rebooting.
Perform a Software Update
Before proceeding further, make sure everything is up to date:
$ yum update
Install VMWare tools
This step is only required if you are using VMWare.
Create the file /etc/yum.repos.d/vmware.repo with the following contents:
[vmware-tools] name=VMware Tools for Red Hat Enterprise Linux $releasever – $basearch baseurl=http://packages.vmware.com/tools/esx/4.1/rhel6/x86_64 enabled=1 gpgcheck=0
Change the x86_64 to i686 if you need to.
Next, run:
$ yum install vmware-tools
Install EPEL
The EPEL RPM repository contains extra packages, such as Cobbler, for RHEL/CentOS.
Run the following:
$ rpm -Uhv http://download.fedora.redhat.com/pub/epel/6/i386/epel-release-6-5.noarch.rpm
Enable NAT
The following steps will turn the server into a network gateway which will allow clients on the Private side to reach the Internet through the Public side. This allows for network-based installs.
Add the following IPTables rules:
$ /sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE $ /sbin/iptables -A FORWARD -i eth0 -o eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT $ /sbin/iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT
Next, ensure these rules are saved:
$ /etc/init.d/iptables save $ /etc/init.d/iptables restart
Finally, edit /etc/sysctl.conf:
net.ipv4.ip_forward = 1
If you do not want to reboot for this to take effect, run:
$ echo 1 > /proc/sys/net/ipv4/ip_forward
Install and Configure Cobbler
Finally it’s time to install Cobbler.
$ yum install cobbler cobbler-web pykickstart
Ensure some required services will start at boot:
$ chkconfig httpd on $ chkconfig xinetd on $ chkconfig cobblerd on $ service httpd start $ service xinetd start $ service cobblerd start
For this setup, I will use dnsmasq for DNS and DHCP. The following changes need made in /etc/cobbler/modules.conf
[dns] module = manage_dnsmasq [dhcp] module = manage_dnsmasq
Edit /etc/cobbler/dnsmasq.template and add the following:
server=192.168.1.1 no-dhcp-interface=eth0
Make sure server is set to your upstream DNS resolver. The no-dhcp-interface will ensure the DHCP server does not run on the Public network.
Also change dhcp-range to an appropriate IP range for your Private network.
Finally, restart Cobbler and have it tell you if anything else is needed to be configured:
$ /etc/init.d/cobblerd restart $ cobbler check
When everything looks good, run
$ cobbler sync
Add a Distro to Cobbler
For this configuration, I will use a CentOS 6 netinst ISO.
First, mount the ISO:
$ mount /dev/cdrom /mnt
Next, import it into Cobbler:
$ cobbler import cobbler import --name=CentOS6 --path=/mnt
This will return an error. This is OK since it is not a full distribution ISO.
Finish the import:
$ cobbler distro add --arch=x86_64 --breed=redhat --name=CentOS6 --initrd=/var/www/cobbler/ks_mirror/CentOS6/isolinux/initrd.img --kernel=/var/www/cobbler/ks_mirror/CentOS6/isolinux/vmlinuz
Generate a Base Kickstart File
In order to perform an automated install, a Kickstart file is needed. You can create an initial file by using the system-config-kickstart utility:
$ yum install system-config-kickstart
This is a graphical utility so you will need to be logged into X.
You can also use my base file. This has been configured to use Cobbler’s network configuration snippets. The encrypted password is just “password”.
Create a Cobbler Profile
Profiles connect Distributions with Kickstart files. Here we can make a standard CentOS6 profile:
$ cobbler profile add --name=CentOS6-Base --distro=CentOS6 --kickstart=/var/lib/cobbler/kickstarts/centos6.ks
Create a Cobbler System
Systems are individual machines complete with IP addresses and MAC addresses. I prefer to use the Cobbler Web Interface to add systems.
If you are using VMWare, create a new virtual machine and either make note of the generated MAC address or generate your own. If you are using a physical server, make note of the MAC. You can then configure your system in Cobbler to use that MAC. This will ensure that any system-specific options (such as IP address) are only configured for that system.
Once the system is added, be sure to sync Cobbler either through the web interface or on the command line:
$ cobbler sync
Now, PXE boot your client on the Private network. DHCP and TFTP should take over and an automated install should begin.
Extra: Polipo
Although it is possible to have Cobbler mirror various repositories, I prefer to only download what is needed. If you configure Kickstart to use a caching proxy server, you can use cached RPMs to install on multiple servers. This way, once the RPMs are cached, future installs will only take a few minutes — no RPMs will need to be downloaded from the Internet.
I am currently using Polipo to handle this since my own automirror will not work with CentOS 6.
Note: As of RHEL6, a new --proxy option is available to Kickstart files to enable the use of a proxy. Before this, if you wanted to use a proxy, you had to use a “tunneling” method as described in automirror.
Install and Configure Polipo
To install Polipo, just do:
$ yum install polipo
To configure, edit the /etc/polipo/config file:
proxyAddress = "::0" disableIndexing = false disableServersList = false
Next, create the file /etc/polipo/uncachable with the contents:
\.xml$
This should ensure that XML files are not cached. This way up-to-date RPM repository data is obtained during installs.
Once that’s all done, edit the Kickstart file to utilize the proxy. This can be seen in the sample Kickstart file linked above.
Conclusion
This article walked through the process of setting up a Cobbler server that will be able to provide automatic installations of CentOS 6 clients.

Delicious Bookmarks for August 15th from 06:19 to 07:01 « Lâmôlabs said,
[...] CentOS 6 Cobbler Server » Terrarum – August 15th ( tags: cobbler centos sysadmin linux kickstart automation pxe reference ) August 15th, 2011, @ 5:01 am | Tags: links | Category: delicious links | Comments are closed | Trackback this Post | 0 views [...]
Cobbler 的使用 | Jasey Wang said,
[...] 这里是一篇如何使用 cobbler 安装 CentOS 6 的教程。 [...]
Add A Comment