Provision a Kickstart Server with RHEL8 - Part 3

John T. Mills
John T. Mills
Provision a Kickstart Server with RHEL8 - Part 3

Now that we have the kickstart server completed, we can add a new RHEL8 kickstart pattern to the web server. We will then be able to install our new RHEL8 VM. The VM profile was completed in the previous article, Provision a Kickstart Server with RHEL8 - Part 2.

Kickstart Profile

  1. Login to the kickstart server using ssh or the console.
  2. Create a starter kickstart configuration. These can get complex, but this will be a good initial configuration.
    vi /var/www/html/rhel8
    
  3. Add the drive formatting to /var/www/html/rhel8 We will format sda in this example. The drive name will change based on the hardware or virtualization that is present. It could be sda,hda,vda, or xda. Change it to what is correct for your setup.
    clearpart --all
    zerombr
    part /boot --fstype xfs --size=1024 --asprimary --ondisk sda
    part pv.1 --fstype="lvmpv" --ondisk=sda --size=1 --grow
    volgroup rootvg --pesize=4096 pv.1
    logvol /         --fstype=xfs --size=8192   --name=rootlv  --vgname=rootvg
    logvol /home     --fstype=xfs --size=2060   --name=homelv  --vgname=rootvg
    logvol /var/www  --fstype=xfs --size=4096   --name=wwwlv   --vgname=rootvg
    logvol swap                   --size=1024   --name=swaplv  --vgname=rootvg
    
  4. Add the network hosted install media details. Replace {IP} with the IP address of the kickstart server. In my example 192.168.0.37
    install
    url --url=http://192.168.0.37/x86_64/8/2/BaseOS
    repo --name="AppStream" --baseurl=http://192.168.0.37/x86_64/8/2/AppStream
    
  5. Add the keyboard and system language as is desired for this installation. In this case, I've selected US english.
    keyboard --vckeymap=us --xlayouts='us'
    lang en_US.UTF-8
    
  6. Specify the network configuration of the VM. Because I'm using DHCP this is a simple configuration. Static IP configurations are more complex. I'll include the static IP setup as a comment in the below code.
    network --onboot yes --bootproto=dhcp --activate --hostname=rhel8 --activate
    # network --onboot yes --bootproto=static --ip=192.168.0.38 --netmask=255.255.255.0 --gateway=192.168.0.1 --nameserver=192.168.0.1 --hostname=rhel8 --activate
    
  7. Set a root password. In this case the password is set to the word Insecure with a capitalized "i".
    rootpw "Insecure"
    
  8. Enable the initial setup application for the first boot.
    firstboot --enable
    
  9. Set up the system without the graphical option. This can be overridden in the package section by selecting a graphical option.
    skipx
    
  10. Enable time management.
    services --enabled="chronyd"
    
  11. Set an appropriate time zone as is desired for this installation. I'll select CST6DST, but you can adjust as is desired.
    timezone America/Chicago --isUtc
    
  12. Extend the firewall to allow httpd traffic. ssh, cockpit, and dhcpv6-client are enabled by default.
    firewall --enable --http
    
  13. Add a %pre section so we can do some scripted actions before the installation begins. We will format sda, in this example. The drive name will change based on the hardware or virtualization that is present. It could be sda,hda,vda, or xda. Change it to what is correct for your setup.
    %pre
    dd if=/dev/zero of=/dev/sda bs=1M count=1000
    %end
    
  14. Add a %packages section to load custom package groups or individual packages.
    %packages
    @base
    @system-tools
    httpd
    %end
    
  15. Add an %addon section to select a security profile. In this case we are using PCI-DSS.
    %addon org_fedora_oscap
        content-type = scap-security-guide
        profile = xccdf_org.ssgproject.content_profile_pci-dss
    %end
    
  16. Add a second %addon section to configure the kdump utility.
    %addon com_redhat_kdump --enable --reserve-mb='auto'
    %end
    
  17. Add an %anaconda section to set some user password policies.
    %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
    
  18. And lastly, add a %post section to run some commands. In this case, we are adding a simple webpage and enabling the webserver to start after the system comes up.
    %post
    echo -e "<html>welcome to rhel8</html>" > /var/www/html/index.html
    systemctl enable httpd.service
    %end
    
  19. Save the file and you should be able to see it from your web browser when you navigate to the kickstart server's URL. In my example, the kickstart server is at 192.168.0.37, so the URL is:
    http://192.168.0.37/rhel8
    

    The browser should display (truncated): example image

Installing RHEL8 from Kickstart

  1. Verify that we have the following requirements met:
    1. Kickstart pattern hosted on a web server.
    2. Installation DVD/ISO repositories hosted on a web server.
    3. Virtual machine created, per the previous installment of this article, Provision a Kickstart Server with RHEL8 - Part 2 I'll refer to this VM as rhel8 in the following steps.
  2. Depending on the virtualization in use, the following operations may vary in order. Regardless, do the following steps in the order appropriate for your virtualization type.
    1. Open a console to the rhel8 VM.
    2. Mount either the RHEL8 Binary DVD or the RHEL8 Boot DVD to the rhel8 VM. The guide for obtaining either is in the previous article, Downloading Red Hat Enterprise Linux 8.
    3. Power on the rhel8 VM and boot from the RHEL8 DVD/ISO.
  3. Immediately you will see the RHEL installation and recovery TUI. example image
  4. If nothing is entered for 60 seconds, the server will boot into the manual installation setup. Before that happens, select the ESC key. The TUI boot: prompt will appear. example image
  5. Type the following to start the kickstart installation. Replace the IP with the IP address of the kickstart server. In my example 192.168.0.37
    linux ks=http://192.168.0.37/rhel8
    

    My input: example image If you are using static IPs, the command would be the folowing to build rhel8 VM with a IP of 192.168.0.38. Be sure to adjust the options based on your subnet configuration.

    linux ks=http://192.168.0.37/rhel8 nameserver=192.168.0.1 ip=192.168.0.38::192.168.0.1:255.255.255.0:rhel8:eth0:none
    

    The ip= syntax is ip=ip::gateway:netmask:hostname:interface:none. More information can be found in the Performing an advanced RHEL installation Guide. example image

  6. The main configuration panel should display after a short time. example image
  7. All of the options should have been completed automatially, so the installation will begin automatically. example image
  8. When complete, the rhel8 VM should boot automatically, and the login should be displayed. If this doesn't occur, ensure the DVD/ISO was ejected after the installtion. If it was mounted, eject it and restart the rhel8 VM. example image
  9. Now that the VM is up, let's verify the sample website is working. Open a browser window and navigate to the rhel8 VM's website. In my example it resides at:
    http://192.168.0.38/
    

    The browser should display: example image

Conclusion

Now that we have built an environment which can build and rebuild a RHEL8 VM, we have the ablity to create complex system images for specific purposes as well as simple images that can be used for a wide variety of purposes. Enjoy!

Examples in this post can be found on GitHub