Building the Server Deployment Assembly Line
Manually installing an operating system is acceptable for one or two machines. In an enterprise, where you might need to deploy dozens or hundreds of identical servers, it is slow, inefficient, and prone to human error. Kickstart is the Red Hat technology that completely automates the CentOS/RHEL installation process. It allows you to create a single configuration file that answers all the installer's questions, enabling fully unattended, consistent, and rapid server deployments at scale.
The Kickstart Philosophy: The Car Assembly Line
A manual installation is like building a car by hand—every car will be slightly different. A Kickstart installation is like a modern robotic assembly line. You provide the blueprint (the Kickstart file), and the factory (the network boot environment) builds a perfect, identical car every single time.
The Architectural Overview
A Kickstart deployment relies on a network boot process called **PXE (Preboot Execution Environment)**. The client machine boots up with no OS, gets its instructions from the network, and installs itself automatically. This requires four key server components:
The PXE Boot & Kickstart Flow
1. DHCP Server
Tells the new client its IP address and where to find the boot files.
2. TFTP Server
Provides the initial bootloader and kernel that the client loads into memory.
3. HTTP/NFS Server
Hosts the Kickstart file and the entire OS installation repository.
4. Client Machine
Boots from the network, follows the Kickstart blueprint, and installs itself.
The Blueprint: The Kickstart (`ks.cfg`) File
The Kickstart file is the heart of the process. It's a simple text file that contains the answers to every question in the Anaconda installer. A basic Kickstart file for a minimal CentOS server looks like this:
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# System authorization information
auth --enableshadow --passalgo=sha512
# Use CD/DVD installation media
#url --url="http://192.168.1.210/centos8" <-- We will use this in the lab
cdrom
# Use graphical install
graphical
# Run the Setup Agent on first boot
firstboot --enable
# Keyboard layouts
keyboard --vckeymap=us --xlayouts='us'
# System language
lang en_US.UTF-8
# Network information
network --bootproto=dhcp --device=enp0s3 --onboot=on --ipv6=auto --activate
network --hostname=kickstart-client
# Root password (use 'openssl passwd -1' to generate a hash)
rootpw --iscrypted $1$a/b/c/d$eFGHIJKLMNOPQRSTUV
# System services
services --enabled="chronyd,sshd"
# System timezone
timezone America/New_York --isUtc
# System bootloader configuration
bootloader --location=mbr --boot-drive=sda
autopart --type=lvm
# Clear the Master Boot Record
zerombr
%packages
@^server-product-environment
kexec-tools
%end
%addon com_redhat_kdump --enable --reserve-mb=auto
%end
%post --log=/root/ks-post.log
# Post-installation script goes here
echo "Kickstart installation complete!" > /etc/motd
%end
Key Sections of the Kickstart File
- Command Section: The top part that defines system settings like language, keyboard, network, and the root password. The `url` or `cdrom` directive tells the installer where to find the OS packages.
- `%packages` Section: Defines which software packages and groups to install. `@^server-product-environment` installs the standard "Server" set of tools.
- `%post` Section: An incredibly powerful feature. This section contains a shell script that runs on the new system *after* the installation is complete but *before* the first reboot. It's used for custom configuration, like adding users, hardening security, or installing specific application software.
Scenario: You will configure your primary CentOS server to act as a Kickstart server to automatically deploy a new, minimal CentOS VM.
- Step 1: Configure the HTTP Server (on your Kickstart Server)
- Install Apache:
sudo dnf install -y httpd - Create directories to hold the repository and the Kickstart file:
sudo mkdir -p /var/www/html/centos8 sudo mkdir /var/www/html/kickstart - Copy the entire contents of a CentOS 8 installation ISO to `/var/www/html/centos8`. You can do this by mounting the ISO:
sudo mount /dev/sr0 /mnt sudo cp -r /mnt/* /var/www/html/centos8/ sudo umount /mnt - Create your Kickstart file at
/var/www/html/kickstart/ks.cfgusing the example above. Remember to set a real encrypted password! - Start and enable the web server:
sudo systemctl enable --now httpd - Open the firewall:
sudo firewall-cmd --add-service=http --permanent && sudo firewall-cmd --reload
- Install Apache:
- Step 2: Configure DHCP and TFTP (on your Kickstart Server)
- Install the required services:
sudo dnf install -y dhcp-server tftp-server syslinux-tftpboot - Configure your DHCP server (
/etc/dhcp/dhcpd.conf) to point clients to the TFTP server. - Copy the PXE boot files to the TFTP directory:
sudo cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot - Create a PXE boot menu configuration (
/var/lib/tftpboot/pxelinux.cfg/default) that points to the kernel and initrd files from your repository and tells it where to find the Kickstart file via the network (e.g.,inst.ks=http://192.168.1.210/kickstart/ks.cfg). - Start the services and open the firewall for them.
- Install the required services:
- Step 3: Deploy the Client
- Create a new, blank virtual machine with no OS installed.
- Configure the VM to boot from the network (PXE boot) instead of a hard drive or CD-ROM.
- Power on the VM.
- The Result: If everything is configured correctly, the new VM will power on, get an IP from your DHCP server, download the bootloader from TFTP, read the boot menu, and then begin a fully automated installation, pulling the OS packages and the Kickstart configuration from your HTTP server. You can walk away and come back in 10 minutes to a fully installed and configured server.