Bookmark this page

Guided Exercise: Building System Images with the Image Builder

In this exercise, you will build a system image using the image builder utility.

Outcomes

You should be able to use the image builder to create system images.

  1. Log in as the student user with student as password on workstation. From a terminal, use SSH to log in to the servera system as the root user.

    [student@workstation ~]$ ssh root@servera

    Note

    In case workstation hangs using the web console, restart the virtual machine, and log into the web console with a new browser.

  2. On servera install the image builder and the web console image builder plug-in.

    1. Use the yum install lorax-composer composer-cli cockpit-composer command.

      [root@servera ~]# yum install lorax-composer \
      > composer-cli cockpit-composer
      ...output omitted...
      Is this ok [y/N]: y
      ...output omitted...
      
    2. Use the systemctl enable --now command to enable and start the image builder and web console services.

      [root@servera ~]# systemctl enable --now lorax-composer.socket cockpit.socket
      
  3. On workstation use Firefox to open the web console running on servera.lab.example.com:9090. Log in as the student user with the password student and the privileged user checkbox selected.

  4. Click Image Builder in the left navigation bar. The Image Builder will be available if you logged in after the packages were installed, because the image builder adds newly installed interface objects during log in initialization.

  5. Create a new bootable ISO image, using one of the existing blueprints.

    1. Click the example-development blueprint.

    2. Click the Images tab.

      From here, you can download completed images, or see the status of previously build images.

    3. Click the Create Image button in the center of the page.

    4. Click the Image Type menu, and from the list choose Live Bootable ISO (.iso) type.

    5. Click Create.

      The new image appears on the list of available images. The creation process takes around 10 minutes to finish. Requests to create additional images are added to the queue, so it is safe to move on to the next steps.

    6. When the image creation process is completed, the image can be downloaded to the local system, but this exercise does not need to take time to download the ISO file.

  6. Create a new blueprint customized with the mc package.

    1. Use the links at the top of the page to return to the Blueprints page.

    2. Click Create Blueprint.

    3. In the Create Blueprint window, enter rh-vm as the name for the blueprint.

    4. Click Create.

    5. In the Filter by Name... search box, enter the mc package name, and press Enter.

    6. Scroll down the list of filtered packages, and click the + icon next to the mc package.

      The mc package is added to the blueprint.

    7. Click Commit to commit the changes.

    8. In the Changes Pending Commit window, click Commit.

  7. Use the new rh-vm blueprint to create a new QCOW2 image.

    1. Use the top breadcrumb link to navigate back to the Blueprints page.

    2. In the line with the rh-vm blueprint, click Create Image.

    3. Click the Image Type drop-down menu and select QEMU QCOW2 Image (.qcow2).

    4. Click Create.

      The creation process takes around 10 minutes to finish. Requests to create additional images are added to the queue, so it is safe to move on to the next steps. Verify the creation process status by clicking the rh-vm blueprint, then the Images tab.

    5. When the image creation process is complete, the image can be downloaded to the local system. In this example, you do not need to download the QCOW2 file.

  8. Customize the rh-vm blueprint by adding the student user and the student's SSH key to that blueprint. To simplify this task, and to avoid errors unrelated to learning the image builder, this course provides a file that contains preconfigured user information and a user SSH key.

    1. On servera.lab.example.com, use the composer-cli blueprints save BLUEPRINTNAME command, to export the blueprint configuration to a file. The created filename will automatically include .toml as its extension.

      [root@servera ~]# composer-cli blueprints save rh-vm
      
    2. Use wget to download the custom.user blueprint customizations from the classroom server.

      [root@servera ~]# wget http://materials.example.com/labs/custom.user
      
    3. Append the customization from the custom.user file to the rh-vm.toml blueprint file.

      [root@servera ~]# cat custom.user >> rh-vm.toml
      
    4. Review the modified blueprint:

      [root@servera ~]# cat rh-vm.toml
      name = "rh-vm"
      description = ""
      version = "0.0.2"
      modules = []
      groups = []
      
      [[packages]]
      name = "mc"
      version = "4.8.19"
      
      [customizations]
      
      [[customizations.user]]
      name = "student"
      password = "$6$C3w0glL853ygS8k7$QxoI50 ...output omitted... d5LDdi/dr0Zq1"
      key = "ssh-rsa AAAAB3NzaC1yc2EAA ...output omitted... 6QuZf8f7aL LabGradingKey"
      groups = ["users", "wheel"]
      
    5. Push the modified blueprint file back to the image builder server.

      [root@servera ~]# composer-cli blueprints push rh-vm.toml
      
    6. Verify that the changes were pushed to the image builder server.

      [root@servera ~]# composer-cli blueprints show rh-vm
      name = "rh-vm"
      description = ""
      version = "0.0.2"
      modules = []
      groups = []
      
      [[packages]]
      name = "mc"
      version = "4.8.19"
      
      [customizations]
      
      [[customizations.user]]
      name = "student"
      password = "$6$C3w0glL853 ...output omitted... 7xOdxd5LDdi/dr0Zq1"
      key = "ssh-rsa AAAAB3Nza ...output omitted... QuZf8f7aL LabGradingKey"
      groups = ["users", "wheel"]
      
    7. Create a new QCOW2 image that contains the modifications. Use the composer-cli compose start BLUEPRINTNAME TYPE command.

      [root@servera ~]# composer-cli compose start rh-vm qcow2
      Compose 36b17 ...output omitted... 8299b2 added to the queue
      
  9. Use the composer-cli compose list command to verify the current status of the build.

    [root@servera ~]# composer-cli compose list
    36b17126-3c1a-4abb-9235-b3748c8299b2 RUNNING rh-vm 0.0.2 qcow2
    0ba76f6e-4acf-4909-a750-5676baac586d FINISHED example-development 0.0.1 live-iso
    3a899344-3e5d-40b8-bf96-1d91d65f2054 FINISHED rh-vm 0.0.2 qcow2
    

    The new image has a new name with a version corresponding to the latest blueprint version. The image name is associated to the blueprint used to create it.

  10. After the final build is finished, log off from servera.

    [root@servera ~]# exit
    [student@workstation ~]$ 
    

This concludes the guided exercise.

Revision: rh354-8.0-0e36520