Automating Installation With Kickstart

Automating Installation With Kickstart

Introduction

A systems administrator can automate the installation using a feature called kickstart. Anaconda is a program that installs the system and it needs to be told how to install the system: network configuration, disks, partitions, users, groups etc. A kickstart installation uses uses a text file to provide all the answers to these questions. By default, the installation is interactive and all the questions should be answered by a user. The recommended approach to creating Kickstart files is to perform a manual installation on one system first. After the installation completes, all choices made during the installation are saved into a file named anaconda-ks.cfg, located in the /root/ directory on the installed system. You can then copy this file, make any changes you need, and use the resulting configuration file in further installations.

Configuration Commands

url: Specifies the location of the installation media

url --url="http://mirror.centos.org/centos/7/os/x86_64"

repo: This option tells anaconda which repository to use and from where to install packages

repo --name="My example repo" --baseurl="http://example.com/Centos/7/packages"

text: Forces text mode installation

vnc: Allows graphical installation via VNC

vnc --password=testpassword

For more options please navigate here

Example of a kickstart file
You can use ksvalidator command to verify kickstart file syntax

#version=RHEL7
# System authorization information
auth --enableshadow --passalgo=sha512

# Use network installation
url --url="http://mirror.centos.org/centos/7/os/x86_64"
# Run the Setup Agent on first boot
firstboot --enable
ignoredisk --only-use=sda
# Keyboard layouts
keyboard --vckeymap=us --xlayouts='us'
# System language
lang en_US.UTF-8

# Network information
network  --bootproto=dhcp --device=eno16777736 --ipv6=auto --activate
network  --hostname=knesenko-centos7
# Root password
rootpw --iscrypted $6$PRh...iI7XKmbA8J1
# System timezone
timezone Asia/Jerusalem --isUtc --nontp
user --groups=wheel --name=knesenko --password=$6$PRh...iI7XKmbA8J1 --iscrypted --gecos="knesenko"
# System bootloader configuration
bootloader --location=mbr --boot-drive=sda
# Partition clearing information
clearpart --none --initlabel 
# Disk partitioning information
part /boot --fstype="ext4" --ondisk=sda --size=500
part pv.10 --fstype="lvmpv" --ondisk=sda --size=19979
volgroup centos_knesenko-centos7 --pesize=4096 pv.10
logvol swap  --fstype="swap" --size=2048 --name=swap --vgname=centos_knesenko-centos7
logvol /  --fstype="ext4" --grow --maxsize=51200 --size=1024 --name=root --vgname=centos_knesenko-centos7

%packages
@core

%end

Publish the Kickstart configuration file to Anaconda
The installer must be able to access the kickstart file during the installation. The most common way is through a network server, such as: http, ftp or nfs.

Boot Anaconda and point to Kickstart file
To start a Kickstart installation, a special boot option (inst.ks=) must be specified when booting the system.

inst.ks=/http://example.com/Centos/7/kickstart.cfg