Introduction to Creating and Deploying Templates

One of the benefits of VMs is how easy they can be cloned – gone are the days of having tediously install OSes or wrestle with complicated scripted deployment tools. vSphere offers a number of different method of duplicating VMs. In fact I think the easy of deploying VMs has done a lot to expose subterranean amount of inefficiencies that will previously hidden by the whole rigamarole of buying new physical hardware. As with all things networking – when you remove one bottleneck (provisioning) it merely exposes hidden bottlenecks elsewhere in our processes – that’s the primary reason tools like vCD and vCAC of interest to VMware customers. The answer to all bottlenecks is greater automation and self-service.

Firstly, a VM whilst powered on can be cloned. This can be useful if you want a perfect copy of existing production VM for testing purposes or for use in an development environment. However, care must be taken not to create hostname and IP conflicts with the original source VM. Typically, people patch the cloned VM to different portgroup or temporarily disconnect the network card.

An existing VM can be cloned into the template format, or converted into a template. The difference is really if you want to keep the existing VM for another purpose, or if you want avoid an unnecessary copy process. A template is very similar to a VM, the only difference really is instead of having a .VMX file, it has .VMTX file registered with vCenter. In this state the VM cannot be powered on and modified, unless it is converted back into a VM. The vSphere Web Client also supports the copying of template into another template.

All the different clone/convert options are available from the New Virtual Machine Wizard:

Screen Shot 2014-04-30 at 14.21.23.png

Also on the right-click of a VM you will see Clone to Virtual Machine and Clone To Template.

Screen Shot 2014-04-30 at 14.22.09.png

You will find the Covert to Template option under All vCenter Actions on the right-click of a VM. This is my personal favourite. On a clean system, often the first VM I build is my golden/master copy of Windows or Linux. I build it up just I want it to be, before gracefully powering it down, and converting it to a template – it then forms the basis of all my other VMs.

Screen Shot 2014-04-30 at 14.25.10.png

Clone an existing VM…

1. Open the New Virtual Machine wizard, and select Clone an existing virtual machine

Screen Shot 2014-04-30 at 14.43.45.png

2. Next explorer the inventory to select VM you wish to clone

Screen Shot 2014-04-30 at 14.45.12.png

The option to Customize the Operating System will trigger the use of Sysprep in Windows and customization scripts in Linux to allow for the renaming and re-ip of the VM. In the case of Windows it can also facilitate the process of joining the Microsoft Active Directory domain. The option to Power on Virtual Machine after creation will power on the VM after the clone process has completed – this potential cause problems if customization has happened or if the VM is place on the same network segment as the source. The option to Customize this virtual machine’s hardware (experimental) has been marked as experimental for sometime by VMware, it allows to modify the assignment of memory, CPU and other resources to the VM prior to the clone process powering on the VM.

3. Next, set a name for the cloned VM, and a location in the vCenter Inventory

Screen Shot 2014-04-30 at 15.52.08.png

4. Select a Host, Cluster or Resource Pool to that will provide resources to the clone

Screen Shot 2014-04-30 at 15.55.56.png

5. Next select a datastore to hold the cloned. The option for the disks to be use the Same format as source – will ensure if the source is using thickly provisioned disks, the cloned VM will as well – and if the source is thinly provisioned the virtual disks of the clone VM will be same as well. The pull-down list does allow the administrator over-ride this – and change the target cloned disk format if necessary.

Screen Shot 2014-04-30 at 15.57.32.png

Note: Once the clone has completed you can edit it settings, patch it to different network and power it on.

Convert to Template…

The Convert to Template option is a very quick and easy method to take an existing VM and turn it into a template. The main advantage is the conversion process takes seconds, as no copy process takes place. The VM is merely unregistered, and re-registered with vCenter as template. One the primary advantages is that it is as quick to take a template, and convert it back to being a VM again. This assists with keeping the VM up to date. For instance, once a month a template could be converted back into a being a VM and powered on – then various software updates could be carried out such as Windows Update, YUM Update or other ancillary software updates such as Anti-virus,.NET, Java and Flash updates. Once these updates have been completed the VM can be powered off, and converted back to template – ensuring that any newly deployed VM is using the most current software available.

1. Locate the VM in the VM and Templates View, and gracefully shutdown the VM that will be converted to a template

2. Right-click the VM, and under vCenter Actions, select Convert to Template

Screen Shot 2014-04-30 at 14.25.10.png

Note: If you are in the Host & Cluster view you should see that VM disappears. This is because templates are not shown in this view. Switch to the Virtual Machine and Templates view if this is the case. You should notice that icon has change for the VM “boxes in boxes” icon to one that resembles a folder of paper. If you have created VM Folders to hold your templates you use drag and drop to relocate them.

Screen Shot 2014-04-30 at 16.31.31.png