Unattended ESXi Installation

Yes the title of this post is correct… ESXi unattended installation. Now that I’m staring down the barrel of ESXi installations as opposed to just PXE booting it (long story, let’s not go there… nothing to do with VMware, everything to do with finite engineering resources where I work), I thought I may as well automate it as much as possible. And while the steps I describe in this post don’t lead to a _completely_ unattended install, to be honest there’s not a helluva lot stopping you from creating a completely automated install if your target systems will only ever have a single non-SAN disk that will be your install target. In the interests of public safety, I haven’t gone that far for you. Besides, if you don’t know Python (not that I do, really) then here’s a good reason to take a little look at it and figure out how to do that for yourselves.

One of the more interesting design choices of ESXi 4.0 is that not only is a minimal Python environment available during installation, but it’s actually there in the final product too. This obviously opens up many possibilities for calling out from ESXi to external systems without the need for custom binaries. Yeh sure you could’ve done it with (b)Ash scripts in ESXi 3.x, but have you ever tried talking to web services via a (b)Ash script? Python definitely seems like it will be handy language to know in the VMware world, and they have some world class Python coders (like Christian Hammond) working for them.

So let’s take a look at the requisite files. The ESXi installer scripts are located in, surprise surprise, the install.tgz file in the root of the installation media. Opening this up, we see 2 directories: sbin and usr. In sbin is the (b)Ash script that is called to kick off the ESXi installation, but it just calls to /usr/lib/vmware/installer/ThinESX.py, which in turn simply calls the Start method defined in ThinESXInstall.py in the same directory. This file defines a number of install steps, each of which is a method in yet another file, /usr/lib/vmware/installer/ThinESX/ThinESXInstallSteps.py. Most of the methods in that file call scripts in /usr/lib/vmware/installer/ThinESX/Dialogs to do the actual work. Once you unravel this, it’s clearly obvious that only one thing needs to be modified – the install steps defined in /usr/lib/vmware/installer/ThinESXInstall.py! Here’s what the default entry looks like, on lines 22/23:

Steps = [ WelcomeStep, LicenseStep, TargetSelectionStep, ConfirmStep, \
WriteStep, PostConfigStep, CompleteStep, RebootStep ]

The PostConfigStep does some important work, and doesn’t present any user dialogs anyway so it needs to stay. But I couldn’t give a damn about a welcome screen, a EULA acceptance (as if we’re not bound to that anyway by the license purchase), a target confirmation dialog, and a message telling me the install has completed. So stripping out the extraneous stuff, we are left with:

Steps = [ TargetSelectionStep, WriteStep, PostConfigStep, RebootStep ]

Et Voila (as Renouf would say), we have an ESXi installer with as few interruptions as possible. And as I mentioned before, you could take it even further by writing some of your own logic into /usr/lib/vmware/installer/ThinESX/Dialogs/DeviceSelectionDialog.py to automate target disk device selection if your hardware standards permit it.

For those out there that don’t have a *nix box to do the requisite operations on the install.tgz tarball (shame on you – even a Mac will do!), here’s one I prepared earlier (sha1:9c7c1124ee486b58fd69ff5f6945f657c31570da) – just replace the install.tgz in the ESXi install ISO you download from VMware with my one and bob’s your uncle!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: