Rapid Deployment using templates

A template is a copy of a preconfigured virtual machine, used to simplify the subsequent, repeated creation of similar virtual machines. Templates capture the installed software, software configuration, and hardware configuration of the original virtual machine. When administrators need to deploy multiple (mostly) identical machines, it can be beneficial to use templates instead of doing multiple installations.

A template can be seen as a bit-for-bit copy of the original disk image and bears many resemblances to imaging a machine with tools like Clonezilla or Ghost. Just like an automated installation such as Kickstart, this helps maintain consistency across machines, making management and troubleshooting easier.

When working with virtual machines, basing machines on a template can also help reduce memory usage. Since machines based on the same template will be very similar, Kernel Same-page Merging (KSM) has a higher chance of finding duplicate memory pages on those machines that can be merged in physical memory.

NOTEOne of the challenges involved in using templates is making sure that no identifying information, such as references to MAC addresses or SSL certificates, are left behind since these may cause issues when multiple machines are deployed from the same template. This process is called sealing the image.


Consider the following procedure outlining the steps necessary to create a template from an existing virtual machine:

1. Install a fresh virtual machine to be the baseline for the template.

2. Seal the image. This means that all information unique to the original virtual machine needs to be removed. This includes hardware information specific to the original virtual machine, such as MAC addresses; unique system configurations, such as the host name and static IP addresses; and possibly logs and other data.

3. Shut down the sealed virtual machine.

4. Create a template from the virtual machine using the Administration Portal.

5. Test the template by creating another virtual machine based on the new template.

NOTE:For Linux virtual machines, Red Hat Virtualization can use virt-sysprep to seal the image as it creates the template. Virtual machines running other operating systems need to be sealed before creating the template.

To create a template, administrators need to select the Virtual Machines tab, right-click the virtual machine they want to use for the template, then select Make Template from the menu. This brings up a dialog like the one shown as follows.

The New Template dialog

The following list describes the settings for the New Template window:

  • Name – The name of the template. This will be listed in the Templates tab in the Administration Portal. It must be a unique name with any combination of uppercase and lowercase letters, numbers, hyphens, or underscores.
  • Description – A limited description of the template. This field is recommended but not mandatory.
  • Comment – A field for adding plain text, human-readable comments about the template. For example, you might use this to elaborate on the purpose or even the usage of a template.
  • Cluster – The cluster with which the template is associated. This is the same as the original virtual machine’s cluster by default. However, any cluster in the data center can be selected.
  • CPU Profile – An advanced feature used to limit how much CPU capacity a virtual machine can use on a host. The default setting imposes no limit. Use CPU Profile to define the maximum amount of processing capability a virtual machine can access on its host. This is expressed as a percent of the total processing capability available on a host. See the Administration Guide for more information.
  • Disks Allocation
    • Alias: An alias for the virtual machine disk used by the template. By default, the alias is set to the same value as that of the source virtual machine.
    • Virtual Size: The current actual size of the virtual disk used by the template. This value cannot be edited, and is provided for reference only.
    • Format: The format of the disks that the template should use. A QCOW2 format always implies that a disk is thin provisioned. The RAW format in file storage implies thin provisioned, while RAW on block storage implies preallocated virtual disks.
    • Target: The storage domain on which the virtual disk used by the template is stored. By default, the storage domain is set to the same value as that of the source virtual machine. Any storage domain in the cluster can be selected.
  • Allow all users to access this Template – Specifies whether a template is public or private. A public template can be accessed by all users, whereas a private template can only be accessed by users with the TemplateAdmin or SuperUser roles.
  • Copy VM permissions – Copies permissions set on the source virtual machine to the template.
  • Seal Template – Seals the template using virt-sysprep. If you are not able to use this option, you must manually seal the virtual machine image before using this window to create the template.
  • This procedure describes the steps needed to create a sealed template from an existing Linux virtual machine:

    1. From the list of available virtual machines, select the appropriate virtual machine.
    2. Make sure that the virtual machine is powered down.
    3. With the virtual machine selected, click the Make Template button.
    4. Specify a Name, Description, and Comment for the template.
    5. Select the appropriate cluster for the template.
    6. Optionally, select a CPU Profile for the template, if any are available.
    7. Select the disk format, the storage domain, and the disk profile. By default, they are the same as those of the source virtual machine.
    8. To make this template public, select the Allow all users access to this Template check box.
    9. Select the Seal Template check box to automatically run the commands to seal a Linux-based template.
    10. Click the OK button to create the template.

    While the template is being created, the virtual machine status displays an Image Locked status.The process of creating the template may take a long time, depending on the size and number of the virtual disks, and the underlying storage hardware. When finished, the template is added to the Templates tab.

    NOTE: Non-Linux virtual machines must be manually sealed and shut down prior to using them to create the template. The procedure to do this varies depending on the operating system. For example, Microsoft Windows systems usually use Sysprep to seal images for use in templates. Red Hat Virtualization provides some files to assist you with this process.

    Using a template to create a new virtual machine

    Once a template has been created from a virtual machine, administrators can create new virtual machines using that template.

    To create a new virtual machine from an existing template:

    1. Log in to the Administration Portal and navigate to the Virtual Machines tab. Click the New VM button to bring up the New Virtual Machine window.
    2. In this window, enter a Name and Description for your new virtual machine. In the Template drop-down menu, select the appropriate template for the virtual machine.
    3. With the New Virtual Machine window still open, make sure that you can see the advanced options. Click on Show Advanced Options if they’re not displayed. Navigate to the Resource Allocation tab. In that tab, select how to provision the virtual disks for the new server. If Provisioning is set to Thin, an overlay is used on top of the original template. If Provisioning is set to Clone, the original template is cloned and the Format option to select (per disk) a Raw or QCOW2 image becomes available.
    4. Click OK to create the virtual machine. Wait for its Status to go from Image Locked to Down before proceeding.
    5. Start the new virtual machine by right-clicking it in the Virtual Machines tab and selecting Run from the context menu.
    6. Open a console to the new virtual machine by right-clicking it and selecting Console from the context menu.