Goal
Write a Kickstart file, check it, serve it from server1 with Apache, and install a new virtual machine web1 without answering a single question in the installer.
Before you start
- server1 (RHEL 10) with root access, and a KVM host that can make a new VM (server1 itself with
virt-install, or your laptop). - The RHEL 10 DVD ISO on the KVM host, for example
/var/lib/libvirt/images/rhel-10.0-x86_64-dvd.iso. - The libvirt network
192.168.122.0/24with the gateway192.168.122.1. server1 has192.168.122.10.
Tasks
Tick a task when it is done. Only your browser remembers it.
- Copy
/root/anaconda-ks.cfgof server1 to/root/ks-web1.cfgand use it as the start. - Change the file so that web1 gets: text mode, time zone
Asia/Riyadh, the fixed address192.168.122.40/24with gateway and DNS.1, the host nameweb1.example.com, a locked root account, a useradmininwheelwith a password hash, only the diskvda(wiped, automatic LVM), SELinux enforcing, the firewall withsshandhttp, and an automatic reboot at the end. - Install the minimal environment plus
httpd, and enablehttpdat boot. In%post, writeweb1 installed by Kickstartto/var/www/html/index.html. - Check the file with
ksvalidatoruntil it reports no errors. - Serve the file from server1 at
http://192.168.122.10/ks-web1.cfg. - Install the VM
web1with this file and wait until it reboots by itself.
Check your work
ksvalidator /root/ks-web1.cfg
curl -s http://192.168.122.10/ks-web1.cfg | grep -E '^(network|rootpw|autopart)'
ping -c 2 192.168.122.40
curl -s http://192.168.122.40/
ssh admin@192.168.122.40 'hostnamectl --static; getenforce; sudo firewall-cmd --list-services'ksvalidatorprints nothing (no errors).curl http://192.168.122.40/printsweb1 installed by Kickstart.- On web1: host name
web1.example.com,Enforcing, the firewall listshttpandssh.
Hints
Show the hints
openssl passwd -6makes the password hash foruser --iscrypted --password=.ignoredisk --only-use=vda,zerombr,clearpart --all --initlabel,autopart --type=lvm.services --enabled=httpdenables the service;firewall --enabled --service=ssh,httpopens the ports.- Files in
/var/www/htmlneed the right SELinux label: runrestoreconafter copying. virt-install … --location ISO --initrd-inject FILE --extra-args "inst.ks=file:/ks-web1.cfg"works without the web server, too.
Solution
Show the solution
- Start from the file of the installation.
- and 3. Edit the file. The important lines:/root/ks-web1.cfg
text lang en_US.UTF-8 keyboard --vckeymap=us timezone Asia/Riyadh --utc network --bootproto=static --device=enp1s0 --ip=192.168.122.40 --netmask=255.255.255.0 --gateway=192.168.122.1 --nameserver=192.168.122.1 --hostname=web1.example.com --activate rootpw --lock user --name=admin --groups=wheel --iscrypted --password=$6$PASTE-YOUR-HASH ignoredisk --only-use=vda zerombr clearpart --all --initlabel autopart --type=lvm selinux --enforcing firewall --enabled --service=ssh,http services --enabled=httpd reboot %packages @^minimal-environment httpd %end %post echo "web1 installed by Kickstart" > /var/www/html/index.html %end - Check it.
dnf install -y pykickstart ksvalidator /root/ks-web1.cfg - Serve it with Apache.
dnf install -y httpd cp /root/ks-web1.cfg /var/www/html/ restorecon -v /var/www/html/ks-web1.cfg systemctl enable --now httpd firewall-cmd --add-service=http --permanent firewall-cmd --reload - Install the VM (on the KVM host).
virt-install --name web1 --memory 2048 --vcpus 2 --disk size=15 \ --location /var/lib/libvirt/images/rhel-10.0-x86_64-dvd.iso \ --os-variant rhel10.0 --network network=default --graphics none \ --extra-args "inst.ks=http://192.168.122.10/ks-web1.cfg console=ttyS0"
My notes
No notes yet.