Operations 19 min read

Automate Large-Scale Server Installations with Cobbler: A Step‑by‑Step Guide

This guide explains how to use Cobbler, an automated provisioning tool, to streamline large‑scale OS installations on servers, covering installation, configuration of DHCP/TFTP/RSYNC, creating repos, managing distros and profiles, and deploying CentOS via PXE with practical command examples.

Efficient Ops
Efficient Ops
Efficient Ops
Automate Large-Scale Server Installations with Cobbler: A Step‑by‑Step Guide

In daily operations, installing operating systems on a large number of servers can be tedious and error‑prone. Cobbler is introduced as an automated deployment tool that simplifies network installations for Linux (and, with adjustments, Windows) and can also create internal Yum repositories.

Cobbler Overview

Cobbler is a fast network installation service written in Python (about 15k lines). It configures PXE environments, manages DHCP, DNS, TFTP, RSYNC, Yum repositories, and can build ISO images. It offers command‑line, web UI, and API interfaces, and the Koan client supports VM installations and OS re‑installation.

Cobbler Features

Configure DHCP using predefined templates.

Create repository mirrors (Yum or Rsync) and register new OS images.

Generate appropriate PXE files in the TFTP directory.

Restart DHCP service to apply changes.

Reboot machines to start installation (if power management is enabled).

Preparing the Lab Environment

