A customer on VCF 9.1.1 across two sites. At one, 2016-era Supermicro hosts that cannot run ESX 9, so the ESXi 8.0U3 clusters are built by hand and imported. At the other, a sixteen-host VDI fleet going to ESX 9.1.1 build 25714478. Every one of those hosts has to pass the same commissioning bar, and most of them arrived carrying a previous life: a hostname still localhost.localdomain, a VM Network portgroup, a self-signed certificate for the wrong name, and disks still claimed by a vSAN cluster that no longer exists.
VCF host commissioning has a short, unglamorous list of requirements, and a host fails the wizard if any one of them is wrong. The wizard stops partway with a message naming one host. You fix that one and run it again. Seven checks, sixteen hosts, each check a different esxcli incantation and each fix with its own way to go wrong: 112 checks by hand, with a feedback loop that reports one failure at a time. This is how that became one command, what the command refuses to do, and the week it ran on hardware that could not take ESX 9 at all.
The Problem Is Boring, Which Is Why It Bites
| # | Requirement | Why VCF cares |
|---|---|---|
| 1 | Hostname is the FQDN | VCF addresses the host by name |
| 2 | Exactly one vmkernel adapter | anything else is left over from a previous life |
| 3 | One uplink on the management vSwitch | a second one with no switch configuration behind it fails validation |
| 4 | One portgroup on the management vSwitch | the runbooks also name it Management Network; esxcli cannot rename one, and nothing downstream reads the name |
| 5 | No stale vSAN partitions | disks still claimed by a vSAN cluster that no longer exists |
| 6 | Certificate names the FQDN | VCF connects by name and rejects a mismatch |
| 7 | Not in maintenance mode | commissioning refuses it outright |
Plus VMFS-6 on the local datastores, and the right ESXi build, without which none of the rest matters.
Three Tools, One File
The toolchain grew in the order the problems arrived.
| Tool | Does | When |
|---|---|---|
esx_push.sh |
copies a depot bundle to every host and upgrades them | hosts on the wrong build |
esx_prep.sh v3.0 |
the seven requirements, on hosts already on the right build | after the upgrade |
esx_ready.sh v1.20 |
both, in one pass, including waiting out the reboots, and self-tested against a stubbed host | now |
They read the same hosts.yaml, which matters more than it sounds. One file describes the fleet, and whichever tool you reach for sees the same list, the same build number, the same datastore convention. They also share the update log’s name on the host, so each one can see the other’s in-flight update and not trample it.
# the bundle and what it installs
bundle: VMware-ESXi-9.1.1.0.25714478-depot.zip
profile: ESXi-9.1.1.0-25714478-standard
build: 25714478
sha256: 0000000000000000000000000000000000000000000000000000000000000000 # checked after the copy
# where the zip is staged on each host:
# a name, with {short} = the host without its domain, {host} = the entry as written
# a full path, e.g. /vmfs/volumes/datastore1
# auto - the largest local datastore with room
datastore: "{short}_ds1"
domain: example.com # appended to bare host entries
hosts:
- host: esx61.example.com
- host: esx62.example.com
- host: 10.0.0.13
fqdn: esx63.example.com # an IP needs its FQDN; nothing can guess it
datastore: some_other_ds # per-host override
Fourteen keys in total: hosts domain build bundle profile sha256 source datastore update_args update_mode mgmt_vlan mgmt_uplink min_uplinks ssh; the five after update_args arrived with version 1.20, and the day they arrived has its own story. An unknown key is a hard error that prints that list, because a mistyped key silently doing nothing is worse than a stop. {short}_ds1 is doing real work there: local datastores on a freshly built fleet are usually named after the host, so one line covers sixteen hosts with sixteen different datastore names. bundle: without build: is rejected, since the build number is how the tool knows an upgrade finished. profile: can be left out, in which case the one profile in the zip ending -standard is used, and two candidates is an error rather than a guess. sha256: is checked after the copy, so a bad download is caught before the upgrade rather than during it.
What is not in the file is deliberate. The SSH user (root), the management vmkernel (vmk0), the portgroup name (Management Network) and the timings (a 20-second poll, a 90-second settle after the host answers, an hour to wait for a reboot, three minutes for management agents, two hours before an update counts as dead) are built in. They are VCF’s requirements and hard-won waits, not site preferences, and a knob for each is one more way to be wrong.
Everything Is a Dry Run Until You Say Otherwise
sh esx_ready.sh list how hosts.yaml was read; connects to nothing
sh esx_ready.sh plan what would change on every host (the default)
sh esx_ready.sh apply do it, and wait out the reboots
plan is the default because the default should be safe. list exists because half of all configuration problems are “the file does not say what you think it says”, and proving that should not need sixteen SSH logins. A plan looks like this:
==== esx61.example.com
standalone host, build 24585383, maintenance mode Disabled
bundle location: /vmfs/volumes/esx61_ds1 - datastore: in hosts.yaml
WOULD copy VMware-ESXi-9.1.1.0.25714478-depot.zip to /vmfs/volumes/esx61_ds1
WOULD upgrade 24585383 -> 25714478 with ESXi-9.1.1.0-25714478-standard: maintenance mode, then the host reboots itself
WOULD hostname localhost.localdomain -> esx61.example.com
WOULD remove portgroup 'VM Network'
WOULD regenerate certificate [localhost.localdomain] -> [esx61.example.com], then restart management agents
WOULD wipe naa.50000000000000a1 (Ineligible for use by VSAN / Has partitions) - needs apply --wipe-disks
And every run ends with one table:
==== result
HOST BUILD STATE
esx61.example.com 25714478 ready (did: upgrade, hostname, certificate)
esx62.example.com 25714478 ready
esx63.example.com 24585383 -> 25714478 upgrade in progress - apply again to finish it
esx64.example.com 24585383 -> 25714478 left alone: managed by the vCenter at 10.0.0.40
Every host reading ready can be commissioned. The exit code is zero only when all of them do, so it drops into a pipeline without anyone parsing output; for anything that does parse, each host’s last two lines are STATUS <build> <state> <did> <todo> <note> and RESULT changes=N problems=N.
Each host reads one of eight states:
| State | Meaning |
|---|---|
ready |
commissionable now; did: lists what changed to get there |
to do |
changes pending, which plan listed |
upgrade |
needs the build change, then whatever follows it |
upgrade in progress |
the update is running on the host; apply again to finish it |
rebooting |
the update installed and the host is coming back on the new build; apply again to finish it |
moving vmk0 to a standard switch |
--restore-vswitch is under way on a distributed switch a vCenter left behind; apply again once the host answers |
left alone |
not standalone and settled; the reason is printed, and the run does not fail because of it |
problem |
something failed, and the host’s own output above says what |
What It Refuses to Do
The safety rules are more interesting than the features, because this runs as root against hosts that may not be as empty as someone believes. It leaves a host alone entirely if it is not standalone and settled: the management vmkernel is on a distributed switch, so that host is already in a cluster, whatever the ticket says; managementServerIp is set in the host summary, so a vCenter owns it and it has to be removed there first; or a reboot is pending that no upgrade from this tool explains. That last one is reconciled against the tool’s own update stamp and log, so a host midway through an upgrade it or esx_push.sh started is waited on, not refused. Each refusal prints a reason ending not touching this host, and the table says left alone: <reason> rather than failing the run.
And within a host it does fix:
- The management vmkernel is never removed or reconfigured. Only the extras go.
- The uplink kept is one reporting Link Up. If none does, it touches nothing: better a host with two uplinks than a host with none.
- The boot device is never wiped. Neither is any disk holding a VMFS datastore. Both are checked by name against the live device list, not inferred: the dirty disks come from
vdq -q, the boot device fromesxcli storage core device list, the datastore extents fromesxcli storage vmfs extent list. A wipe is a fresh GPT label frompartedUtil, and it comes last: first the host leaves the vSAN cluster it still thought it was in, then each old disk group is broken up by its cache device withesxcli vsan storage remove -s <cache> -m noAction, because vSAN keeps every disk it owns read-only topartedUtiluntil both are done, andpartedUtilis asked three times becauseesxclireturns before a volume has detached. That order was learned on a live fleet and is now a self-test check; the follow-up has the chain. - Only ESXi’s own self-signed certificate is regenerated. A CA-issued one is reported and left in place; the tool has no business replacing something your PKI issued. The check waits until the hostname is right, since a certificate for the old name is not worth generating. The old pair is kept as
rui.*.<timestamp>.bakand put back ifgenerate-certificatesfails;auto-backup.shruns so the new pair survives a reboot, the management agents restart, and the tool waits up to three minutes for port 443 to serve the new certificate before it calls the step done. The file on disk and the certificate port 443 actually serves are checked separately, because a host can have the right file and still present the old one. - VMFS-5 becomes VMFS-6 only when the datastore is local, single-extent and has no registered VMs: unmount,
vmkfstools -C vmfs6under the same name, verify it mounts as VMFS-6, and remount the old one if it failed. The partition table is never edited, a datastore spanning several extents is reported for hand work, and because the contents are gone afterwards this sits behind--wipe-diskstoo. --wipe-disksis a separate opt-in, and it only goes withapply. The plan already lists which disks need it and why, so you decide with the list in front of you rather than in advance.
That last one came from a real afternoon: a host carried vSAN metadata from an abandoned build, reported zero eligible disks, and the cluster came up six disks short. The plan now names each disk, its state and the reason, and declines to destroy anything until told twice.
The Upgrade Is a State Machine, Because Reboots Are
Upgrading sixteen hosts is not sixteen commands. It is sixteen hosts in different states at the same time, and a run has to cope with being started while that is true.
on the right build ─────────────────────────────────────► prep steps 1-7
│
▼
bundle not on the host ──► copy it ──► sha256 ──► dry run ──► maintenance mode
│ │
fails ◄──┘ ▼
│ background the update,
▼ write a .running stamp,
report and stop, reboot
nothing installed │
▼
poll port 443 for the new build ──► settle 90 s
│
▼
prep steps 1-7
Specifics worth stealing:
- A dry run first.
esxcli software profile update --dry-runbefore anything is installed. If it fails, nothing happened, the first lines are shown and the whole output is kept next to the bundle. If the dry run itself demands maintenance mode, it is retried inside it. When it fails on hardware warnings the tool prints the exact line to add:to go ahead despite these hardware warnings, add update_args: --no-hardware-warning to hosts.yaml. - The update is backgrounded with
trap "" HUPand the host reboots itself, but only once its own update log saysReboot Required: true. The SSH session dying is expected, not a failure. - SSH is re-enabled before the reboot (
vim-cmd hostsvc/enable_ssh), because a host that comes back with SSH off is a host you now visit in person. - Progress is polled over port 443, using the unauthenticated
RetrieveServiceContentcall a vSphere client makes first. No login needed, so it works while the host is still starting its management agents. - A
.runningtimestamp file marks an update in flight. Older than two hours and it counts as dead rather than hanging the run forever. - Ctrl-C is safe. State lives on the hosts, not in the script.
applyagain resumes: hosts already done reportready, hosts mid-upgrade are waited on. - Shared datastores are skipped when staging the bundle. If two hosts stage to the same volume, their update logs interleave and neither is readable.
ESXi’s Shell Is Not Your Shell
Three things shaped the implementation more than any design decision. Busybox has no tr. Every lowercase conversion and line join goes through awk. It also has no working command -v, so capability checks are openssl version >/dev/null 2>&1 rather than asking whether the binary exists. ESXi won’t start a shell from a very long command line. Pass a large script as the SSH command and you get /bin/sh: File too large. The payload travels over stdin into a temp file and runs from there, and stdin is read fully before the payload starts, so nothing it runs can swallow its own script. The shell does 32-bit arithmetic. Datastore free space in bytes overflows it silently. Every byte-sized number, the bundle size, the free space, the margin, is compared and added in awk, never in the shell. This one produces no error message at all; it just picks the wrong datastore.
It Also Runs on an ESXi Host
There is no requirement for a jump box. esx_ready.sh is POSIX sh with no dependencies, so it runs from one of the hosts in the list, and when it does, that host puts itself last, after everything else is finished. It opens the sshClient firewall ruleset if it needs to and closes it again on the way out. Convenient in an environment where the management network is reachable from the hosts and from nowhere else.
What It Actually Ran On
Numbers from the week this was written, so none of the above is theoretical. Eight hosts on the same 2016-era Supermicro chassis as the import story, legacy BIOS. Build 24585383 to 25595708 in one apply. Every one of them came back and prepped itself without a second command. Two things that run found on its own:
- The dry run failed on all eight with a hardware warning the platform raises for this generation of chassis. The tool printed the fix as a line of YAML,
update_args: --no-hardware-warning, and the next run went through. Nobody had to search for the flag. - Four disks per host reported Ineligible for use by VSAN with partitions left from an earlier build. Thirty-two disks. The plan listed each one by NAA id with its reason, and
apply --wipe-diskscleared them. Without that the cluster would have formed with half the capacity, and the shortfall would have shown up as a vSAN capacity alarm days later.
Then deploy_vc.py built the cluster on top, vSAN, HA and a vLCM image seeded from one of the prepared hosts, and the cluster was imported into VCF the same afternoon. The fleet file for the other site, whose hardware does run ESX 9, reads the same way: the sixteen-host VDI fleet to ESX 9.1.1 build 25714478, datastore: "{short}_ds1", one sha256. Sixteen lines of hosts and six lines of configuration.
Where It Sits in the Bigger Build
For this engagement the hosts could not be commissioned by VCF at all: the hardware is too old for ESX 9, and VCF 9.1.1 refuses an ESXi 8 host at the door:
Host ESXi version - 8.0.3-25595708 is not supported. VCF supported ESXi versions - [9.1.1.0.25714478]
So the clusters were built by hand on vSphere 8 and imported afterwards. esx_ready.sh is still step one of that, and of every day-2 host addition. And when the hosts are coming out of another vCenter rather than arriving new, there is a step before step one: host_release.py (vcf-import-prep, since 1.1.0) evacuates the host, drains it with full vSAN data migration behind a capacity gate on the source cluster, takes its disk groups out, moves it out of the cluster so NSX uninstalls, waits for NSX to let go, and removes it from inventory. It refuses a host still carrying an N-VDS or TEP vmkernels, because esx_ready.sh would strip the vmkernels and leave the VIBs. The result is a standalone host, which is the only kind of host the list below touches:
esx_ready.sh: build, hostname, networking, disks, certificatedeploy_vc.py: cluster, VDS, vmkernels, NTP, vSAN, and the vLCM image, taken from one of these hosts (Importing ESXi 8 Into VCF 9.1)- VCF import, then an inventory sync in VCF Operations, which stalls on a host without NTP
nsx_prep.py: the NSX overlay on the imported clusters, which an import leaves out by design, KB 444225 (Prepared Is Not Working)
Step 2 blocks on step 1 by design: deploy_vc‘s esx step refuses to build a cluster whose hosts are on mixed builds, because a cluster wants a uniform image and finding that out later costs a rebuild. Since vcf-import-prep 1.2.0 that uniform build is also where the image comes from. A new cluster is born on a vLCM image seeded from one of the prepared hosts, on a fresh vCenter too, where the site’s first host joins the cluster as it is created. A cluster that already exists without an image has one taken from a host in it before image management is turned on. Either way the desired image is what the prepared hosts already run. Before 1.2.0 the seed needed a host the vCenter already held, so the first cluster behind a fresh 9.1.1 vCenter came out with no image, which the import refuses.
Stale NSX from a previous life comes off before the host joins anything, which is the cheapest moment there is. And this is not the custom ISO problem: that one is what the installer can see; this one is what commissioning will accept after the host already boots.
Lessons Learned
- Make the dry run the default and make it honest.
planhas to show everythingapplywould do, including the things it will refuse. Ours lists the disks it won’t wipe without--wipe-disks, so the decision is made with the evidence visible. - One config file across the whole toolchain. Three scripts reading one
hosts.yamlmeans there is one place to be wrong, andlistproves what it says before anything connects. - Report state, don’t assume it. Every host is re-read after changes and its final state printed: FQDN, vmkernels, uplinks, portgroups, build, maintenance mode, certificate names. A
CHANGEline says what was attempted. The state block says what is true. - Refuse more than you fix. More of this code deals with “should I touch this at all” than with touching it. The host already in a cluster, the CA-issued certificate, the boot disk, the uplink that is the only one up: every one of those is a host someone would otherwise have had to rebuild.
- Name the next command in the error.
needs apply --wipe-disks.add update_args: --no-hardware-warning to hosts.yaml.apply again to finish it. Nobody should have to read the script to find out what to do next.
Getting It
git clone https://github.com/noahfarshad/esxi-vcf-host-prep.git
cd esxi-vcf-host-prep
sh esx_ready.sh selftest # 104 checks against a stubbed host; connects to nothing
cp hosts.example.yaml hosts.yaml # then set the build, the bundle and the hosts
read -rs ESXPW && export ESXPW # the root password never reaches shell history
sh esx_ready.sh list # how hosts.yaml was read; connects to nothing
sh esx_ready.sh plan # what would change
sh esx_ready.sh apply # do it, wait out the reboots
sh esx_ready.sh apply --wipe-disks # also clear stale vSAN partitions
unset ESXPW
plan esx05 esx06 takes a subset, -f another fleet file. esx_prep.sh is in the same repository for a fleet already on the right build: dry-run by default, --apply to change anything, PARALLEL for several hosts at once, and a host on the wrong build is refused with upgrade it first (esx_push.sh); not touching this host. esx_push.sh is there for the upgrade alone. Between them those two also read user:, ssh:, mgmt_vmk: and mgmt_portgroup:, which esx_ready.sh rejects on purpose, so a file that carries them is run with -f against the script that understands it. Every name and address in the example is a placeholder, and the commissioning checklist the hosts have to meet is the VCF 9.1 host-management page in the references.
Conclusion
Commissioning is not an upgrade. It is the moment VCF agrees to take a standalone host, and the hosts that fail it are wrong in boring ways. Put the seven requirements and the build in one file, make the plan honest, let the tool refuse what it should, and sixteen hosts become one command and one table.
References
- Commission ESX Hosts: the bar the script aims at. Hostname equal to the FQDN, forward and reverse DNS, a supported ESX build, healthy hardware, disk partitions deleted, management on a VMkernel connected to the standard switch, and when the host has more than one physical NIC, only one connected to that switch, carrying management. Hosts deployed with an external CA must keep using one when the domain grows.
- Managing ESX Hosts in VMware Cloud Foundation: a network pool comes first, commissioned hosts land as unassigned, and VCF does not support stateless ESX.
- Configure the Network on the ESX Hosts: how the management network is set before the installer runs.
Repository: github.com/noahfarshad/esxi-vcf-host-prep (release 1.2.0)
Related Stories:
- Everything That Cost Us a Day Returned Success: Nine Versions of esx_ready.sh on a Live Fleet — the day this tool went from 1.12 to 1.20: the build gate, the vSAN ownership chain, the deleted rename and the self-test harness
- Importing ESXi 8 Into VCF 9.1 When ESX 9 Won’t Run on the Hardware — step two: the cluster these hosts were built into, and the vLCM image it takes from them
- The NSX That Nobody Installed: Clearing Stale VIBs Before a VCF Import — what else can be on a host before it joins anything
- Prepared Is Not Working: The Overlay a VCF Import Leaves Out — step four: the overlay after the import
- When the Installer Sees Zero Disks — the image build; this is what commissioning accepts after the host boots
