/ linux

Kickstart with Kickstart

Hello everyone! Today we're going to discuss getting started with automated installs. Primarily via Kickstart!

One of my good buddies, a co-host, a bff (I LOVE YOU PHIL) was asking me what I did to get started with Kickstart. I figured I'd throw it into a blog post to immortalize the ideas for anyone that needs assistance! ... So long as I don't nuke the server again...

Anyway, what were we talking about? Oh, Kickstart!

So, really, when I started out, I cheated. There is a "default" Kickstart file based on your installation.

If you head over to /root you'll see what I'm talking about.

sudo su
cd
ls

The above commands will get you there on a CentOS, RHEL, or Fedora system.

The anaconda-ks.cfg is your Kickstart file. Let's check it out:

#version=DEVEL
# System authorization information
auth --enableshadow --passalgo=sha512
# Use CDROM installation media
cdrom
# Use graphical install
graphical
# 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=static --device=em1 --gateway=10.0.0.1 --ip=10.0.0.100 --nameserver=10.0.0.1 --netmask=255.255.255.0 --ipv6=auto --activate
network  --bootproto=dhcp --device=em2 --onboot=off --ipv6=auto
network  --hostname=infrastructure

# Root password
rootpw --iscrypted PWHASHNOUCANTHAVE
# System services
services --disabled="chronyd"
# System timezone
timezone America/Chicago --isUtc --nontp
user --groups=wheel --name=sysadmin --password=PWHASHNOUCANTHAVE --iscrypted --gecos="Chris"
# System bootloader configuration
bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda
# Partition clearing information
clearpart --all --initlabel --drives=sda
# Disk partitioning information
part swap --fstype="swap" --ondisk=sda --size=4096
part /home --fstype="xfs" --ondisk=sda --size=3553790
part /boot/efi --fstype="efi" --ondisk=sda --size=512 --fsoptions="umask=0077,shortname=winnt"
part / --fstype="xfs" --ondisk=sda --size=256000

%packages
@^minimal
@core
kexec-tools

%end

%addon com_redhat_kdump --enable --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

Holy crap. This wall of text gives us a ton of information, but it also gives us a lot to work with!

Note the top, # use graphical install section. You can change graphical to text if you want to do a headless installation in a minimal environment. I've made a few changes on my current installation process. Before editing, I recommend copying anaconda-ks.cfg to ks.cfg to not mess with the original file. I moved mine to /var/ftp/pub/ks.cfg You can see that next:

#version=DEVEL
# System authorization information
auth --enableshadow --passalgo=sha512
# Use CDROM installation media
cdrom
# Use graphical install
#graphical
# 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=static --device=ens3 --gateway=10.0.0.1 --ip=10.0.0.111 --nameserver=10.0.0.1 --netmask=255.255.255.0 --ipv6=auto --activate
network  --hostname=redis

# Root password
rootpw --iscrypted NOUCANTHAVE
# System services
services --disabled="chronyd"
# System timezone
timezone America/Chicago --isUtc --nontp
user --groups=wheel --name=admindev --password=NOUCANTHAVE --iscrypted --gecos="Systems Administrator"
# System bootloader configuration
bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda
autopart --type=lvm
# Partition clearing information
clearpart --none --initlabel
reboot

%packages
@^minimal
@core
kexec-tools
%end

%addon com_redhat_kdump --enable --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

%post
yum install vim git -y
yum update -y
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm
yum --enablerepo=elrepo-kernel install kernel-ml -y
sed -i 's/saved/0/g' /etc/default/grub
grub2-mkconfig -o /boot/grub2/grub.cfg
%end

I've trimmed up the partitioning scheme and added some post installation steps to upgrade the kernel and add a few packages. You can of course do this under the %packages header, but that requires adding certain repositories to the Kickstart file. If my list of required packages starts to grow, I'll consider that.

You can find a lot of useful information on the CentOS website and a few blogs.

CentOS Tips and Tricks

Kickstart Documentation

Exhaustive Walkthrough

Thanks for reading! Hope this helps you out, Phil!

Kickstart with Kickstart
Share this