8. Automated Network install using Kickstart
After completing your installation manually, login into one of your compute nodes via SSH.
[root@master ~]# ssh c01
The authenticity of host 'c01 (192.168.17.1)' can't be established.
ECDSA key fingerprint is SHA256:NkyFE6f7mofYPNH7jBeOMKmBKr0qmiFR8p9g6sf0a0g.
ECDSA key fingerprint is MD5:f4:56:4f:11:53:39:49:a4:15:1d:99:11:b9:7b:2a:77.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'c01,192.168.17.1' (ECDSA) to the list of known hosts.
root@c01's password:
Last login: Thu Feb 14 10:34:20 2019 from gateway
[root@c01 ~]#
If there are any errors such as
[root@master ~]# ssh c01
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
...
make sure to remove any existing host key and try again:
[root@master ~]# rm ~/.ssh/known_hosts
The root
user’s home directory will contain a file called
anaconda-ks.cfg
. This text file contains the configuration you used
to install the system. You can use this file as a starting point to
automate the installation of other machines.
[root@c01 ~]# cat anaconda-ks.cfg
#version=DEVEL
# System authorization information
auth --enableshadow --passalgo=sha512
# Use network installation
url --url="http://192.168.16.1/CentOS-7-2207-02-x86_64"
# Use text mode install
text
# Run the Setup Agent on first boot
firstboot --enable
ignoredisk --only-use=sda
# Keyboard layouts
keyboard --vckeymap=us --xlayouts=''
# System language
lang en_US.UTF-8
# Network information
network --bootproto=dhcp --device=eno1 --onboot=off --ipv6=auto --no-activate
network --bootproto=dhcp --device=eno2 --ipv6=auto --activate
network --bootproto=dhcp --device=eno3 --onboot=off --ipv6=auto
network --bootproto=dhcp --device=eno4 --onboot=off --ipv6=auto
network --bootproto=dhcp --device=ib0 --onboot=off --ipv6=auto
network --hostname=localhost.localdomain
# Root password
rootpw --iscrypted $6$fkThkrwW9F3iY40X$aToChePSgrEr3aRCR2l2XbT3flRfsjvgGklhEEy55I8vXYcXYUanJQLgx6fwA3b.zYV8VfaaqokYi0odoBlW..
# System services
services --enabled="chronyd"
# Do not configure the X Window System
skipx
# System timezone
timezone US/Eastern --isUtc
# System bootloader configuration
bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda
autopart --type=plain
# Partition clearing information
clearpart --all --initlabel --drives=sda
%packages
@core
chrony
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
Kickstart files are made up of sections, each describing which actions to take during stages of the installation process.
The default section is a list of commands which configure the installer. You can find descriptions of each of these commands in the Kickstart Syntax Reference from Red Hat.
It is followed by a packages
section defines which packages should
be installed (see Packages
Selection)
%packages
@core
chrony
kexec-tools
%end
%pre
and
%post
sections allow you to define scripts that should run before or after the
installation process. A common way to create an initial configuration of
a server is to place the necessary steps inside of a %post
script.
%post
# system is installed
# this bash script can run any commands on that system before reboot
%end
For our purposes, we don’t need the %addon
and %anaconda
section.
8.1. Install compute nodes with kickstart file
You will now automatically provision your servers using a Kickstart script. These scripts will be hosted by the HTTP server. Kernel options in the PXELINUX configuration will guide the installer to where to find them.
Create a
minimal.ks
file based on theanaconda-ks.cfg
file from your installed compute nodeCopy the Kickstart file to the HTTP server directory
[root@master ~]# mkdir -p /var/www/html/kickstarts [root@master ~]# cp minimal.ks /var/www/html/kickstarts/minimal.ks
Make adjustments to your kickstart file
Note
Ensure that your kickstart file includes a line with the
reboot
command. Otherwise you will have to manually reboot each server at the end of the installation.Add a kickstart menu item to the PXELINUX configuration
Use the
inst.ks
kernel option to specify the URL of the kickstart file. Keep other options for debugging purposes.LABEL installer-kickstart kernel centos7/vmlinuz initrd centos7/initrd.img append console=tty0 console=ttyS1,115200n8 inst.sshd inst.ks=http://master.hpc/kickstarts/minimal.ks MENU LABEL CentOS 7 Installation (Kickstart)
Boot your systems into the the kickstart installer
Either manually select the
installer-kickstart
entry in the serial console while booting your system or let the system automatically move into the kickstart installer by changing the default entry. To change the default entry, changeONTIMEOUT
fromlocal
toinstaller-kickstart
and move theMENU DEFAULT
to theinstaller-kickstart
label.... ONTIMEOUT installer-kickstart ... LABEL local MENU LABEL (local) LOCALBOOT -1 ... LABEL installer-kickstart ... MENU LABEL CentOS 7 Installation (Kickstart) MENU DEFAULT
Note
You can speed up installer boot time by preventing it from trying to configure all network interfaces. Limit yourself to just the necessary network interface with the
ip=<interface-name>:dhcp
kernel option (e.g.,ip=em2:dhcp
).
Boot from local disk after the installation completes
Change the PXELINUX configuration file for the compute node and make it boot from local disk
Note
One way to avoid having to deal with multiple files is to create a local
configuration file and a installer-kickstart
configuration file. And then use either symbolic links or copying the files to control which file is used by each node:
[root@master pxelinux.cfg]# ls -lah
total 20K
drwxr-xr-x 2 root root 4.0K Nov 2 18:12 .
drwxr-xr-x 4 root root 4.0K Nov 2 11:16 ..
lrwxrwxrwx 1 root root 19 Nov 2 18:01 C0A81101 -> installer-kickstart
lrwxrwxrwx 1 root root 19 Nov 2 18:01 C0A81102 -> installer-kickstart
lrwxrwxrwx 1 root root 10 Nov 2 18:12 C0A81103 -> local-boot
lrwxrwxrwx 1 root root 19 Nov 2 18:01 C0A81104 -> installer-kickstart
-rw-r--r-- 1 root root 1.9K Nov 2 12:22 default
-rw-r--r-- 1 root root 2.1K Nov 2 18:01 installer-kickstart
-rw-r--r-- 1 root root 2.1K Nov 2 18:02 local-boot