Image Builder
A set of Image Builder cmdlets are included in PowerCLI for vSphere 5. These cmdlets allow you to create custom ESXi images which can include updates, vendor software and drivers.
A bit of background information on ESXi image. An ESXi image contains a collection of packaged software components known as VMware Installation Bundles (VIBs). VIBs are used for all the parts that make up an ESXi image, including the base ESXi image, custom drivers, CIM providers and third party software. PowerCLI, with its Image Builder cmdlets, gives an administrator the ability to manipulate a base ESXi image by adding additional VIBS from different software depots, to the package. This customized package is known as an image profile.
Software Depots
The first step to creating a customised ESXi image using Image Builder is to add a software depot to your PowerCLI session. A depot is a location where vibs and image files are stored. When you add a depot, it gets added to the $DefaultSoftwareDepots session variable. However, this is only valid during the session, and will need to be exported if you want to save the configuration for a later session.
Perform the following steps to add a software depot to your PowerCLI session:
1. Run Add-EsxSoftwareDepot -DepotUrl https://hostupdate.vmware.com/software/VUM/PRODUCTION/main/vmw-depot-index.xml to add the ESXi 5.0 offline depot file.
This has added VMware’s ESXi depot, which is also what update manager users. However, there are depots from other vendors such as Cisco and HP, and you can also use a local depot. And example command for adding a local depot would be: Add-EsxSoftwareDepot “c:\tmp\VMware-Esxi-5.0.0-<buildnumber>-depot.zip”
2. To verify that the software packages were successfully added to the depot, run Get-EsxSoftwarePackage to retrieve a list of available packages.
We can now use the packages we see in the configured depots to build a custom ESXi image.
Image Profiles
An image profile will consist of a base ESXi image, but can also be combined with additional VIBs from VMware or third party vendors. They can be used to build your own customised ESXi install media, or can be uploaded for use with an Auto Deploy server.
Creating an Image Profile
We’ll create our own new image profile by cloning an existing one. To list the available image profiles in the software depot’s we added earlier, run the following command:
Get-EsxImageProfile
To clone an image profile we can run:
New-EsxImageProfile -CloneProfile “ESXi-5.0.0-20120302001-standard” -Name “MyAutoDeploy_Profile”
This will create a new Image Profile based on the ESXi-5.0.0-20120302001-standard profile listed above.
Editing an Image Profile
Now that we have our custom image profile we can edit it by adding or removing VIBs. The two cmdlets that allow you to do this are Add-EsxSoftwarePackage and Remove-EsxSoftwarePackage.
The following command is an example of adding an additional software package, such as a driver, to an image profile:
Add-EsxSoftwarePackage -ImageProfile “MyAutoDeploy_Profile” -SoftwarePackage packagename
Once you have added the packages, you can verify that your packages have been added by comparing the software packages in your profile to the ones contained in the base ESXi image profile. You do this by running the Compare-EsxImageProfile cmdlet. If necessary you can remove packages from your image profile by using the Remove-EsxSoftwarePackage cmdlet.
One package that you will want to add to your image profile if you are using it with Auto Deploy, and are going to add the host to a HA Cluster, is the vmware-fdm package. To add the vmware-fdm software package to the new Image Profile first you need to add the depot:
Add-ESXSoftwareDepot -DepotUrl https://vcenteripaddress:80/vSphere-HA-depot
Then add the package to your image profile:
Add-ESXSoftwarePackage -ImageProfile “MyAutoDeploy_Profile” -SoftwarePackage vmware-fdm
Exporting an image profile
When you have finished building your image profile you will need to export it. Exporting the image profile downloads the VIBs from the connected software depots and validates the VIB signatures. An image profile can be saved as either an ESXi .iso image or as an offline depot .zip file.
The following commands provide examples of exporting an image profile:
Export-EsxImageProfile -ImageProfile “MyAutoDeploy_Profile” -ExportToBundle -FilePath “C:\Software\Exports\AutoDeploy_Profile.zip”
Export-EsxImageProfile -ImageProfile “MyAutoDeploy_Profile” -ExportToIso -FilePath “C:\Software\Exports\AutoDeploy_Profile.iso”