A Guide to Writing Fedora Kickstart Files: Automate Dozens of Server Installs in Under an Hour

Fedora tutorial - IT technology blog
Fedora tutorial - IT technology blog

The Nightmare of Setting Up 30 Bare-Metal Servers in a Freezing Server Room

Late last quarter, our team received a batch of 30 Dell PowerEdge R650 servers to build out an on-prem lab cluster and dedicated CI/CD runners. The assignment sounded routine enough: install Fedora Server on every node, configure LVM storage, create an administrative user, and inject SSH keys.

In reality, it turned into an agonizing time sink.

On day one, a junior engineer and I hauled a bootable USB drive from rack to rack, plugging it into the rear ports of each chassis. We took turns babysitting the Anaconda graphical installer, clicking “Next” through screen after screen. Typing passwords, setting the timezone to Asia/Ho_Chi_Minh, and carving out disk partitions—over and over, for 30 consecutive iterations. It took two full, exhausting days just to get the base OS running across the cluster.

By day three, real trouble hit when we triggered our Ansible playbooks to bootstrap the environment. Node 07 was missing the vim-enhanced package. On Node 14, someone had mistyped the default gateway as 10.0.1.1 instead of 10.0.10.1, cutting off its network access entirely. Node 22 had the SSH service disabled. Manual installations don’t just drain your energy—they inevitably breed human error and configuration drift.

Why GUI Installations Break Down at Scale

The issue isn’t a lack of attention to detail. The failure lies in the inherent flaws of manual operations:

  • Lack of Reproducibility: Every mouse click requires a human decision. A single missed checkbox means Node 01 and Node 30 are no longer identical.
  • Wasted Idle Time: Writing packages to NVMe drives takes roughly 8 to 12 minutes per machine. You are effectively stranded beside the rack just waiting to click the final “Reboot” button.
  • Zero Integration with Modern Infrastructure: Modern infrastructure demands reproducibility via code (IaC). You cannot reliably scale to 50 or 100 nodes if your workflow still hinges on manually shuffling USB drives.

Common Approaches and Their Real-World Trade-Offs

When tackling this challenge, infrastructure engineers typically look into three common paths:

1. Ghost / Disk Cloning (Clonezilla, dd)

The traditional route: configure a clean “golden image” server, then clone raw disk blocks directly to destination drives.

  • Pros: Fast deployment speeds when disk images are small.
  • Cons: Extremely rigid. The target drive must be identical to or larger than the source drive. On top of that, you must run cleanup scripts to wipe Machine IDs (/etc/machine-id), remove stale SSH host keys, and reset MAC address configurations to prevent IP conflicts on the local network.

2. Cloud-Init

If you provision virtual machines on Proxmox, VMware, or AWS, Cloud-Init is the industry standard for Day 0 configuration injection.

  • Pros: Clean YAML syntax, highly modular, and widely supported.
  • Cons: Cannot be used directly to install a clean base OS onto bare-metal physical servers straight from stock ISO installation media.

3. Kickstart Files: The Native Solution for the Red Hat Ecosystem

Kickstart is the native unattended installation mechanism built right into the Anaconda installer used by Red Hat Enterprise Linux, CentOS, and Fedora. Every setting—from disk partitioning and network configurations to user accounts and post-installation scripts—is declared in a single plain text file (traditionally named ks.cfg). During boot, Anaconda parses this file and executes the installation from start to finish without requiring human intervention.

Crafting a Production-Ready Kickstart File for Fedora Server

After numerous bare-metal rollouts, I refined a clean, dependable Kickstart template that supports both modern UEFI booting and practical LVM partitioning for enterprise environments.

Step 1: Write the ks.cfg Configuration File

Whenever you finish installing any Fedora machine, the installer automatically dumps a reference configuration at /root/anaconda-ks.cfg. It serves as an excellent starting point. Taking cues from that file, I stripped away interactive elements and crafted this fully automated template:

# Non-interactive installation mode
text
skipx

# Language and keyboard settings
lang en_US.UTF-8
keyboard us
timezone Asia/Ho_Chi_Minh --utc

# Installation package source (use public mirrorlist or local mirror IP)
url --mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=fedora-$releasever&arch=$basearch

# Auto-configure network interface via DHCP
network --bootproto=dhcp --device=link --activate --onboot=on

