By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
|Gabrie van Zanten|
This article series gives step-by-step directions for scripting the installation of an ESX host.* After a host has been created, there are just two steps left for an administrator to perform: selecting the name of the host and adding the host to the correct cluster after installation. When you script an installation in this way, you can deploy a VMware ESX 3.5 host in 10 minutes.
To roll out VMware ESX hosts automatically, there are some prerequisites. You need to download the Ultimate Deployment Appliance (UDA) (more info on UDA appears below), you need a separate virtual local area network (VLAN) or network in which you can configure you own Dynamic Host Configuration Protocol (DHCP) server, and you need to have your VMware ESX installation media set up as an ISO file. (For instructions on turning software media into an ISO file, see the SearchVMware.com tip Five options for installing CD or DVD data on VMware virtual machines (VMs).)
UDA is a complete virtual machine appliance that can be downloaded here and then directly imported into a virtual environment like an existing VMware ESX host, vCenter Server or VMware Workstation. In our setup, the UDA has multiple roles. If we take a look at how the installation works as a whole, we'll see how the UDA fits in.
- New ESX host boots from bootable network adapter and requests DHCP address.
- The UDA gives an IP address and the address of the Preboot Execution Environment (PXE) server is included in the DHCP info.
- The new ESX host receives the IP address and contacts the PXE server, which is also the UDA.
- The UDA then presents a menu with a list of possible configurations.
- From the menu, the desired configuration is selected and the automatic install procedure will start.
- All scripts and software needed during automatic install will be downloaded from the UDA.
- The admin leaves to get some coffee. Upon return he will find a completely installed ESX host that only needs to be added to vCenter Server.
As you can see, the UDA acts as the DHCP server, PXE boot server and the Web server. Of course, if you want, to you can use a different DHCP server, but using the UDA in a separate network is the easiest way.
Preparing the UDA
After downloading and unpacking the UDA, you can easily import it into ESX because the disks are based on a SCSI controller. A quick overview of UDA can be found on the VMware appliances directory. It shows you how to boot UDA and use a Web browser to connect to the IP 10.0.0.104. This process, however, is annoying if your IP range doesn't match the one from the UDA. You can change the IP address in the Web interface, but this is impossible when the IP is inaccessible. It is easier to boot the UDA and open the VMware remote console, log on with "test" as the root user and password and edit the network settings.
Use the following command to change the IP address:
Now edit the IP address and the subnet mask into settings that better suit your network configuration. Save your changes by pressing the following key combination in exactly this sequence:
Now restart the networking stack with the following command.
service network restart
While the remote console is still open, make a subdirectory in /var/public/www with the name scripts.
mkdir /var/public/www/scriptsThis is where you store the scripts that will be downloaded during the automatic install procedure. For a quick setup, use your favorite secure copy program (such as Veeam FastSCPor WinSCP) to copy the scripts to the UDA. From the file available for download here, extract esx-postinstall-3.5.sh, vsw-vms01-cluster.sh and fastscp.xml and place them on the UDA in /var/public/www/scripts.
You can now connect to the Web interface. Here you will a find quick-start guide that tells you where to upload. The credentials for the Web interface are admin/admin.
Next we create our first template. Go to the Web interface. Click on Web Interface, click Templates and then click on Create new template. Next, enter the template ID. This is the ID you have to type when choosing an installation configuration from the menu. Select the correct OS disk. In the description field, enter the fully qualified domain name (FQDN) of the ESX host. This is just a description and is used only as display value in the boot menu, but using the FQDN clarifies things for all admins who use this procedure to install an ESX host. Set Type to typical, and click OK. Later, we will edit this template to reflect your configuration.
Preparing your VMware ESX host
What I have learned from configuring and installing many ESX hosts is that it helps when you have a list of the MAC addresses of the network adapters in your host and the physical switch port to which they are connected. I have a list of all my hosts that looks like this:
This is helpful if you're booting an ESX host and it isn't picking up a DHCP address. You can check which network adapter is trying to do a PXE boot by the MAC address, whether or not it's the one you wanted, and whether or not the correct VLAN is connected. After you have double-checked that your configuration is ok, you're ready to boot from the network adapter and start the automatic install.
IP and naming configuration
Now that you have your network adapters connected to the correct VLANs, it is time to write down the IP addresses needed for the VMware service console and the VMotion interface. The automatic procedure assumes that the last octet of the service console is the same as for the VMotion interface. In other words, if your service console is 192.168.0.10, then your VMotion interface IP should be 192.168.1.10. Also, the last octet will be used for the FQDN of the host. For example: esx010.company.local.
To configure the correct IP of your first host, go back to the UDA Web interface templates and edit the template you just created. Delete the contents of the boot parameters field and enter the line in the boot-parameters.txt file:
append ip=dhcp ksdevice=eth0 load_ramdisk=1 initrd=initrd.esx301 network ks=http://192.168.0.1/kickstart/es001.cfg ESXIP=10 ESXCL=001
In the line above, you have to adjust three parts to match your own configuration. The IP address 192.168.0.1 should be replaced with the IP of the UDA. ESXIP=10 should be the last octet of the IP of your ESX host and ESXCL=001 will point to the script that is used to configure the vSwitches and VLANs for the cluster this host will be member of. The default name of this script is: vsw-vms01-xxx.sh, in which xxx will be replaced by the ESXCL value.
The second change to the template is the kickstart script itself. Delete the contents of this large field and replace it with the script in the ZIP file named: uda-script.txt. Browse through the script to check which values you need to change for your configuration. When creating more templates for extra hosts, you can just copy the kickstart script from the first template (the one you're now editing) and paste it into the following templates. After this step, you don't have to edit the kickstart template but only change the "boot parameters" field.
Once everything is set, the automatic installation can begin. Boot your ESX host from the network adapter and wait for the PXE boot menu to prompt you for the desired configuration. I've set it up so that each host has a specific configuration. The configuration name is equal to the DNS name that the host should receive after installation.
Type the name of the configuration you want to install and press Enter. Installation will start and continue without the need for further human intervention. After installation, the host will reboot. Once the vmkernel is loaded, a second configuration script will start. Once this second script has finished, installation is complete. The only task left is add your ESX host to vCenter and assign it to the right cluster.
If you'd like to also have an in-depth view of how the individual scripts and peices of this operation work together to automate the creation of an ESX host, check out part two of this series: A deep dive into scripting VMware ESX host creation.
* I wrote the initial version of the script. Arnim van Lieshout helped perfect it.
Gabrie van Zanten (VCP) has been in the IT industry for 12 years. Currently he is a virtualization architect for a worldwide consultancy company and has designed and maintained virtual infrastructures for a number of customers. He has written articles for magazines and frequently publishes in-depth articles at his weblog, GabesVirtualWorld.