posted

14 Comments

A common Auto Deploy issue I come across is:  “I just added a new image profile and updated the rules on the Auto Deploy server, but when I reboot my vSphere hosts they still boot from the old image”.

This situation occurs when you update the active ruleset without updating the corresponding host entries in the auto deploy cache.  The first time a host boots the Auto Deploy server parses the host attributes against the active ruleset to determine (1) the image profile to install on the host, (2) the host profile to configure the host, and (3) the where in the vCenter inventory to add the host.  This information then gets saved in the auto deploy cache and reused on all future reboots.  The strategy behind saving this information is to reduce the load on the auto deploy server by eliminating the need to parse each hosts against the rules engine on every reboot.  With this approach each host only gets parsed against the active ruleset once (on the initial boot) after which the results  get saved and reused on all subsequent reboots.

A challenge with this approach comes anytime you make a change to the active ruleset that results in a host using a different image profile or host profile, or being assigned to a different vCenter location.  When you make changes not only do you need to update the rules in the active ruleset but you also need to update the host entries saved in the cache for the affected hosts.  This is done using the Test-DeployRuleSetCompliance cmdlet together with the Repair-DeployRuleSetCompliance cmdlet.

Use the “Test-DeployRuleSetCompliance” cmdlet to check if the host information saved on the auto deploy server is up-to-date.  This cmdlet parses the host attributes against the active ruleset and compares the results with the information saved in the cache.  If the saved information is incorrect (i.e. out of compliance) the cmdlet will return a status of “Non-Compliant” and show what needs to be updated.  If the information in the cache is correct then the command will simply return an empty string.

To update the auto deploy cache run the “Repair-DeployRuleSetCompliance” cmdlet.  To run this cmdlet you need to first run the “Test-DeployRuleSetCompliance” and then pipe the results into the “Repair-DeployRuleSetCompliance”.  The “Repair-DeployRuleSetCompliance” cmdlet updates the saved host entry in the cache and brings the host back into compliance with the active ruleset.  Note that the “Repair-DeployRuleSetCompliance” does not generate any output.  After you run the repair verify the host entry has been updated by re-running the “Test-DeployRuleSetCompliance” cmdlet.

For environments with a lot of vSphere hosts you can use a simple PowerCLI “foreach” loop to avoid having to update each host one at a time:

PowerCLI C:> foreach ($esx in Get-VMHost) {$esx | test-deployrulesetcompliance | Repair-DeployRuleSetCompliance}

Follow me on Twitter @VMwareESXi