# Firewall and SELinux configuration
firewall --enabled --service=ssh
selinux --enforcing

# Wipe existing partition tables
zerombr
clearpart --all --initlabel

# UEFI and LVM partition layout
part /boot/efi --fstype="efi" --size=600
part /boot --fstype="ext4" --size=1024
part pv.01 --fstype="lvmpv" --grow --size=1

volgroup vg_system pv.01
logvol swap --vgname=vg_system --name=lv_swap --recommended
logvol / --vgname=vg_system --name=lv_root --fstype="xfs" --size=25600
logvol /var --vgname=vg_system --name=lv_var --fstype="xfs" --grow --size=20480

# SHA-512 hashed passwords (generate with: openssl passwd -6 "YourPassword")
rootpw --iscrypted $6$rounds=4096$saltstring$randomhashvaluehere...
user --name=devops --groups=wheel --iscrypted --password=$6$rounds=4096$saltstring$userhashvaluehere...

# Package selection list
%packages
@^server-product-environment
@standard
curl
wget
vim
tmux
git
htop
chrony
-nano
-plymouth
%end

# Post-installation script executed immediately after OS install
%post --log=/var/log/kickstart_post.log
echo "=== Running post-installation setup ==="

# Add SSH public key for devops user
mkdir -p /home/devops/.ssh
cat << 'EOF' > /home/devops/.ssh/authorized_keys
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGx9eExampleKeyForDevOpsTeamMasterKey [email protected]
EOF
chmod 700 /home/devops/.ssh
chmod 600 /home/devops/.ssh/authorized_keys
chown -R devops:devops /home/devops/.ssh

# Grant passwordless sudo privileges to devops user for seamless Ansible bootstrapping
echo "devops ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/devops
chmod 0440 /etc/sudoers.d/devops

# Boost DNF download throughput
echo "fastestmirror=True" >> /etc/dnf/dnf.conf
echo "max_parallel_downloads=10" >> /etc/dnf/dnf.conf
%end

# Automatically reboot once installation finishes
reboot

Step 2: Validate Syntax Using ksvalidator

Never rush an unvalidated Kickstart file into production. A single typo or invalid directive will cause Anaconda to halt abruptly and fall back to interactive prompts. To avoid wasted cycles, validate your file beforehand using pykickstart:

sudo dnf install -y pykickstart
ksvalidator -v F39 ks.cfg

If the command exits cleanly without printing red error lines, your file’s command structure is syntactically sound.

Step 3: Feed the Kickstart File to the Server at Boot Time

Depending on your network environment, choose one of the following two deployment methods:

Method 1: Fetch via Local HTTP (Recommended for Connected LANs)

On your workstation, spin up a quick, temporary web server directly inside the directory where ks.cfg is saved:

python3 -m http.server 8080

Boot the target server from the Fedora installation media via USB or virtual media in iDRAC/iLO. At the GRUB boot menu, press e (for UEFI) or Tab (for Legacy BIOS). Locate the line starting with linuxefi (or vmlinuz) and append the following kernel boot parameter to the end:

inst.ks=http://192.168.1.100:8080/ks.cfg

Press Ctrl + X to boot. The server will lease an IP address via DHCP, download the ks.cfg payload, partition its drives, install selected packages, and reboot automatically. You won’t have to touch the keyboard again.

Method 2: Embed Directly into a Bootable USB (Ideal for Air-Gapped Networks)

When operating inside an isolated, air-gapped lab with no reachable DHCP or local web server, rename your USB drive filesystem label to OEMDRV and drop the ks.cfg file directly into its root directory. Anaconda automatically checks any mounted volume with this specific label for Kickstart files during initial startup.

Alternatively, you can reference the drive label explicitly from the GRUB boot prompt:

inst.ks=hd:LABEL=FEDORA_USB:/ks.cfg

The Real-World Payoff

By transitioning to Kickstart, our team slashed rollout times for 30 physical servers from two grueling days down to just 40 minutes. Every single node was 100% consistent across partition schemes, local accounts, and authorized SSH keys. Subsequent Ansible bootstrap runs executed flawlessly on the very first try without hitting odd, edge-case bugs. If you maintain Fedora or RHEL server clusters, building a standard Kickstart file today will save you hours down the road.

Share: