7.9. Using Sysprep to Automate the Configuration of Virtual Machines

Sysprep is a tool used to automate the setup of Windows virtual machines; for example, configuring host names, network interfaces, authorized keys, set up users, or to connect to Active Directory. Sysprep is installed with every version of Windows.
Red Hat Virtualization enhances Sysprep by exploiting virtualization technology to deploy virtual workstations based on a single template. Red Hat Virtualization builds a tailored auto-answer file for each virtual workstation.
Sysprep generates a complete unattended installation answer file. Default values for several Windows operating systems are available in the /usr/share/ovirt-engine/conf/sysprep/ directory. You can also create a custom Sysprep file and reference it from the the osinfo file in the /etc/ovirt-engine/osinfo.conf.d/ directory. These files act as templates for Sysprep. The fields in these files can be copied and edited as required. This definition will override any values entered into the Initial Run fields of the Edit Virtual Machine window.
The override file must be created under /etc/ovirt-engine/osinfo.conf.d/, have a filename that puts it after /etc/ovirt-engine/osinfo.conf.d/00-defaults.properties, and ends in .properties. For example, /etc/ovirt-engine/osinfo.conf.d/10-productkeys.properties. The last file will have precedence and override any other previous file.
Copy the default values for your Windows operating system from /etc/ovirt-engine/osinfo.conf.d/00-defaults.properties into the override file, and input your values in the productKey.value and sysprepPath.value fields.

Example 7.2. Windows 7 Default Configuration Values

# Windows7(11, OsType.Windows, false),false
os.windows_7.id.value = 11
os.windows_7.name.value = Windows 7
os.windows_7.derivedFrom.value = windows_xp
os.windows_7.sysprepPath.value = ${ENGINE_USR}/conf/sysprep/sysprep.w7
os.windows_7.productKey.value =
os.windows_7.devices.audio.value = ich6
os.windows_7.devices.diskInterfaces.value.3.3 = IDE, VirtIO_SCSI, VirtIO
os.windows_7.devices.diskInterfaces.value.3.4 = IDE, VirtIO_SCSI, VirtIO
os.windows_7.devices.diskInterfaces.value.3.5 = IDE, VirtIO_SCSI, VirtIO
os.windows_7.isTimezoneTypeInteger.value = false

7.9.1. Configuring Sysprep on a Template

You can use this procedure to specify a set of standard Sysprep settings to include in the template, alternatively you can configure the Sysprep settings when creating a virtual machine based on this template.
Replacement strings can be used to substitute values provided in the default files in the /usr/share/ovirt-engine/conf/sysprep/ directory. For example, "<Domain><![CDATA[$JoinDomain$]]></Domain>" can be used to indicate the domain to join.

Important

Do not reboot the virtual machine while Sysprep is running.

Prerequisites

  • The Windows virtual machine parameters have been correctly defined.
    • If not, click Edit the Virtual Machines tab and enter the required information in the Operating System and Cluster fields.
  • The correct product key has been defined in an override file on the Manager.

Procedure 7.13. Using Sysprep to Prepare a Template

  1. Build the Windows virtual machine with the required patches and layered software.
  2. Create a template based on the Windows virtual machine. See Section 7.2, “Creating a Template”
  3. Update the Sysprep file with a text editor if additional changes are required.
You can now provision new virtual machines using this template.

7.9.2. Using Sysprep to Initialize a Virtual Machine

Use Sysprep to automate the initial configuration of a Windows virtual machine. You can use the Sysprep fields to configure a virtual machine's host name, time zone, root password, authorized keys, network interfaces, and DNS service.

Procedure 7.14. Using Sysprep to Initialize a Virtual Machine

This procedure starts a virtual machine with a set of Sysprep settings. If the relevant settings are included in the template the virtual machine is based on, review the settings and make changes where required.
  1. Create a new Windows virtual machine based on a template of the required Windows virtual machine. See Section 7.10, “Creating a Virtual Machine Based on a Template”
  2. Click the Virtual Machines tab and select the virtual machine.
  3. Click Run Once.
  4. Expand the Boot Options section, select the Attach Floppy check box, and select the [sysprep] option.
  5. Select the Attach CD check box and select the required Windows ISO from the drop-down list.
  6. Move the CD-ROM to the top of the Boot Sequence field.
  7. Configure any further Run Once options as required. See Section A.5, “Explanation of Settings in the Run Once Window” for more details.
  8. Click OK.