Bookmark this page

Guided Exercise: Automating Host Provisioning

In this exercise, you will explore the network installation server and the deployment environment.

Outcomes

You should be able to explore the network installation and Kickstart server.

Log in to workstation as the student user, using student as the password.

On workstation, run the lab hypervisor-kickstart start command. This command runs a start script that determines if the Red Hat Virtualization environment is configured and working.

[student@workstation ~]$ lab hypervisor-kickstart start
  1. Download the RHVH-4.3-20190512.3-RHVH-x86_64-dvd1.iso file.

    1. From workstation, open a terminal and log into the utility.lab.example.com server as the root user using ssh.

      [student@workstation ~]$ ssh root@utility.lab.example.com
      [root@utility ~]# 
    2. Change into the /tmp directory.

      [root@utility ~]# cd /tmp
    3. Use the wget command to download the RHVH-4.3-20190512.3-RHVH-x86_64-dvd1.iso file.

      [root@utility tmp]# wget \ 
      http://content.example.com/rhv4.3/x86_64/isos/\
      RHVH-4.3-20190512.3-RHVH-x86_64-dvd1.iso
      ...output omitted...
      Saving to: ‘RHVH-4.3-20190512.3-RHVH-x86_64-dvd1.iso.1’
      
      RHVH-4.3-20190512.3-RHVH-x86_64-dvd1. 100%[======================================================================>]   1.05G   450MB/s    in 2.4s
      
      2019-07-26 12:14:06 (450 MB/s) - ‘RHVH-4.3-20190512.3-RHVH-x86_64-dvd1.iso.1’ saved [1131413504/1131413504] 
  2. Mount the ISO image and find the files used during a PXE boot.

    1. Using the mount command, mount the ISO image to the /mnt mount point.

      [root@utility tmp]# mount RHVH-4.3-20190512.3-RHVH-x86_64-dvd1.iso /mnt
      mount: /dev/loop0 is write-protected, mounting read-only 
    2. List the contents of the /mnt/images directory.

      The files in this directory are used for PXE booting.

      [root@utility tmp]# ls -al /mnt/images
      total 8717
      dr-xr-xr-x. 3 root root    2048 May 12 13:45 .
      dr-xr-xr-x. 8 root root    2048 May 12 13:45 ..
      -r--r--r--. 1 root root 8919040 May 12 13:44 efiboot.img
      -r--r--r--. 1 root root     280 May 12 13:43 product.img
      dr-xr-xr-x. 2 root root    2048 May 12 13:45 pxeboot
      -r--r--r--. 1 root root     446 May 12 13:45 TRANS.TBL
  3. Find the squash file that is required for Kickstart configuration.

    1. List the contents of the /mnt/Packages directory.

      [root@utility tmp]# ls -al /mnt/Packages
      total 606494
      dr-xr-xr-x.  2 root root      2048 May 12 13:45 .
      dr-xr-xr-x.  8 root root      2048 May 12 13:45 ..
      -r--r--r--.  1 root root 621026735 May 12 13:28 redhat-virtualization-host-image-update-4.3-20190512.0.el7_6.noarch.rpm
      -r--r--r--. 22 root root     17140 Nov 22  2018 redhat-virtualization-host-productimg-4.3-0.0.el7.x86_64.rpm
      -r--r--r--.  1 root root       555 May 12 13:45 TRANS.TBL 
    2. Use rpm2cpio to extract the redhat-virtualization-host-image-update-4.3-20190512.0.el7_6.noarch.rpm file.

      [root@utility tmp]# rpm2cpio \
      /mnt/Packages/\
      redhat-virtualization-host-image-update-4.3-20190512.0.el7_6.noarch.rpm \
      | cpio -idmv
      ./usr/share/redhat-virtualization-host/image
      ./usr/share/redhat-virtualization-host/image/redhat-virtualization-host-4.3-20190512.0.el7_6.squashfs.img
      ./usr/share/redhat-virtualization-host/image/redhat-virtualization-host-4.3-20190512.0.el7_6.squashfs.img.meta

      The redhat-virtualization-host-4.3-20190512.0.el7_6.squashfs.img file is used in the Kickstart configuration file. To use the file for Kickstart it must first be copied to the installation tree directory. Rename the file to squashfs.img.

  4. Create a new NFS export on the utility server to provide your Kickstart file.

    1. Return to the root user's home directory. Create a new directory on utility called /ks.

      [root@utility tmp]# cd
      [root@utility ~]# mkdir /ks
    2. Edit the /etc/exports file to export the new /ks directory with read permission to *.lab.example.com using NFS.

      The utility server is already an NFS server for other exported file systems; if any configuration already exists in this file, then you must not change it. Add the configuration to the bottom of the file. The file should display as follows:

      ...output omitted...
      /ks            *.lab.example.com(ro)

      Save the file and exit the editor.

    3. Export the directories shared by the NFS daemon by issuing the exportfs -r command.

      [root@utility ~]# exportfs -r
      
  5. Inside the /ks directory, create a new Kickstart file to automate the installation of your Red Hat Virtualization Hosts.

    1. On utility, create a new file called /ks/rhvh.cfg. Open this file using a text editor, and then type in the following lines:

      liveimg --url=http://content.example.com/rhv4.3/x86_64/squashfs.img
      clearpart --all
      autopart --type=thinp
      rootpw --plaintext redhat
      timezone Etc/UTC --isUtc
      zerombr
      text
      
      reboot
      
      %post --erroronfail
      nodectl init
      %end
      
      • liveimg is the shared location of the squashfs.img image; http dictates that the file is shared using HTTP.

      • clearpart --all clears all partitions on the server.

      • autopart --type=thinp automatically creates new partitions using thin provisioning.

      • rootpw --plaintext redhat passes the root password in plain text.

      • timezone Etc/UTC --isUtc sets the timezone.

      • zerombr clears the MBR.

      • text indicates that the installation will be performed in text mode.

      • reboot will reboot the server once the squashfs.img is extracted and the installation is complete.

      • nodectl init initializes the configuration of the server.

    2. Save the file and close your text editor.

    3. Log out of the utility.lab.example.com server.

      [root@utility ~]# logout
      Connection to utility closed.
      [student@workstation ~]$
  6. The Kickstart configuration file can now be used to install a new RHV host by adding the inst.ks command during the boot process.

    However, we are not actually doing an installation during this guided exercise.

    vmlinuz initrd=initrd.img ip=dhcp inst.stage2=http://content.example.com/rhv4.3/x86_64/rhvh/dvd inst.ks=nfs://utility.lab.example.com:/ks/rhvh.cfg

Finish

On workstation, run the lab hypervisor-kickstart finish script to complete this exercise.

[student@workstation ~]$ lab hypervisor-kickstart finish

This concludes the guided exercise.

Revision: rh318-4.3-c05018e