Kickstart Introduction

What is kickstart?

Kickstart is a function that gives you the ability to install a complete operating system based on a predefined list (kickstart file). Whenever you install an operating system on Red Hat Enterprise Linux, CentOS, Fedora or another Red Hat based Linux distribution, your installation choices are automatically recorded in a kickstart file called "anaconda-ks.cfg". This file is located within the home area of the root user: /root/anaconda-ks.cfg.

If you take a look at this file after an installation has been carried out, you will see that it reflects the entries that were entered during the installation. These entries would be installation type (new installation/upgrade), locale settings for keyboard and timezone, Networking information such as dhcp or static, disk partitioning information, package selections and much more. Many of these options we will cover in more detail.

The main function of the kickstart file is to give an administrator the ability to carry out network installations of Linux quickly. Another advantage is that you can create servers based on a proven build (standard build configuration). This functionality is very useful if you have to create a lot of servers of the same build frequently. You can even specify commands to be run after installation, such as the creation of new accounts. The normal method of using a kickstart file is to locate the file from an exported nfs directory or make it available via a web server, however, other options are available. We will cover the process involved for using nfs and a web server in the following examples.

In the examples that follow I will be using a Virtual Environment as my testing environment and CentOS 8 as the Linux Operating System. Here I will create a single server that will act as a nfs server and web server for our installations. It is this server that will contain the customized kickstart configuration files. Below are the instructions for creating the nfs/web server configuration used in this example.

Minimal Build - NFS/Web Server

For the server that will contain our kickstart files I have chosen to go with a minimal build. A video link is available that indicates how the VirtualBox environment has been defined. In this example this server will be called kicks01. I have given the server 2 CPUs, 4096 MB of Memory and a Virtual Disk of 20 GB in size.

The installation images used in this example can be downloaded from the following location: CentOS Downloads. For the build of the minimal server, I will be assuming that you have installed a basic server configuration previously. If not, refer to the video link as a quick overview of the process involved. For information relating to VirtualBox, follow the link VirtualBox.

Install Minimal Server

Below are the steps involved in configuring the Minimal Server build.

Define Server - In this example I have used "VirtualBox"
Specify No of CPUs - 2
Specify Memory - 4096MB
Specify size of disk - 20GB
Network - On VirtualBox select "Bridged Network"
Start Installation
Reboot Server Make a note of your IP address that has been assigned - ip a s Check Access to Network/Repositories - dnf repolist

Install NFS Components

Once your server has been built, you are now ready to install the "NFS" components. To install "NFS", issue the following commands as the "root" user.

Command issued: dnf install nfs-utils -y

Once the package "nfs-utils" has been installed, you will need to start the service and set it to automatically start at system start-up

Command issued:systemctl enable --now nfs-server

Create Kickstart area

Next we need to create a directory structure that will hold out kickstart files. Issue the following commands to create this area

Command issued:mkdir /kickstart

Add the following entry into the file "/etc/exports".


/kickstart *

Now restart the NFS services with the following command:

systemctl restart nfs-server

Install the Web Server

To install an Apache web server, issue the following command on your server: "dnf install httpd -y"

Once the web server components have been installed, you will need to start the web server and set it to automatically start at system start-up. To do this, issue the following commands:

systemctl enable httpd && systemctl start httpd

Security Considerations

For the purposes of the following examples I have chosen to disable SELinux and disable the firewall. However, in a real environment you would probably need to configure firewall access and modify your SELinux settings. To disable "SELinux" and the "Firewall", issue the following commands:

To set SELinux to Permissive mode, issue the following command: setenforce 0

To disable the firewall, issue the following commands: systemctl stop firewalld

Kickstart file created from the above installation

Below is the "anaconda-ks.cfg" file that was created during the installation of our nfs/web server. The kickstart file is generally broken down into multiple sections.

Location: /root/anaconda-ks.cfg


#version=RHEL8
# Use graphical install
graphical

repo --name="Minimal" --baseurl=file:///run/install/sources/mount-0000-cdrom/Minimal

%packages
@^minimal-environment

%end

