Once you understand the contents of a kickstart file, it then becomes quite easy to customize it. The kickstart file is arranged into 4 sections.
AnnouncementI have released my new course on Udemy, Kubernetes By Example. Sign up now to get free lifetime access!
- Configuration commands
- pre section for writing preinstall scripts
- packages section
- post section
These sections neeeds to be declared in the same order as listed above.
A lot of the stuff in the kickstart file is self explanatory, such as:
keyboard us # This sets to keyboard to United States layout
The packages section. The packages section lists all the software that are to be installed during the OS install process:
- Lines beginning with an “@” symbol, Indicates a package group that is installed.
- Lines with no symbol represents individual packages that are installed.
- Lines beginning with an “-” symbol, indicates packages that will be excluded from the install.
By default a Kickstart file will only create the root user. However you can create other users during the install prcocess by inserting the following entry:
user --name=vagrant --plaintext --password vagrant --groups=vagrant,wheel
In this example we created a user called “vagrant”.
Note, For security purpose, you should always <l=>encrypt the password before inserting into the kickstart file.
You might find the partition section is commented out, that’s because machines can have different hardware in terms of number/capacity of hdds. Therefore as a precaution, this bit is commented out so that you do this manually. But if all your machines have the same HDD setups (and you want all of them to have the same partition/LV setup) then you can uncomment this bit as well. Once you are happy with your kickstart file, you can then start to use kickstart to automate Centos installations.
Creating a kickstart file
A Kickstart file automatically gets created by the “anaconda installer” at the end of a RHEL installation. It is saved at the root user’s home directory, and has the name
There are main 3 ways to create a kickstart file:
Approach 1 – Carry out a normal Centos/RHEL installation
The chance are that you have unknowing already created a ks file the last time you install Centos. It was automatically generated using the answers you selected at the time of the install. You should find the ks file under the root directory, and it has the name “anaconda-ks.cfg”. You can use this file as a template to create your own kickstart files.
Approach 2 – Write it from scratch
The kickstart file is a simple text file and a lot of it is quite intuitive. There is a long list of kickstart options that you can set. Some of the settings are manadatory. The easiest way to create a kickstart file is by using an existing kickstart file as a template.
Approach 3 – Use the GUI tool
There is a very handy little tool called system-config-kickstart which lets you create your own custom ks files, using a simple GUI. First you need to install the tool:
$ yum install system-config-kickstart
After that, you can open the tool via the command line:
or from the desktop go to:
Applications => system tools => Kickstart
This will result in the following gui popping up:
Note: this gui tool hasn’t been updated in a long time, and hence some powerful features unavailable, e.g. the ability to specify logical volumes, instead this tool is only limited to specifying partitions.
Validating your kickstart file
If you manually edit the ks file, be sure to use the
ksvalidator command to check that your kickstart file is valid.
$ vksvalidator /path/to/ks-file
This tool will find error likes:
keyxaboard us # Notice "keyboard" has been mispelt.
However it won’t identify errors relating to:
– URL paths
– package names or groups
– %post or %pre
ksvalidator is part of the
system-config-kickstart package. So you need to install this package in order to use ksvalidator.
Kickstart User Guide
You can find help info for kickstart by running the following:
$ rpm -qd pykickstart /usr/share/doc/pykickstart-220.127.116.11/COPYING /usr/share/doc/pykickstart-18.104.22.168/ChangeLog /usr/share/doc/pykickstart-22.214.171.124/README /usr/share/doc/pykickstart-126.96.36.199/kickstart-docs.txt # Open this in vim. /usr/share/doc/pykickstart-188.8.131.52/programmers-guide /usr/share/man/man1/ksflatten.1.gz /usr/share/man/man1/ksshell.1.gz /usr/share/man/man1/ksvalidator.1.gz /usr/share/man/man1/ksverdiff.1.gz
Note: pykickstart is a software package that writes/reads kickstart files.