For most VMware administrators, managing VM templates is a manual and tedious task that is probably given to
the new person on the team as a cruel form of initiation.
It doesn't have to be this way. This post will cover
how you can utilize a few awesome technologies to produce fully automated VMware templates and deploy those
templates into your envionrment.
- Build server
- Build Server Software
- Chocolatey - Package management for Windows.
- Packer - Automates the creation of machine images.
- VMWare Workstation - Desktop virtualzation.
- psake - A build automation tool. Use it. Love it.
- BoxStarter - Repeatable, reboot resilient Windows environment installations using Chocolatey packages.
- PowerCLI - PowerShell module for managment VMware vSphere.
- Artifactory - Artifact repository manager.
- ovftool - Command-line utility for importing and exporting OVF packages.
- curl - Command-line utility for transfering data.
First off your going to want to provision a build server that this process will run on. For this post, I’m going to use a vanilla but fully patched Windows 2012 R2 VM. You’re going to want to assign enough resources (vCPU and RAM) to this VM in order to run VMware Workstation. You’ll also want to assign a decent amount of storage to handle the VMWare Workstation VM and associated artifacts as part of the build process.
Yes, we’re going to be using nested virtualization (having a VM run another VM to produce another VM). That’s very meta isn’t it :)
Build server resources
- VM: Windows 2012 R2 Standard
- vCPU: 2
- vRAM: 6GB
- Storage: C:\ 100 GB D:\ 50 GB
We’re going to need a fairly big
Cdrive as Packer will copy the
.vmdkproduced during it’s build phase to
$env:tempduring it’s post-processor phase. These temporary files will be automatically cleaned up by Packer.
Build Server Software
Install the following software on the build server with Chocolatey. Feel free to use other installation methods if you like.
Chocolatey, Packer, psake, and curl
Grab a copy of VMWare workstation and run the following command to install.
Download the latest version of PowerCLI and run the following command to install. You can start here.
Download ovftool from https://www.vmware.com/support/developer/ovf