<code>[root@cobbler-node1 ~]# cat /etc/redhat-release
#系统版本CentOS Linux release 7.1.1503 (Core)
[root@cobbler-node1 ~]# uname -r
#内核版本3.10.0-229.el7.x86_64
[root@cobbler-node1 ~]# getenforce
#检测selinux是否关闭(必须关闭)Disabled
[root@cobbler-node1 ~]# systemctl stop firewalld
#关闭防火墙
[root@cobbler-node1 ~]# ifconfig eth0|awk -F '[ :]+' 'NR==2 {print $3}'
#查看IP地址10.0.0.101
[root@cobbler-node1 ~]# hostname
#查看主机名cobbler-node1
[root@cobbler-node1 ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
#cobbler安装必须使用到epel源</code>
Tip: Use NAT mode for the VM network card because a DHCP server will be set up; multiple DHCP servers on the same LAN can cause conflicts.

Installing Cobbler

<code>[root@cobbler-node1 ~]# yum install cobbler cobbler-web pykickstart httpd tftp dhcp xinetd</code>

RPM package details:

cobbler: main program cobbler-web: web interface pykickstart: kickstart syntax checker httpd: Apache web server tftp: TFTP service dhcp: DHCP service

Cobbler Directory Structure

<code>/etc/cobbler                  # configuration files
/etc/cobbler/settings         # main settings file
/etc/cobbler/dhcp.template    # DHCP template
/etc/cobbler/tftpd.template   # TFTP template
/etc/cobbler/rsync.template   # Rsync template
/etc/cobbler/iso              # ISO templates
/etc/cobbler/pxe              # PXE templates
/etc/cobbler/power            # power management configs
/etc/cobbler/users.conf       # web service auth config
/var/lib/cobbler              # data directory
/var/www/cobbler              # installation images
/var/log/cobbler              # logs
</code>

Testing Cobbler

Cobbler depends on DHCP, TFTP, Rsync, and DNS services. These can be provided by isc‑dhcpd, dnsmasq, tftp‑server, rsync, and bind.

<code>[root@cobbler-node1 ~]# systemctl start httpd
[root@cobbler-node1 ~]# systemctl start cobblerd
[root@cobbler-node1 ~]# cobbler check
# Output shows configuration items to fix, e.g., set 'server' and 'next_server' to proper IPs, enable TFTP, install missing loaders, start rsyncd, etc.
</code>

Fixing Common Issues

<code>1. sed -i 's/server: 127.0.0.1/server: 10.0.0.7/' /etc/cobbler/settings
2. sed -i 's/next_server: 127.0.0.1/next_server: 10.0.0.7/' /etc/cobbler/settings
3. Edit /etc/xinetd.d/tftp to set "disable = no"
4. cobbler get-loaders   # or install syslinux and copy loaders
5. systemctl enable rsyncd
6. yum -y install debmirror   # if Debian support is needed
7. Update default_password_crypted in /etc/cobbler/settings
8. yum -y install cman fence-agents
systemctl restart cobblerd</code>

Configuring DHCP

<code>[root@cobbler-node1 ~]# sed -i 's#manage_dhcp: 0#manage_dhcp: 1#g' /etc/cobbler/settings
# Edit /etc/cobbler/dhcp.template, e.g.:
subnet 10.0.0.0 netmask 255.255.255.0 {
    option routers 10.0.0.2;
    option domain-name-servers 10.0.0.2;
    option subnet-mask 255.255.255.0;
    range dynamic-bootp 10.0.0.200 10.0.0.250;
    default-lease-time 21600;
    max-lease-time 43200;
    next-server $next_server;
}</code>

Synchronizing Cobbler

<code>[root@cobbler-node1 ~]# systemctl restart xinetd
[root@cobbler-node1 ~]# systemctl restart cobblerd
[root@cobbler-node1 ~]# cobbler sync
# Task output shows cleaning trees, copying bootloaders, generating PXE configs, rendering DHCP/TFTP files, and restarting services.
</code>

Managing Cobbler

Managing Distros

Define a distro by importing an installation tree or ISO. Example:
<code>[root@cobbler-node1 ~]# mount /dev/cdrom /mnt/
[root@cobbler-node1 ~]# cobbler import --path=/mnt/ --name=CentOS-7.1-x86_64-distro --arch=x86_64</code>

Managing Profiles

<code>[root@cobbler-node1 ~]# cobbler profile edit --name=Centos7.1-distro-x86_64 --kickstart=/var/lib/cobbler/kickstarts/Cobbler-CentOS-7.1-x86_64.cfg
# For CentOS 7, disable predictable network names:
[root@cobbler-node1 ~]# cobbler profile edit --name=Centos7.1-distro-x86_64 --kopts='net.ifnames=0 biosdevname=0'
# Add internal Yum repo and sync:
[root@cobbler-node1 ~]# cobbler repo add --name=centos-7-base --mirror=http://mirrors.aliyun.com/centos/7/os/x86_64/Packages/ --arch=x86_64 --breed=yum
[root@cobbler-node1 ~]# cobbler reposync
[root@cobbler-node1 ~]# cobbler sync</code>

Managing Systems

<code>[root@cobbler-node1 ~]# cobbler system add --name=xuliangwei-pc --mac=00:0C:29:6E:41:CB \
    --profile=Centos7.1-profile-x86_64 \
    --ip-address=10.0.0.110 --subnet=255.255.255.0 \
    --gateway=10.0.0.2 --interface=eth0 \
    --static=1 --hostname=EC.com \
    --name-servers="114.114.114.114 8.8.8.8"
[root@cobbler-node1 ~]# cobbler sync
[root@linux-node1 ~]# cobbler system list</code>

Customizing Installation

Use kickstart files or MAC‑based rules to assign specific configurations, such as fixed IP, hostname, and DNS. Cobbler can also customize the boot menu and login screen via templates.

Web Management

The web interface is accessed via HTTPS (e.g., https://10.0.0.7/cobbler_web). Authentication can be configured using authn_pam, authn_configfile, or the default cobbler credentials (user: cobbler, pass: cobbler).

authn_pam – uses PAM accounts.

authn_configfile – uses a digest file.

Default – user "cobbler" with password "cobbler".

linuxPXEServer ProvisioningAutomated DeploymentCobbler
Efficient Ops
Written by

Efficient Ops

This public account is maintained by Xiaotianguo and friends, regularly publishing widely-read original technical articles. We focus on operations transformation and accompany you throughout your operations career, growing together happily.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.