Today I have a guest post on the ESXi Chronicles blog. Every since I first started working with Auto Deploy back in the early days of the vSphere 5.0 beta I’ve been a huge fan. It’s proven to be an ideal way to deploy ESXi in my lab where I often need to reinstall large numbers of ESXi hosts in a relatively short period of time.
Auto Deploy uses PowerCLI to create and maintain a set of “Deploy Rules” that are used to map ESXi hosts with an image profile, host profile, and to place the hosts into vCenter. Because it’s very easy to script PowerCLI that means there is a lot of potential for automating the common Auto Deploy activities. The following is an excellent article written by Daniel Hiltgen from our engineering team that demonstrates some of this PowerCLI scripting potential.
Sample Scripts for Automating Auto Deploy
By Daniel Hiltgen
One of the exciting new features in vSphere 5.0 is Auto Deploy which enables rapid deployment of ESX systems using network boot technologies. Auto Deploy enables a mode of operating ESXi which we call "stateless" – instead of managing the state on each individual ESXi system, all the state of your systems are managed centrally using Image Profiles and Host Profiles. This allows you to treat a large set of similar hosts using one common configuration, thus greatly increasing the number of physical hosts one admin can manage. This also allows your ESXi systems to be diskless (although you can still place VMFS on a local drive if you like) and prevents unintended "drift" of configuration or software content. If you want to make changes, just update the central configuration, and reboot your hosts. A quick overview video describing Auto Deploy is available on the VMware Tech Pubs Channel on YouTube.
The primary way you interact with and configure vSphere 5.0 Auto Deploy is by using vSphere PowerCLI. A set of cmdlets let you set up image profiles, and define the rules that map image profiles, inventory location, and host profiles to your hosts. A quick-reference for the relevant cmdlets is available at the vSphere 5 Document Center. By writing Power Shell scripts you can automate routine tasks to help further increase your efficiency. The Auto Deploy team has developed a few example scripts to help illustrate some of the scripting potential.
The first script we'll look at is one that helps automate updating the image on a set of hosts. When a new patch or update release is made available by VMware or our partners, updating your stateless ESXi hosts with Auto Deploy is as simple as updating the image profile and mapping rule, then rebooting the hosts. You can do this manually, or using this reference script you can automate this process over one or more clusters of hosts. The following excerpt is from the comment at the top of the script:
# This script will help automate patching/updating large numbers of
# stateless hosts. On the first invocation of the script, specify
# a cluster to remediate, the new image profile, and the old image mapping
# rule. The script will update the deploy rule to use the new image profile.
# The script will then loop through all the hosts in the cluster,
# put them in maintenance mode, and reboot once the VMs are migrated off
# via DRS. On subsequent invocations of the script, you can specify
# just the cluster (this assumes you have multiple clusters that leverage
# the same image profile deploy rule in Auto Deploy)
You can access the script in the PowerCLI forum at http://communities.vmware.com/thread/328033. Please make sure to open the script up in a text editor to view the comment at the top for additional information on usage.
The second script we'll look at helps automate the bulk addition of hosts with static IP addresses. Here's a brief description:
# 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. Then ESX is configured to
# use DHCP, but will always get the same IP. This script does not address this
# 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
You can access the script in the PowerCLI examples forum at http://communities.vmware.com/thread/328034. Again, please take a look at the comment at the top of the script for more detailed usage information.