Here at work we are about to embark on a complete redesign of our virtual infrastructure from the ground up. As I’ve mentioned before with our IOPs issues with View, we went from PoC to Production without scaling all resources evenly. So starting from scratch means redoing everything, all the way down to standardizing ESXi ISO images. I have been attending vBrownBag’s (Professional VMware) #AutomateAllThings video session about how automation can help with everyday tasks to overhauling your environment.
Why not automate the creation of ESXi images for my various clusters? Great idea since each cluster has different NIC’s, Drivers, Graphics Cards, etc. so let’s throw all of my VIB’s into my image as opposed to doing it manually like I did during my vSGA evaluation.
To start you will need a few things to get started:
- Vanilla ZIP instance of ESXi 5.5
- All VIB’s that you want to load into your image
- PowerCLI 5.5
- MS PowerShell v2 (Running Windows 7 or 8 it will be installed)
- Free Space on your Computer (kinda obvious but you never know!)
Now that we have everything let’s assume you have already installed PowerShell and PowerCLI on your workstation and are ready to start, if you haven’t here are some helpful links to aid you in installing those packages. Install PowerShell. Install PowerCLI. You probably received a prompt during the installation of PowerCLI talking about execution policy issues may arise, fear not we will take care of that right now. Navigate to your Start Menu or Desktop and locate the PowerShell icon, right click and select “Run as Administrator”. When PowerShell opens, run the following command:
Your screen should look something similar to this:
You can close PowerShell since the remainder of the work will be done in PowerCLI, run PowerCLI (always run CLI as administrator) and you should see this:
First let’s create a small folder structure to organize our custom ISO’s, me personally I am going to be building 3 ISO’s for three separate cluster configurations. I also wrote my scripts in Notebook++ so I can look at the individual lines for each function.
Here is the framework for the script that I will run:
Get-PSSnapin -Name VMware.ImageBuilder Add-EsxSoftwareDepot C:\ESXi_Depot\VMware-ESXi-5.5.0-1331820-depot.zip Add-EsxSoftwareDepot C:\ESXi_Depot\Server_Cluster\igb-22.214.171.124-offline_bundle-1290233.zip Add-EsxSoftwareDepot C:\ESXi_Depot\Server_Cluster\ixgbe-3.18.7-offline_bundle-1327252.zip Add-EsxSoftwareDepot C:\ESXi_Depot\Server_Cluster\NVIDIA-VMware-x86_64-319.65-1OEM.5126.96.36.1991820-bundle.zip Get-EsxImageProfile | Format-Table -AutoSize New-EsxImageProfile -CloneProfile ESXi-5.5.0-1331820-standard -Name ESXi-5.5.0.ServerCluster.Customised -AcceptanceLevel PartnerSupported Export-EsxImageProfile -ImageProfile ESXi-5.5.0.ServerCluster.Customised -ExportToIso -FilePath C:\ESXi_Depot\BOXX_Cluster\ESXi-5.5.0.ServerCluster.Customised.iso
Let’s go through each step of this process and explain what each function does.
Get-PSSnapin -Name VMware.ImageBuilder
Get-PSSnapin is the call function to bring VMware Image Builder into PowerCLI if you don’t have it already loaded in your instance of PowerCLI you will need to run this command.
Add-EsxSoftwareDepot is the call to add my ESXi image (ZIP format) and then all of my VIB’s to my image, each VIB requires a separate line. After you run this command you will get a spit of like this:
Once you have added all of your VIB’s to the depot then we need to look at the actual ESXi image we introduced to the image builder and determine which profile we want to use, that is the intent of the Get-EsxImageProfile function. You will get a table of the profiles to choose from:
Next we use the New-EsxImageProfile to clone the profile and name it what we want!
Finally we run the Export-EsxImageProfile function to compile our depot of VIB’s to produce our custom ESXi ISO as shown here:
Now I have my custom image that I can load to my hosts when I do my complete virtual infrastructure redesign.
Big thanks to vStrong.info for his article on VMware Image Builder and Alan Renouf on getting PowerCLI setup.
You must be logged in to post a comment.