Automating My Home Lab Part 1

ESXi, Puppet Bolt, and the OVFTool

In a moment of quiet I started to think about how to improve my home lab VM deployment strategy although strategy is a strong word for it ! Currently I use basic server build ESXi virtual machines for 2K12 R2, 2K16, and 2K19 that have been sysprep’d and perform an autologon to set the machine name, IP details, and join the Domain. The Powershell script I use pulls variables from the vmx file or prompts me to set the details if I forget to add them. Not the most elegant of solutions but it did mean I could deploy a new VM in about 15 minutes albeit with a lot of manual intevention.

Enter Puppet Bolt as I was looking around at things and came across some articles on the web about using Bolt to execute scripts on ESXi hosts which peaked my interest. Of course, it still meant that I needed deploy an OVF to my hosts before it would work so off I went again to see if you could import an ovf in the ESXi shell.

Running the OVFTool from an ESXi host command line

I stumbled across the article How to Deploy an OVF Located On ESXi Datastore Using ovftool on and after a bit of fiddling, I got it working so enter the OVFTool. Below are the steps I performed to get it working on an ESXi 6.5 Build 16207673 host:

  1. Downloaded the Linux 32-bit OVFTool version 4.1.0 (Version 4.4.0 wouldn’t work)
  2. Installed on to a minimal installation of CentOS 7
  3. Copy the /usr/lib/vmware-ovftool folder to the ESXi Host local DataStore
  4. Edited the file /vmfs/volumes/datastore1/vmware-ovftool/ovftool and changed to first line from #!/bin/bash to #!/bin/sh

After that the OVFTool worked fine from my ESXi hosts and once I’d mounted my OVF NFS share as a DataStore on them I could import an OVF from there but as the article says, it’s not a supported configuration by VMWare.

Using Puppet Bolt to deploy the OVFs

The article which gave me the idea to try using Puppet Bolt I came across was Getting Started with Puppet Bolt on and after following the initial test script to execute a simple script I created my own for deploying an OVF shown below:

/vmfs/volumes/DataStore-1/vmware-ovftool/ovftool --allowExtraConfig --noSSLVerify --name="Lost-It-DC" -dm=thin -ds=DataStore-2 --net:"VM-Network"="Infrastructure" /vmfs/volumes/OVF-Store/2K19-Core-Template/2K19-Core-Template.ovf "vi://autodeployer:{password}@lost-esxi1"

Below is a breakdown of the command line piece by piece to show what means what and why it’s being used:

  1. /vmfs/volumes/DataStore-1/vmware-ovftool/ovftool – Where the OVFTool is installed
  2. –allowExtraConfig – Needed adding to allow additional vmx declarations to be added
  3. –noSSLVerify – My ESXi hosts are running with the self generated certificates
  4. –name=”Lost-It-DC01″ – Name of the VM to create
  5. -dm=thin – Deploy as a thin provisioned disk
  6. -ds=DataStore-2 – DataStore to deploy the VM to
  7. –net:”VM-Network”=”Infrastructure”
  8. /vmfs/volumes/OVF-Store/2K19-Core-Template/2K19-Core-Template.ovf – OVF location
  9. “vi://autodeployer:{password}@lost-esxi1” – User, password, and ESXi host name

Now from my automation server I can deploy a VM named Lost-It-DC01 on to my ESXi host lost-esxi1 by executing bolt script run –targets lost-esxi1

It’s proved to me how useful Puppet can be and my ambition is to deploy VMs for a Citrix lab environment with as little intervention as possible. This is step one being able to deploy flat build Windows Server 2019 Core or GUI VMs with the Puppet agent installed and step two is where the fun will really begin !

Leave a Reply

Your email address will not be published.