7.10. 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.
You can create a custom sysprep
file when creating a pool of Windows virtual machines, to accommodate various operating systems and domains. See Creating a Virtual Machine Pool in the Administration Guide for details.
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.10.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.
Do not reboot the virtual machine while Sysprep
is running.
Prerequisites
The Windows virtual machine parameters have been correctly defined.
If not, click
, click , 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.
Using Sysprep
to Prepare a Template
- Build the Windows virtual machine with the required patches and software.
- Seal the Windows virtual machine. See Sealing Virtual Machines in Preparation for Deployment as Templates
- Create a template based on the Windows virtual machine. See Creating a template from an existing virtual machine
-
Update the
Sysprep
file with a text editor if additional changes are required.
You can now provision new virtual machines using this template.
7.10.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.
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.
- Create a new Windows virtual machine based on a template of the required Windows virtual machine. See Creating a Virtual Machine Based on a Template.
-
Click
and select the virtual machine. - Click the Run Once. drop-down button and select
- Expand the Boot Options section, select the Attach Floppy check box, and select the [sysprep] option.
- Select the Attach CD check box and select the required Windows ISO from the drop-down list.
- Move the CD-ROM to the top of the Boot Sequence field.
- Configure any further Run Once options as required. See Virtual Machine Run Once settings explained for more details.
- Click .