Dec 15 2011

Builds, the magic between code and deployment – Part 5

A short post continuing the subject of builds with this one covering the use of virtualised infrastructure.

I would advise any software development department to make use of virtualisation – especially for appliances such as Build Agents. The choice of virtualisation product in a commercial environment typically comes down to one of two choices. Microsoft offer Hyper-V for free as a role on Windows 2008 and newer and VMWare provide ESX (both free and paid versions). Both are excellent solutions though at this time my preference is with VMWare – it’s simply a more mature product with a greater feature set. I have no experience of ESX setup/configuration however and whilst this is an area where Hyper-V scores well I would still put ESX ahead.

Both Hyper-V and ESX have similar features and either product will support a TFS build environment without issue.

One particular feature that is must have [for build eco-systems] is the ability to create template virtual machines. A template VM is a machine that is pre-configured and ready to run but repackaged as a template. The purpose of a template is to ensure successive deployments of machines based on the template will, obviously, inherit the template’s configuration and be to all intents and purposes ‘the same’.

Using a pre-configured template as a base for a machine should save considerable time and ensure consistency in the resulting machine. Build Agents are commodity appliances that simply ‘drop in’ to the TFS build eco-system or removed at will. They benefit from the template in both speed of deployment (subject to disk/network constraints) and consistency of content.

The first template to build is a base operating system and I follow a pre-defined set of actions when building one.

Create machine

Resources such as CPU, disk, memory should be sized appropriately. Whilst these are usually editable when a machine is deployed from the template, historical evidence shows that they are seldom adjusted. Resource over-allocation may soon become a problem if the template has excessive demands.
Virtualisation products typically provide support for fixed or expanding disk storage formats. If disk capacity is at a premium where the templates are stored it may help to use an expanding format.

Install Operating System

With recent versions of Windows there should be little to do bar map the DVD drive/mount the ISO and install. For those versions of Windows that support it, do not enter a license key – a template need not be licensed at this stage.

Install Operating System Service Pack

Where appropriate, insert CD/DVD/mount ISO and/or run the Service Pack installer. I perform this 1st as it generally provides the fastest way to get the most stable copy of the Operating System.

Install tools, customisations, etc.

Installation of system tools such as 7-Zip, .NET Framework, Silverlight, etc. Any system level customisations should also be applied here.

I do not usually add a template to a domain as templates have no purpose on a domain. I also name each template with a fixed naming convention (T-’OS’-'TYPE’). For example, a Windows 2008 R2 French template machine would have the following name: T-WIN2K8R2-FR.

Configure Windows Update

Even when the latest Service Pack has been recently released it’s normal for Windows Update to have an additional set of updates to apply. Sadly this can amount to significant download and installation time. I also enable Microsoft Update to allow updates for other Microsoft products (such as Visual Studio, SQL Server, Silverlight, etc.). Even though Microsoft are steadily improving the experience, it’s usually necessary to run this several times in between reboots.

Once complete I disable automatic updates on all virtual machine templates. In the context of a Build Agent, automatic updates that yield later versions of the C++ development runtime can cause issues.

Clean up machine content

Delete temporary folder files, any local downloads, internet history, etc. Not always necessary but I like to have my templates with as little context data as possible.

Convert the machine to a Template

Most virtualisation products contain inbuilt support for deploying templates. What I mean by that is they will handle machine identification changes such as SID regeneration and network name change when a machine is created from a template. If that’s the case, simply convert the machine as is. If not, Sysprep should be used to manipulate the machine state into something that will support being rolled out. Once Sysprep has completed (the machine should have shutdown) the machine can be converted to a template.

 

Hopefully the benefit of creating template machines with a ‘bare’ operating system installation should be obvious. It will be quicker to deploy the template in a consistent manner rather than repeat the above actions per machine. The next and final post of builds covers the Build Agent template virtual machine configuration and how components are built without Visual Studio.

Tags: ,

No comments

Leave a Reply

(required)