Posted on 18 Mar 2011 by Ray Heffer
If you are looking to deploy multiple ESX/ESXi servers then there are plenty of methods and tools out there, some more complex than others. There are vendor specific deployment products available such as HP Rapid Depuployment Pack (RDP) which uses Altiris, or alternatively there are free deployment tools such as ESX Deployment Appliance (EsleeDA) and Ultimate Deployment Appliance (UDA). UDA is my favorite tool for the job as it offers great flexibility such as the use of subtemplates (discussed later), and therefore this will be the basis of this article. It was created by Carl Thijssen and thanks to Mike Laverick of RTFM, it also supports ESX/ESXi deployments, and the latest build supports ESX/ESXi 4.1.
I aim to share the basics of getting the UDA configured for your environment and not delve into anything too complicated here. The best way of learning to perform some of the more complex deployments are to grasp the basics first then experiment with other functionality in your own environment for yourself.
For the purposes of this guide a number of assumptions have been made. You will have already deployed vCenter and at least one ESX/ESXi host running with some storage. If you are going to be testing this in a home lab then bear in mind that we’ll need to configure DHCP options 66 and 67, see the end of this article for details. You can do this with an existing DHCP server or use UDA as a DHCP server. Most deployments will be using an existing DHCP server.
Let’s get started…
Once it has finished you will then be able to access your UDA from a web browser. Log in with admin and the password you set during the setup.
When you first log into the appliance you will be presented with a welcome page. The first thing to configure is the additional disk space we need to store our ISO images. If you haven’t added a second hard disk, then shutdown the UDA (System > Shutdown), then add the additional disk and power on.
UDA has two partitions; systemlv
and localv
. ISO images are stored on the localv partition, so we’ll extend that.
It may take a little while depending on how large the new disk is, but once that is complete we’ll load the ISO image for ESXi 4.1 Update 1 on to the UDA.
It will store the ISO on the localv partition in /local.
Now for the exciting bit. We’ll add our OS (ESXi) and template for deployment which will also create the basics of our Kickstart script which we’ll add to later. The OS section allows us to tie an ISO image to a Flava name, in this case we’ll call it ESXi41. I’d recommend using a better naming convention for your environment though.
Next, the template which contains our Kickstart script. The template also contains a subtemplate which allows us to define our own variables, such as IP address and hostnames for each ESXi host we are deploying. This is why I like using UDA so much, because it avoids having to create a separate Kickstart script for each ESXi host.
The next stage is to perform the configuration of our Kickstart script and subtemplate. Go to Templates, select your template (esxi-build) and click Configure. You’ll see three tabs here; General, Subtemplates and Advanced. Click on Advanced. This is where our Kickstart script lives, and you’ll see it contains a basic configuration.
Here is a breakdown with explanations for each line:
Accept the VMware EULA - The script will fail without this.
accepteula
Set the root password using MD5 crypt
rootpw secret
Auto partition the disk
autopart --firstdisk --overwritevmfs
Location of the install media
install url http://[UDA_IPADDR]/[OS]/[FLAVOR]
Configure IP address and hostname
--addvmportgroup=0 will disable creation of the VM Network portgroup
network --bootproto=static --ip=192.168.178.200 --gateway=192.168.178.1 --nameserver=192.168.178.1 --netmask=255.255.255.0 --hostname=esx41i --addvmportgroup=0
Reboot the host when the installation is complete
reboot
The first thing we need to change is the root password which by default is set to secret and is in plain text. We can use a crypted MD5 password here using rootpw –iscrypted followed by the crypt.
rootpw --iscrypted $1$3vkd233f/wksSo$fhniM3fdcV6hr0
Now we need to change the network configuration to use the appropriate IP address, gateway, subnet mask and hostname. We could just replace the default IP address configuration here, but a better method is to use variables which we can set in subtemplates. Variables are set inside square brackets, such as [IPADDR], [FQDN] and so on. The variable names are up to you. Change the network configuration, replacing the IP address and hostname with variables as follows:
network --bootproto=static --ip=[IPADDR] --gateway=192.168.4.1 --nameserver=192.168.4.1 --netmask=255.255.255.0 --hostname=[FQDN] --addvmportgroup=0
Select Subtemplates and click on Edit. The first line we will create contains the word SUBTEMPLATE then the variable names that we want to use (separated by semi-colons). Subsequent lines contain the values for each host. See my example below:
SUBTEMPLATE;IPADDR;FQDN;VMKIPADDR
ESX01;192.168.4.11;esx01.home.lab;192.168.4.211
ESX02;192.168.4.12;esx02.home.lab;192.168.4.212
ESX03;192.168.4.13;esx03.home.lab;192.168.4.213
ESX04;192.168.4.14;esx04.home.lab;192.168.4.214
You’ll notice in my example I’ve added a VMkernel IP address that in the case of our ESXi deployment we will use for VMotion.
Click on the Advanced tab. After the network configuration line we need to add the following command which allows us to run our esxcfg commands on first boot:
%firstboot --unsupported --interpreter=busybox
Now add the following commands to the Kickstart script (Advanced), which will add a VMotion portgroup and IP address. You can leave the # comments in if you wish:
Setup VMotion portgroup on vSwitch0
esxcfg-vswitch -A VMotion vSwitch0
Setup VMotion IP address
esxcfg-vmknic -a VMotion -i [VMKIPADDR] -n 255.255.255.0
Wait for previous command to finish before enabling VMotion
sleep 10
Enable VMotion (ESX uses vmware-vim-cmd and ESXi is vim-cmd)
vim-cmd hostsvc/vmotion/vnic_set vmk1
vim-cmd hostsvc/net/refresh
Notice in the vim-cmd command above that it sets VMotion on vmk1. vmk0 will be the management IP address used in the network command at the top of our script. This is fairly straightforward to work out, but if anyone knows of a better method then feel free to comment!
Finally click on Save.
Now we have the UDA configured and ready to roll with our ESXi installation all we have to do now is PXE boot our hosts and providing you have configured DHCP options 66 & 67 (see the end of this article) you should be presented with the UDA menu (see first screenshot).
The rest is easy, just select the host from the menu (we set this in SUBTEMPLATE) and it will install and configure ESXi with no user intervention. Using a scripted installation can be very powerful and a lot more can be configured than I’ve included here. Even if you don’t have mass ESXi deployments, this is a good way of ensuring that your ESXi hosts maintain your standard build. If you have an Enterprise Plus license then you can also use Host Profiles.
accepteula
rootpw --iscrypted $1$3vkd233f/wksSo$fhniM3fdcV6hr0
autopart --firstdisk --overwritevmfs
install url http://[UDA_IPADDR]/[OS]/[FLAVOR]
network --bootproto=static --ip=[IPADDR] --gateway=192.168.4.1 --nameserver=192.168.4.30 --netmask=255.255.255.0 --hostname=[FQDN] --addvmportgroup=0
reboot
## THE FOLLOWING IS OUR FIRSTBOOT CONFIGURATION ##
# Configure additional commands at first boot.
%firstboot --unsupported --interpreter=busybox
# Setup VMotion portgroup on vSwitch0
esxcfg-vswitch -A VMotion vSwitch0
# Setup VMotion IP address
esxcfg-vmknic -a VMotion -i [VMKIPADDR] -n 255.255.255.0
# Wait for previous command to finish before enabling VMotion
sleep 10
# Enable VMotion (ESX uses vmware-vim-cmd and ESXi is vim-cmd)
vim-cmd hostsvc/vmotion/vnic_set vmk1
vim-cmd hostsvc/net/refresh
SUBTEMPLATE:
SUBTEMPLATE;IPADDR;FQDN;VMKIPADDR
ESX01;192.168.4.11;esx01.home.lab;192.168.4.211
ESX02;192.168.4.12;esx02.home.lab;192.168.4.212
ESX03;192.168.4.13;esx03.home.lab;192.168.4.213
ESX04;192.168.4.14;esx04.home.lab;192.168.4.214
Tagged with: vmware
Comments are closed for this post.