Filters
Zo zoek je
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • "twee woorden" vindt precies die zin.
  • --naam of -x vindt een optie.
  • #woord zoekt alleen in commando's.
  • @grep vindt lessen en labs die grep gebruiken.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Zet ! voor een woord om het weg te laten. OR tussen woorden betekent één ervan.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken

Lab 16.1RH134, Hoofdstuk 16

Install a server automatically with Kickstart

Niveau
Gemiddeld
60 min
Machines
server1
Status
Nog niet begonnen

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

Doel

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.

Voordat je begint

  • 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/24 with the gateway 192.168.122.1. server1 has 192.168.122.10.

Taken

  1. Copy /root/anaconda-ks.cfg of server1 to /root/ks-web1.cfg and use it as the start.
  2. Change the file so that web1 gets: text mode, time zone Asia/Riyadh, the fixed address 192.168.122.40/24 with gateway and DNS .1, the host name web1.example.com, a locked root account, a user admin in wheel with a password hash, only the disk vda (wiped, automatic LVM), SELinux enforcing, the firewall with ssh and http, and an automatic reboot at the end.
  3. Install the minimal environment plus httpd, and enable httpd at boot. In %post, write web1 installed by Kickstart to /var/www/html/index.html.
  4. Check the file with ksvalidator until it reports no errors.
  5. Serve the file from server1 at http://192.168.122.10/ks-web1.cfg.
  6. Install the VM web1 with this file and wait until it reboots by itself.

Controleer je werk

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'
  • ksvalidator prints nothing (no errors).
  • curl http://192.168.122.40/ prints web1 installed by Kickstart.
  • On web1: host name web1.example.com, Enforcing, the firewall lists http and ssh.

Hints

Toon de hints
  • openssl passwd -6 makes the password hash for user --iscrypted --password=.
  • ignoredisk --only-use=vda, zerombr, clearpart --all --initlabel, autopart --type=lvm.
  • services --enabled=httpd enables the service; firewall --enabled --service=ssh,http opens the ports.
  • Files in /var/www/html need the right SELinux label: run restorecon after copying.
  • virt-install … --location ISO --initrd-inject FILE --extra-args "inst.ks=file:/ks-web1.cfg" works without the web server, too.

Oplossing

Toon de oplossing
  1. Start from the file of the installation.
    cp /root/anaconda-ks.cfg /root/ks-web1.cfg
    openssl passwd -6
  2. 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
  3. Check it.
    dnf install -y pykickstart
    ksvalidator /root/ks-web1.cfg
  4. 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
  5. 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"

Mijn notities

Nog geen notities.

Lessen voor dit lab

Commando's in dit lab