You can use vSphere Auto Deploy to configure one or more hosts by associating custom scripts with a vSphere Auto Deploy rule.
The scripts run in alphabetical order after the initial ESXi boot workflow of the host.
- Verify that the script bundle you want to associate with a vSphere Auto Deploy rule is in .tgz format, with a maximum size of 10 MB, and written in Python or BusyBox ash scripting language.
- In a PowerCLI session, run the Connect-VIServer cmdlet to connect to the vCenter Server system that vSphere Auto Deploy is registered with.
Connect-VIServer ipv4_or_ipv6_addressThe 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.
- Run the Add-ScriptBundle cmdlet to add the script bundle that contains the necessary scripts to the vSphere Auto Deploy inventory.
Add-ScriptBundle c:/temp/MyScriptBundle.tgzThe name of the script bundle without the .tgz extension is the name identifier or object of the script bundle item. You can update an existing script bundle by using the -Update parameter with the Add-ScriptBundle cmdlet.
- (Optional) Run the Get-ScriptBundle cmdlet to verify that the script bundle is added to the vSphere Auto Deploy inventory.
- Define a rule in which hosts with certain attributes, for example a range of IP addresses, are assigned to the script bundle.
New-DeployRule -Name "testrule4" -Item "MyScriptBundle" -Pattern "vendor=Acme,Zven", "ipv4=192.XXX.1.10-192.XXX.1.20"
Double quotes are required if a name contains spaces, optional otherwise. Specify -AllHosts instead of a pattern to apply the item to all hosts.You create a rule named testrule4. The rule assigns the script bundle named My Script Bundle to all hosts with a vendor of Acme or Zven that also have an IP address in the specified range. You can use the name identifier of the script bundle or the object returned by the Get-ScriptBundle cmdlet to identify the script bundle you want to associate with the rule.
- Add the rule to the rule set.
Add-DeployRule testrule4By default, the rule is added to both the working rule set and the active rule set. If you use the NoActivate parameter, the working rule set does not become the active rule set.
What to do next
- For hosts already provisioned with vSphere Auto Deploy, perform the compliance testing and repair operations to provision them with the new scripts. See Test and Repair Rule Compliance.
- Turn on unprovisioned hosts to provision them with the new scripts.