VMware vSphere 5.1 Cookbook
上QQ阅读APP看书,第一时间看更新

Performing a scripted install of the ESXi server

With the help of the Installing ESXi 5.1 recipe, you should now be familiar with the regular interactive installation of the ESXi server. Although the interactive installation is an easy task, it becomes a tedious one when you are deploying servers in a larger environment. This is where a scripted installation could come in handy.

The How to do it... section will guide you through the steps required to perform a scripted installation.

How to do it...

The following are the steps involved in a scripted-installation process:

  1. Boot the server with the ESXi installation CD in the CD/DVD ROM drive.
  2. At the ESXi installer's Loading ESXi installer screen, press Shift + O.
  3. On pressing Shift + O, you would see the default command the installer uses: runweasel.
  4. At this prompt, specify the location of the install script. I have used an FTP location. Local CD ROM, USB driver, HTTP/HTTPS, or NFS are other supported script locations.

    The ks script will then locate and load the specified configuration file and proceed with the installation.

  5. Once the installation is complete, it will prompt for a reboot. Press Enter to reboot.
    Note

    Note that all the commands in the script file should be in lowercase.

    In this example we have created an install script with the name forbook.cfg and saved it onto an FTP server.

How it works...

An installation script is a plain text file with a .cfg extension and can only contain supported commands.

The ESXi installer has a default install script, ks.cfg, that performs a standard installation on the first detected disk. This file is located in the initial RAM disk at /etc/vmware/weasel/ks.cfg. The following is the default script file:

#
# Sample scripted installation file
#
# Accept the VMware End User License Agreement
vmaccepteula

# Set the root password for the DCUI and Tech Support Mode
rootpw mypassword

# Install on the first local disk available on machine
install --firstdisk –overwritevmfs

# Set the network to DHCP on the first network adapter
network --bootproto=dhcp --device=vmnic0

# A sample post-install script
%post --interpreter=python --ignorefailure=true
import time
stampFile = open('/finished.stamp', mode='w')
stampFile.write( time.asctime() )
Note

When you install an ESXi server using the ks.cfg script, the default password is mypassword.

A single script can be used to install ESXi on multiple machines. Some modifications might be needed if you choose to install ESXi on a different hard drive, because by default it would install on the first local hard drive.

A scripted install has two stages. In the first stage, we create a custom script with needed commands or edit the script if it needs to be unique for a specific host. In the second stage we will redirect the installer to use the script file.

At the runweasel prompt, use the postfix ks=location of the script. This boot option will call the install script with additional boot parameters, if supplied. If we do not specify the ks= boot option, then the standard-text installation will proceed. The following is the script being used:

On successfully locating the configuration file (forbook.cfg in this case), the scripted install will begin. The following screenshot shows all the phases the installer would go through during the scripted install:

Once the installation is complete, it will indicate that the server must be rebooted:

There's more...

The ks= boot option supports the following syntaxes:

  • ks=cdrom:/path
  • ks=usb:/path
  • ks=file://path
  • ks=protocol://serverpath

There are many more commands than what you see in the default script, and those commands can be used to create scripts to install ESXi servers as per your requirement.

Starting with ESXi 5.0, you can use the script to perform upgrades on the server. The following is the list of commands:

  • vmaccepteula
  • clearpart
  • dryrun
  • install
  • installorupgrade
  • keyboard
  • network
  • paranoid
  • part or partition
  • reboot
  • rootpw
  • upgrade
  • %include
  • %pre
  • %post
  • %firstboot
Note

Note that there are a few commands with a % prefix; those are multiline commands.

For more information on each of these commands refer the vSphere installation guide at the following link:

http://www.vmware.com/support/pubs/vsphere-esxi-vcenter-server-pubs.html