November 25, 2009

Notes on How to perform a scripted install of VMware ESX 4.0

Filed under: vmware — Tags: , , , , , , , — Tim Lefler @ 5:32 pm

First a little backgroud and a few links.  You will find all kinds of information on automated installation on the VMWare User Group community.  VMWare also has some paltry level of documentation on the subject.  This best beginning source of information for me was this blog….. and it is from here that the following excerpt was taken to help remind me of the basiss behinfd the ESX scripted installation:

The vSphere ESX 4 install process uses an updated linux boot release commonly referred to as Syslinux. This Syslinux release version 3.63 supports a variety of popular protocols to facilitate a remote central install repository. FTP, HTTP, NFS and gPXE are all available options for provisioning network attachment to a remote install repository.

From the Syslinux boot process vSphere launches it’s initrd.img kernel instance which is a custom VMware/Linux kernel containing a multitude of VMware ESX 4 drivers and components. The custom drivers allow for a more closely integrated VMware ESX 4 install process that targets an improved ESX 4 server configuration result.

The custom VMware kernel incorporates Linux kickstart scripting functionality to invoke automated installations. The script location is defined as part of the Syslinux functionality and is available as a menu at boot time. A control file located on the boot media provides these variable control elements. Depending on the media type Syslinux uses a respective cfg file to implement this function. The various available Syslinux boot methods that I am aware of are USB, CD, DVD, PXE and gPXE. In this blog I will demonstrate an ISO CDROM method to perform the automated boot cycle. Any of the boot methods mentioned will all work and have varying levels of complexity to achieve.

The ISO CD and DVD based Syslinux configuration uses a config file named isolinux.cfg, USB boot images would use isolinux.cfg as well as gPXE based boot services can use either depending on the final gPXE target image.

This is a great source of reference, although it did not meet all my needs because it is a network based installation.

So what exactly am I trying to do?  I want to use the built in kickstart scripting mechanism to consistently install or reinstall ESX Hosts in our VMWare vSphere 4.0 environment.  I want the installation script to prompt for things that change from ESX host to ESX host like:  Service console IP  information, iSCSI IP information, and the FQDN.  I also want the installation script to download an additional configuration script from a centralized repository after the installation is complete and execute it.

This is probably complicated a little in our environment because all of the network connections to our ESX hosts are 802.1Q VLAN trunks to give us the greatest flexibility in production.  Unfortunately, the ESX kickstart/syslinux kernel used for the ESX 4.0 installation does not support VLAN trunking, so no networking is available unless we switch the port before and after the installation.  I don’t want to do that……

So what are the advantages to how I approached this automated installation problem:

  1. Installation is done totally from media so network not required during the scripted installation
  2. One configuration script for any ESX host being installed that prompts for dynamic elements.
  3. A post installation download of an additional script that can be easily updated without changing the installation media.
  4. The downloaded script can configure anything that can be configured on a running ESX host.
  5. Complete install/reinstall of ESX environment in 25 minutes.

We used to do all this with ESX 3.5.  By omitting the “network” section in the kickstart “ks.cfg” the installation would prompt us, allowing us to setup the dynamic elements.  Unfortunately, I had to build my own prompting mechanism into my ESX4 kickstart script and it was a little tricky.

I’ve found the most straight forward approach is to simply use the same old boring default DVD iso downloaded from VMWare.  Download it, burn it to a DVD and we are 25% of the way there already.  The default installtion DVD, contains a non default option to do a  “ESX Scripted Install using USB ks.cfg”.

Select

ESX Scripted Install using USB ks.cfg

So now, all I need to do is place my modified kickstart “ks.cfg” file on a USB memory stick and it will install from the CD but because I’ve modified the %pre and %post sections of the “ks.cfg” in the manner I’m about to describe, the ks.cfg will prompt me for the dynamic networking components.  If you don’t want to use a USB drive then you can see my other post that talks about a complicated method of burning your custom ks.cfg on to the DVD media.

So now lets look at my customized kickstart “ks.cfg”

We start with some of the basics……

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
accepteula
 
keyboard us
 
# Read network information from a file we are going to populate in the %pre section
# of this kixstart script.
%include /tmp/networkconfig
 
auth  --enablemd5 --enableshadow
 
install cdrom 
 
rootpw --iscrypted $1$M7fvhjkgghkyguysdfjhgjoqg.
 
timezone --utc 'US/Eastern'
 
# Read partition information from a file we are going to populate in the %pre section
# This allows me to create local vmfs with "hostname:storage1" and I've adjusted the sizes
# on my service console partitions.
%include /tmp/partconfig
 
%pre --interpreter=bash

Now the “%pre” section is where it begins to get interesting. We need to collect information for three things:

  • Service Console IP
  • iSCSI Service Console IP
  • iSCSI Kernel IP

I have my script fill in all the other stuff, like subnet, gateway, VLAN excetera because we set up all of our hosts consistently and that stuff doesn’t change. You could easily expand on this part to prompt for other items. I’ve XX’d out my specific settings you will need to plug in your own if you model after this script.

So here is my “%pre” section….. (more…)

Powered by WordPress