Getting started with RHEL Kickstart files

RedHat and its derivatives can utilize special configuration files called “Kickstart files” to make installation automated and repeatable. I wanted to explore this for my RHEL Migration project where I am moving from CentOS 7 to RHEL 8.

Obtaining a basic configuration

The simplest way to get a basic Kickstart file is to install your distro like you normally would then copy the anaconda-ks.cfg file that is generated by the installer (called Anaconda) and left in /root on your new system. This file contains the parameters that you chose during your graphical setup process. It holds all settings including:

  • Package selection
  • Keyboard layout and language selection
  • Network configurations
    • Hostname
    • Static/DHCP settings
  • Disk layouts
  • Timezone
  • Root password and optional user configurations
  • Password policies

Changes you can make to the Kickstart file

Package management

In the %packages block you will see any packages you have already chosen to install. For me this is “@^minimal-environment”. In this case “@^” marks a meta-group of packages.

You can add more packages below %packages header as well as remove packages from the selection. I do not like Firewalld but this is added in the “@^minimal-environment” meta-package. To remove a package use a -. My entire package selection is as follows:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
%packages
@^minimal-environment
# realm packages
realmd
sssd
oddjob
oddjob-mkhomedir
adcli
samba-common-tools
# other packages
vim
iptables-services
cockpit
# exlcude
-firewalld
%end

📝You can read more about package selection in the official docs

Network configuration

Network configurations can be simple. I would specify each NIC with its own line and the hostname on its own as well. You can do various actions such as disabling v6, setting nameservers, etc.

DHCP

1
network  --bootproto=dhcp --device=eth0 --noipv6 --activate

Static

1
2
network --bootproto=static --device=eth0 --ip=10.0.2.15 --netmask=255.255.255.0 --gateway=10.0.2.254 --nameserver=10.0.2.1,10.0.2.2 --noipv6 --activate
network --hostname=rhel8.dev0.sh

📝You can read more about network configurations in the official docs

User Creation

I created my users in the initial installation, but you can create them manually in the file as well. As far as passwords for the users go they can be encrypted or plain text, if you want to encrypt them in the file the offcial doc as well as this non-official doc this seem to be good sources on using Python to do that.

Register with RedHat automatically

Setting up your subscription (necessary to pull updates from the RH repos) is done via a “post install script” and it placed in a %post% block. Your username and password are required, they are saved in plain text in this file.

1
2
3
%post --log=/root/ks-post.log
subscription-manager register --username=<username> --password=<password> --auto-attach
%end

📝 You can read more about how to use post install scripts here and more on the subscription manager here

Using a kickstart file

There are several methods to use your new kickstart file. I used a Local Volume (A USB/Disk), since I am working in virtual machines I made a new tiny disk in the proper formats and put my ks.cfg file on it. I mount that disk to any new VM (as disk 2) then fire it up and all the magic happens. I would see most people using this method for smaller setups like mine.

RedHat has some nice docs on this specific setup method that includes a step-by-step on creation of the media.

Updated: