Bookmark this page

Lab: Deploying and Managing Virtual Machines

Performance Checklist

In this lab, you will create templates and use them to deploy virtual machines.

Outcome

You should be able to create a template and deploy a virtual machine.

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

On workstation, run the lab vms-review start command. This command runs a start script that determines if the Red Hat Virtualization environment is configured and working. Wait for the start script to finish before starting the lab. The start script creates a new virtual machine named rhel-vm1, which does not initially exist in the production data center.

[student@workstation ~]$ lab vms-review start

The start script created the rhel-vm1 virtual machine in the production data center.

  1. Install cloud-init on the rhel-vm1 virtual machine in the production data center.

    1. Open Firefox and, using the https://rhvm.lab.example.com URL, log in to the Administration Portal as the admin user, with the internal profile, using redhat as the password.

    2. Navigate to Virtual Machines by clicking on Compute in the menu bar and then selecting Virtual Machines.

    3. Highlight the row containing the rhel-vm1 virtual machine in the clustertwo cluster by clicking on an empty cell in that row. Ensure that the rhel-vm1 virtual machine is running. If it is not, click the Run button to start it.

    4. When available, open the console and log in to rhel-vm1 as user root with redhat as the password.

    5. To install the cloud-init software package on your rhel-vm1 virtual machine, you normally would ensure the system is registered with Red Hat Subscription Manager and has the correct entitlements and Yum repositories enabled.

      In this classroom environment, this step has been modified because the classroom might not have access to the Content Distribution Network or a Red Hat Satellite server. Instead, local Yum repositories have been provided that contain the correct packages.

      Install the cloud-init package with all dependencies using the yum command.

      [root@rhel-vm1 ~]# yum -y install cloud-init
      ...output omitted...
    6. Shut down the rhel-vm1 virtual machine using the systemctl poweroff command.

      [root@rhel-vm1 ~]# systemctl poweroff
  2. Create a new template named cloud-lab-template in the production data center, using the rhel-vm1 virtual machine. Give the template a description of cloud-init based template, and give the template disk an alias of rhel7-cloud-lab.

    1. Ensure that the row containing the rhel-vm1 virtual machine in the clustertwo cluster is highlighted by clicking an empty cell in that row.

    2. With the rhel-vm1 virtual machine row highlighted, click the three vertical dots to the right of the Create Snapshot button, and then select Make Template.

    3. Specify all the settings needed to create the template using the New Template window.

    4. In the Name text field, type cloud-lab-template as the template name.

    5. In the Description text field, type cloud-init based template as the template description.

    6. In the Alias text field, type rhel7-cloud-lab as the template alias.

    7. If it is not already selected, then select the Seal Template (Linux only) check box.

    8. Leave all other options as they are.

    9. Click the OK button to begin the template creation. This step can take a couple of minutes to finish. When the process of creating the template is complete, the virtual machine is released from its locked state.

  3. Ensure that virtual machines created from the cloud-lab-template template will use cloud-init.

    1. On the Compute >> Templates page, click an empty cell in the row containing cloud-lab-template. With the row containing cloud-lab-template highlighted, click the Edit button. The Edit Template window displays.

    2. In the Edit Template window, click the Show Advanced Options button to access the advanced options. Click the Initial Run tab.

    3. Make sure the check box for Use Cloud-Init/Sysprep is selected.

    4. Make sure the VM Hostname text field is empty.

    5. Leave the other options with their default values. Click the OK button to accept the changes.

  4. Use the cloud-lab-template template to deploy a new virtual machine called rhel-lab-vm to the production data center. Configure cloud-init to:

    • Make sure that the new virtual machine has the correct host name (rhel-lab-vm).

    • Configure the /etc/motd file to display the message: This VM has been provisioned using cloud-init.

    • Create a new user called labuser with redhat as the password.

    1. On the Compute >> Virtual Machines page, click the New button. The New Virtual Machine window displays.

    2. In the Cluster menu, choose clustertwo.

    3. In the Template menu, choose cloud-lab-template.

    4. In the Name field, type rhel-lab-vm as the virtual machine name.

    5. In the Description field, type RHEL Guest for cloud-init lab as the virtual machine description.

    6. Leave all the other options as they are and click the OK button to create the new template-based virtual machine.

    7. Wait while the virtual machine is created.

    8. After the rhel-lab-vm virtual machine becomes ready to use, highlight the row containing the virtual machine by clicking an empty cell in that row.

    9. With the row containing rhel-lab-vm highlighted, click the Run drop-down menu and select Run Once to display the Run Virtual Machine(s) window.

    10. Click the + icon next to Initial Run.

    11. Make sure that the check box on the Use Cloud-init line is selected.

    12. In the VM Hostname text field, ensure that the rhel-lab-vm name is present. This will change the host name of the new virtual machine.

    13. Click Authentication to reveal the Authentication section. Enter a User Name of labuser, and a Password of redhat. Enter the password again in the Verify Password field.

    14. In the Custom Script text area, enter the following lines:

      write_files:
        - path: /etc/motd
          content: |
            This VM has been provisioned using cloud-init.
      

      Note

      YAML used by cloud-init is sensitive to white space indentation. Indent your script as shown in the example for this step, using two spaces for each indentation level. The blank line at the end (with one or more spaces) ensures a new line character is added to the end of the file.

    15. Click OK to initiate the creation of the virtual machine, using cloud-init as the provisioning method.

  5. Once the new virtual machine is ready, log in to the rhel-lab-vm virtual machine as labuser to ensure that all the changes were successfully applied by cloud-init.

    1. Once the virtual machine is running, click the Console button and verify the changes made by cloud-init. Log in as the labuser user with redhat as the password. Notice that the host name of the virtual machine is rhel-lab-vm. The message displayed after you log in matches that which cloud-init placed into the /etc/motd file. When you have finished reviewing the changes to the rhel-lab-vm virtual machine, close the virtual machine console.

Evaluation

On workstation, run the lab vms-review grade command to confirm that you have completed this exercise successfully.

[student@workstation ~]$ lab vms-review grade

Note

The grading script uses the IP address for the virtual machine reported by the qemu guest agent. If the grading script fails the check for evaluating the labuser user and the /etc/motd file, verify that the IP address for the rhel-vm1 virtual machine is visible from the Compute >> Virtual Machines page. If the IP address is not visible, try restarting the qemu-guest-agent service on the rhel-vm1 virtual machine, or shut down and then restart the virtual machine. Run the grading script again once the IP address is displayed.

Cleanup

Using the Administration Portal, manually clean up after completing the lab.

  1. Remove the rhel-lab-vm virtual machine.

    1. View available virtual machines by clicking on Compute in the menu bar and then selecting Virtual Machines. From the list of available virtual machines, highlight the row for the rhel-lab-vm virtual machine by clicking an empty cell in that row. Click the Shutdown drop-down menu, and then select Power Off. When the Power Off Virtual Machine(s) window displays, confirm powering off the machine by clicking the OK button.

    2. With the row containing the rhel-lab-vm virtual machine highlighted, click the Remove button to remove the virtual machine. When the Remove Virtual Machine(s) window appears, make sure the check box next to Remove Disk(s) is selected. Confirm the removal of the machine by clicking the OK button.

  2. Remove the cloud-lab-template template.

    1. View available templates by clicking on Compute in the menu bar, and then selecting Templates. From the list of available templates, highlight the row containing cloud-lab-template by clicking an empty cell in that row.

    2. With the row containing the cloud-lab-template template highlighted, click the Remove button to remove the template. When the Remove Template(s) window appears, click the OK button to confirm the removal of the template.

Finish

On workstation, run the lab vms-review finish script to complete this exercise.

[student@workstation ~]$ lab vms-review finish

This concludes the lab.

Revision: rh318-4.3-c05018e