The attached script demonstrates how you can automate bulk addition of stateless ESXi hosts via Auto Deploy with static IP addresses using Host Profile Answer files, as long as you know the primary boot MAC address, or BIOS UUID of the new hosts ahead of time. The following excerpt from the script describes how this works (refer to the script for more details):
# There are two common ways to set up hosts with static IP addresses using Auto
# Deploy. The preferred mechanism is to enter static entries within your DHCP
# server so it always hands out the same IP address to a given MAC address.
# Then ESX is configured to use DHCP, but will always get the same IP. This
# script does not address that approach. Please refer to your DHCP server
# documentation for more details on setting this up.
#
# The alternative approach is to set up host profiles to use a static IP
# address and have an answer file for each host that defines its addresses.
# Normally on first boot, the host will stay in maintenance mode, and require
# the admin to manually re-apply the profile, at which point you would enter
# the IP addresses in the GUI which are then stored in the answer file. This
# script demonstrates how you can "pre-answer" the static IP settings for hosts
# so that no user intervention is required on first boot. The script
# is structured to facilitate bulk addition of new servers. As long as you
# know the MAC address of the primary boot NIC, or the BIOS UUID, then you
# can run this script to set up all the IP addresses
Here's what the CSV file might look like, assuming you have two portgroups with vmkernel networking - "Management Network" and "vmotion"
00:50:56:9c:0e:c8,ESXi-5.0.0-469512-no-tools,MyClusterName,Management Network,192.168.1.10,255.255.255.0,vmotion,192.168.2.10,255.255.255.0
00:50:56:9c:0e:c9,ESXi-5.0.0-469512-no-tools,MyClusterName,Management Network,192.168.1.11,255.255.255.0,vmotion,192.168.2.11,255.255.255.0
Then running the script (assuming the file above is called "hosts.csv") would look like:
Connect-VIServer MyVcServerName
Add-EsxSoftwareDepot https://hostupdate.vmware.com/software/VUM/PRODUCTION/main/vmw-depot-index.xml
.\pre-answer.ps1 .\hosts.csv
Once the script completes, you can power on your systems and they'll come up with the desired static IPs automatically without user invervention.
Daniel
And another great script, your on fire !
This document was generated from the following discussion: javascript:;