# Keyboard layouts
keyboard --xlayouts='gb'
# System language
lang en_GB.UTF-8

# Network information
network  --bootproto=static --device=enp0s3 --gateway=192.168.0.1 --ip=192.168.0.18 --nameserver=8.8.8.8 --netmask=255.255.255.0 --ipv6=auto --activate
network  --hostname=kicks01

# Use CDROM installation media
cdrom

# Run the Setup Agent on first boot
firstboot --enable

ignoredisk --only-use=sda
autopart
# Partition clearing information
clearpart --none --initlabel

# System timezone
timezone Europe/London --isUtc

# Root password
rootpw --iscrypted $6$fGb2EcZuirAJJcQT$DdAZakvcy2TGiX5VHqJLJmiBzXRvN4z1bAn.7CS8UgNdiv6Aja9Kyb68T3pR.947yQ7mV./qif1NM8rN6EHOC1
user --groups=wheel --name=john --password=$6$Pyg3i2M/OdkI2j0v$gY/EfHwOJDQ.RDL2ncu8.1biwSGg53oltSL7v/Gk2JXjyg9iMaP50gauzQYuPZy/f17bKpefy5J9KxngmmWh3. --iscrypted --gecos="john"

%addon com_redhat_kdump --disable --reserve-mb='auto'

%end

%anaconda
pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
%end

Creating a Server from a kickstart file

Now that we have a server that can be used for either a NFS or Web Server installation, we can place our customized kickstart (ks.cfg) file into the /kickstart directory that was created earlier or it can be placed into the DocumentRoot directory of our web server /var/www/html

Creating a Definition for the New Server

Before we proceed, we first need to create a machine/server definition for the new server that we are going to create. Here we will specify that we are using a 2 CPUs, 4096 MB of Memory, a 20GB Virtual Disk.

If you are using VirtualBox, then you will need to specify a "Bridged Network Connection". The machine definition name will be the same as the hostname specified in the kickstart file. (kicks02)

Once the machine has been defined, we will use the same iso image to install our server. The video below will guide you through the process that is involved.

Now when we initiate our installation, at the installation screen, we will need to specify the location of the remote ks.cfg file that will be used. To specify this you will need to press "Escape" at the initial installer menu, this will then take you to a "boot:" prompt. In this example our kickstart file is residing on a server with the IP address 192.168.122.210 in a directory called /kickstart.

So from the boot prompt we enter the following information:

linux ks=nfs:192.168.122.018:/kickstart/ks.cfg

This command specifies that the location of the kickstart file ks.cfg can be found on a NFS mount at IP address 192.168.122.210 within a directory called /kickstart.

Once this command has been entered, you should have no further involvement during the installation. Our network information and partition information will be used to build the server. Once the installation has completed, remember to remove the installation media! before rebooting. Below is a Video overview of this process. You will notice that there is no manual intervention during the installation.

Creating a Server from a kickstart file

Now that we have a server that can be used for either a NFS or Web Server installation, we can place our customized kickstart (ks.cfg) file into the /kickstart directory that was created earlier or it can be placed into the DocumentRoot directory of our web server /var/www/html.

Kickstart Using NFS

For the example that follows a customized kickstart file has been created called ks.cfg. This file has been copied into the /kickstart directory we created earlier. This kickstart file contains custom partition information and specifies that we will be using a static IP address.

Once you have created this file, you will need to make sure the file can be read. To achieve this you must issue the following command:

chmod +r ks.cfg (This command adds the read attribute to the file, thus allowing anyone to read the file)

ks.cfg file used


#version=RHEL8
# Use graphical install
graphical

repo --name="Minimal" --baseurl=file:///run/install/sources/mount-0000-cdrom/Minimal

%packages
@^server-product-environment

%end

# Keyboard layouts
keyboard --xlayouts='gb'
# System language
lang en_GB.UTF-8

# Network information
network --device=enp0s3 --bootproto=static --ip=192.168.0.47 --netmask=255.255.255.0 --gateway=192.168.0.1 --nameserver=192.168.0.1 
network  --hostname=kicks02

# Use CDROM installation media
cdrom

# Run the Setup Agent on first boot
firstboot --enable

