You can use vSphere Auto Deploy to reprovision a host with a new image profile in a PowerCLI session by changing the rule for the host and performing a test and repair compliance operation.
Several options for reprovisioning hosts exist.
- If the VIBs that you want to use support live update, you can use an esxcli software vib command. In that case, you must also update the rule set to use an image profile that includes the new VIBs.
- During testing, you can apply an image profile to an individual host with the Apply-EsxImageProfile cmdlet and reboot the host so the change takes effect. The Apply-EsxImageProfile cmdlet updates the association between the host and the image profile but does not install VIBs on the host.
- In all other cases, use this procedure.
Procedure
- At the PowerShell prompt, run the Connect-VIServer PowerCLI cmdlet to connect to the vCenter Server system that vSphere Auto Deploy is registered with.
Connect-VIServer ipv4_or_ipv6_address
The cmdlet might return a server certificate warning. In a production environment, make sure no server certificate warnings result. In a development environment, you can ignore the warning.
- Determine the location of a public software depot that contains the image profile that you want to use, or define a custom image profile with vSphere ESXi Image Builder.
- Run Add-EsxSoftwareDepot to add the software depot that contains the image profile to the PowerCLI session.
Depot Type |
Cmdlet |
Remote depot |
Run Add-EsxSoftwareDepot depot_url. |
ZIP file |
- Download the ZIP file to a local file path or create a mount point local to the PowerCLI machine.
- Run Add-EsxSoftwareDepot C:\file_path\my_offline_depot.zip.
|
- Run Get-EsxImageProfile to see a list of image profiles, and decide which profile you want to use.
- Run Copy-DeployRule and specify the ReplaceItem parameter to change the rule that assigns an image profile to hosts.
The following cmdlet replaces the current image profile that the rule assigns to the host with the
my_new_imageprofile profile. After the cmdlet completes,
myrule assigns the new image profile to hosts. The old version of
myrule is renamed and hidden.
Copy-DeployRule myrule -ReplaceItem my_new_imageprofile
- Test the rule compliance for each host that you want to deploy the image to.
- Verify that you can access the host for which you want to test rule set compliance.
Get-VMHost -Name ESXi_hostname
- Run the cmdlet that tests rule set compliance for the host, and bind the return value to a variable for later use.
$tr = Test-DeployRuleSetCompliance ESXi_hostname
- Examine the differences between the contents of the rule set and configuration of the host.
The system returns a table of current and expected items if the host for which you want to test the new rule set compliance is compliant with the active rule set.
CurrentItem ExpectedItem
----------- ------------
my_old_imageprofile my_new_imageprofile
- Remediate the host to use the revised rule set the next time you boot the host.
Repair-DeployRuleSetCompliance $tr
- Reboot the host to provision it with the new image profile.