الفلاتر
طريقة البحث
  • الكلمات العادية تجد الأسماء والنصوص والأمثلة.
  • "كلمتان" تجد العبارة بالضبط.
  • --name أو -x تجد خيارًا.
  • #كلمة تبحث داخل الأوامر فقط.
  • @grep تجد الدروس والمعامل التي تستخدم grep.
  • الفلاتر: cat:network · in:labs · level:rhcsa · ch:8 · root:yes. ضع ! قبل كلمة لاستبعادها. OR بين الكلمات تعني إحداها.
  • ↑ ↓ للتنقل · Enter للفتح · Esc للإغلاق · / للبحث

معمل 16.1RH134, الفصل 16

Install a server automatically with Kickstart

المستوى
متوسط
60 دقيقة
الأجهزة
server1
الحالة
لم يبدأ

هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.

الهدف

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.

قبل أن تبدأ

  • 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.

المهام

  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.

تحقّق من عملك

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.

تلميحات

اعرض التلميحات
  • 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.

الحل

اعرض الحل
  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"

ملاحظاتي

لا توجد ملاحظات بعد.

دروس هذا المعمل

الأوامر في هذا المعمل