ignoredisk --only-use=sda
autopart
# Partition clearing information
clearpart --none --initlabel

# System timezone
timezone Europe/London --isUtc

# Root password
rootpw --iscrypted $6$ptdYrGQbI76lS47X$ZPYahKYemNxyhbVPRCfL/Z3d74o8q7YYiRoba.ktFA0mqFHgqmcB6xivzKUFP400yC3./Sq/Srw.OC8yT8s4J0
user --groups=wheel --name=john --password=$6$bXWyU2uW79u2K5VU$ddsrrlSxTv1KMRv3Qu4C0t6nfgykIfzrHSFVhbBcL9G3zrvyYC7NiDa2Jurr1d1NyhDloj5tidsbaR.TUeNZD1 --iscrypted --gecos="john"

%addon com_redhat_kdump --disable --reserve-mb='auto'

%end

%anaconda
pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
%end

Create a VirtualBox Definition for the New Server

Before we proceed, we first need to create a machine/server definition for the new server that we are going to create. Here we will specify that we are using a two CPUs, 4096 MB of Memory, a 20 GB Virtual Disk and a Bridged Network Connection. The machine definition name will be the same as the hostname specified in the kickstart file. (kicks02)

Once the machine has been defined to VirtualBox, we will use the same iso image to install the server. The following video below will guide you through the process that is involved.

Now when we initiate our installation, at the installation screen, we will need to specify the location of the remote ks.cfg file that will be used. To specify this you will need to press "Escape" at the initial installer menu, this will then take you to a "boot:" prompt. In this example our kickstart file is residing on a server with the IP address "192.168.0.18" in a directory called "/kickstart".

So from the boot prompt we enter the following information:

linux ks=nfs:192.168.0.18:/kickstart/ks.cfg

This command specifies that the location of the kickstart file ks.cfg can be found on a NFS mount at IP address 192.168.0.18 within a directory called /kickstart.

Once this command has been entered, you should have no further involvement during the installation. Our network information and partition information will be used to build our server. Once the installation has completed, remember to remove the installation media! before rebooting. Below is a Video overview of this process. You will notice that there is no manual intervention during the installation.

Kickstart using a webserver

The process of using a webserver is almost the same as that of the NFS installation. The main difference here is that we copy the kickstart configuration file to the root document directory. You can confirm this location on your web server by looking for the line "DocumentRoot" within the following configuration file: /etc/httpd/conf/httpd.conf

By default the DocumentRoot is : "/var/www/html"

Extract from: /etc/httpd/conf/httpd.conf


#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/var/www/html"

Once the file has been placed into the default DocumentRoot area, you can use a browser to confirm that the file is available by typing the IP address of the remote server along with the path to the ks.cfg file: 192.168.0.18/ks.cfg

You should now see that your ks.cfg file has been displayed. If not, check that your web server is running by using the following commands:

service httpd status - Displays whether web server is running or not
service httpd restart - Restarts web server
service httpd stop - Stops web server
service httpd start - Starts web server

Create a VirtualBox Definition for the New Server

As per the nfs installation, you will need to create a machine/server definition for the new server that we are going to create. Here we will specify that we are using a two CPUs, 4096 MB of Memory, a 20 GB Virtual Disk and a Bridged Network Connection. The machine definition name will be the same as the hostname specified in the kickstart file. (kicks02)

Once the machine has been defined to VirtualBox, we will use the same iso image to install the server. The following video below will guide you through the process that is involved.

Now when we initiate our installation, at the installation screen, we will need to specify the location of the remote ks.cfg file that will be used. To specify this you will need to press "Escape" at the initial installer menu, this will then take you to a "boot:" prompt. In this example our kickstart file is residing on a web server with the IP address "192.168.0.18".

So from the boot prompt we enter the following information:

linux ks=http://192.168.0.18/ks.cfg

This command specifies that the location of the kickstart file ks.cfg can be found within the root directory of our web server.

Once this command has been entered, you should have no further involvement during the installation. Our network information and partition information will be used to build our server. Once the installation has completed, remember to remove the installation media! before rebooting.