Manage Learn to apply best practices and optimize your operations.

Simplicity is vital to a well-built VM template

VM templates can help you maintain consistency, but don't go overboard and try to include every possible setting or application.

In any large organization it is important to deploy virtual machines consistently. Consistency makes the deployment...

process more efficient, and it leads to more predictable results. One of the best ways to make sure that VMs are deployed consistently is to use a VM template.

A VM template is essentially just a VM that can be cloned in order to create other VMs. Both Microsoft and VMware offer such functionality, although the specifics vary from one hypervisor to another. Regardless of the hypervisor used, there are some best practices that you should follow when creating VM templates.

One such best practice is to fully patch the VM from which the template is going to be created. New operating system patches are released on a regular basis, so it is unrealistic to expect to always have a template that includes the latest patches. Even so, fully patching a VM prior to building a template will reduce the amount of time that it takes to patch new VMs that are spawned from the template because some patches will have already been applied.

In the case of Windows VMs, templates have to be randomized. Essentially this means that any machine-specific information has to be scrubbed from the VM prior to using that VM as a template. This can be achieved by using the Sysprep tool. The Sysprep tool gets rid of things such as the computer name and any globally unique identifiers.

Because the VM has to be randomized before being converted to a template, there are certain things that you should avoid doing when creating the template VM. First, you must avoid joining the VM to a domain prior to running Sysprep. Instead, domain membership can be achieved at the time that the template is used to generate a VM. Similarly, you must avoid using static IP addresses on template VMs.

So, if a VM template contains a randomized VM, where do the template deployment parameters come from? The answer varies depending on the software that is being used, but in the case of Microsoft Virtual Machine Manager, a guest OS profile is used to store things like the product key, administrative password and domain membership information. This profile can also be used to specify operating system level configuration items such as the roles and features that are be to be installed and the time zone in which the VM will operate. In essence, the guest OS profile takes the place of a Sysprep answer file.

You will also need to be careful about installing applications on the VM. Some applications are minimally invasive and can be safely installed on a VM that is to be used as a template. For example, I use a very simple screen capture application for the books and articles that I write. This application consists of a self-contained executable and can be safely included in a VM template.

Of course, this raises the question of how you should deal with applications with regard to template VMs. Unfortunately, there is no universally applicable answer to this question. The hypervisor, guest operating system and application all play a role in the decision-making process. As a general rule, however, it is usually best to avoid installing an application directly into a template VM. Instead, applications should be installed after the resulting VM has been created or as a part of the VM creation process. Again, the specifics depend on the application, guest OS and hypervisor.

To give you a more concrete example, consider some of the features that are included in Microsoft System Center 2012 R2 Virtual Machine Manager. The Virtual Machine Manager library includes more than just VM templates. It also allows for the creation of application profiles. An application profile contains instructions for installing an application either natively or through the use of a script.

Some applications are designed to span multiple servers. Deploying multi-tier applications greatly complicates the template-based deployment process, but it does not make it impossible. Virtual Machine Manager provides a special type of VM template called a service template that can be used to deploy multi-tier applications that span multiple VMs.

One last best practice that I want to mention is that if you are using Virtual Machine Manager, it is a good idea to create hardware profiles for your VMs. Earlier, I mentioned the importance of deploying VMs in a consistent manner. A hardware profile standardizes the hardware allocation during the VM creation process. For example, such a profile might be used to specify that VMs should receive 4 GB of memory. The hardware profile can be directly referenced within the VM template.

When it comes to creating and using template VMs, the best option is often to take a modular approach. Rather than trying to create a monolithic template that includes every possible setting or application, it is best to make use of other components, such as application profiles and hardware profiles. Doing so allows template-based deployments to be modified with a minimal amount of work.

This was last published in November 2014

Dig Deeper on Virtual machine provisioning and configuration

PRO+

Content

Find more PRO+ content and other member only offers, here.

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchVMware

SearchWindowsServer

SearchCloudComputing

SearchVirtualDesktop

SearchDataCenter

Close