By provisioning a template of the most used operating systems in your virtual environment you can save time deploying new virtual machines and ensure a consistent standardisation of guests across the estate. A template takes the virtual disks and virtual machine configuration files and forms a master image, from which new virtual machines with the same configuration settings can be deployed. Furthermore a customisation specification can be applied to make OS specific customisations such as host name, domain join, product key, etc. as well as generating a new SID for each VM.
In this post we will create a virtual machine running Windows Server 2016, convert it to a template, create a customisation specification, and then deploy a new virtual machine using the template and OS customisation. A virtual machine can be converted to a template or cloned to a template to leave the virtual machine intact. A template cannot be powered on or altered but can be converted back to a virtual machine if modifications are needed at a later date. Templates and customisation specifications both require a vCenter Server instance.
Creating a Template
First we need to provision a new virtual machine to act as the base for our template. Select Create a new virtual machine and click Next.
Give the virtual machine a name and select a folder location, click Next.
Select the destination compute resource; host or cluster and click Next.
Select the storage to use for the virtual machine and click Next. Verify the version of ESXi in use in your environment and click Next; this sets the virtual machine hardware version, which can be upgraded at a later date but cannot be downgraded.
Select the operating system that will be used, this does not install the OS but determines the version of VMware Tools to use.
Amend the virtual hardware settings if required and click Next. On the review page click Finish, the virtual machine will now be deployed.
Once the virtual machine is provisioned install the guest operating system. To mount an ISO click the virtual machine in the vSphere inventory, on the Summary tab under VM Hardware locate CD/DVD Drive 1. Click the disconnected symbol and select to connect to the host drive, or mount a file from a shared datastore. To mount installation media from your client machine install the VMware Remote Console Application available from VMware downloads. Launch the Remote Console from the summary tab of the virtual machine.
After the guest OS is installed the first thing to do is install VMware Tools. Right click the virtual machine in the vSphere inventory and select Guest OS, Install VMware Tools.
Apply the necessary customisations to the operating system as required. When ready shut down the guest OS cleanly. Right click the virtual machine in the vSphere inventory and select Template, Convert to Template. Remember to remove any ISO mappings or other settings which should not be applied to virtual machines deployed from this template.
Templates are only visible in the VMs and Templates view (not in Hosts and Clusters). The inventory icon also changes from the standard virtual machine to a template icon. Before deploying virtual machines from our newly created template we should setup a customisation specification, to configure OS specific aspects of the guest and create a new SID for each VM.
On the home page of the vSphere web client navigate to Customisation Specification Manager. Click the new customisation specification icon to load the wizard. Amend the target VM operating system as appropriate and enter a name and description, click Next.
Enter the registration information for the operating system and click Next.
Select the desired option for the host name, this sets the computer name within the operating system. Click Next.
Enter the product key to use with the operating system and click Next.
Set the administrator password and tick the auto logon box if required, then click Next.
Set the time zone for the operating system to use and click Next.
Enter any commands to run at user log on and click Next.
Configure the network settings and click Next.
If the virtual machine should join a domain enter these details here and click Next.
Accept the default value to generate a new SID and click Next.
Confirm the details on the review screen by clicking Finish. The customisation specification is now ready to use when deploying a virtual machine.
Deploy a VM
Finally we can deploy a virtual machine using the newly created template and customisation specification. Locate the template in the vSphere inventory – remember to browse using VMs and Templates. Right click the template and select New VM from This Template. Enter a name for the virtual machine and select a folder location, then click Next.
Select the compute to use (host or cluster) and the storage for the virtual machine files. On the clone options page tick Customise the operating system and Power on virtual machine after creation, then click Next.
Select the customisation specification to use and click Next. On the review page click Finish.
A new virtual machine will be deployed from the template, powered on, and have the guest customisations applied that we configured earlier. It is worth noting that the customisation specification can take a few minutes to apply.
To learn how to convert a physical server to a virtual machine see the Physical to Virtual Machine Conversion Guide.