Unattended installation

While interactive installation is straightforward, you need to repeat the same steps for each server to install. If the number of hosts to install increases dramatically, the interactive installation method may not be the most suitable choice. The installation process can be automated using a script to provide an efficient way to deploy multiple hosts.

ESXi supports the use of an installation script to automate the installation process and can be useful if you want to have a consistent configuration for all hosts. Using an installation script, you can quickly deploy multiple instances of ESXi, creating unattended installation routines. These scripts can be saved on a USB flash drive or in a network location accessible through NFS, HTTP, HTTPS, or FTP.

The following table indicates some common boot options for unattended ESXi installation. For a complete list of supported boot options, refer to the vSphere Installation and Setup Guide available on the VMware website at https://docs.vmware.com/en/VMware-vSphere/6.7/com.vmware.esxi.upgrade.doc/GUID-61A14EBB-5CF3-43EE-87EF-DB8EC6D83698.html:

Boot option

Description

BOOTIF=hwtype-MAC address

Similar to the netdevice option, except in the PXELINUX format as described in the IPAPPEND option under SYSLINUX  at syslinux.zytor.com.

gateway=ip address

Sets the default gateway to be used for downloading the installation script and installation media.

ip=ip address

Used to set a static IP address to be used for downloading the installation script and the installation media.

ks=cdrom:/path

Specifies that the path of the installation script, which resides on the CD in the CD-ROM drive. The path of the script must be written in uppercase characters (for example, ks=cdrom:/KS_CUST.CFG).

ks=file://path

Performs a scripted installation with the script at path.

ks=protocol://serverpath

Specifies that the script is located on the network at the given URL. Supported protocol can be HTTP, HTTPS, FTP, or NFS (for example,  ks=nfs://host/porturl-path).

ks=usb

Indicates that the installation script is located in an attached USB drive. ks.cfg must be in the root directory of the drive. Only FAT16 and FAT32 are supported. If multiple USB flash drives are attached, the system searches until the ks.cfg file is found.

ks=usb:/path

Specifies the path of the installation script that resides on the USB (for example, ks=usb:/ks.cfg).

ksdevice=device

Tries to use a network adapter device when looking for an installation script and installation media. If the script has to be retrieved over the network, the first discovered plugged-in NIC is used if one is not specified.

nameserver=ip address

Specifies a domain name server to be used for downloading the installation script and installation media.

netdevice=device

Tries to use a network adapter device when looking for an installation script and installation media. The device can be specified as vmnicXX name. If the script has to be retrieved over the network, the first discovered plugged-in NIC is used if not specified.

netmask=subnet mask

Specifies the subnet mask for the network interface that downloads the installation script and the installation medium.

vlanid=vlanid

Used to specify the VLAN for the network card.

Common boot options for unattended ESXi installation

The installation script is a text file often named ks.cfg that contains supported commands useful to provide the required installation options to the ESXi installer. In the installation medium, VMware includes a default installation script that can be used as a reference to perform an unattended ESXi installation to the first detected disk. You can use this script if it is suitable for your ESXi installation.

The default sample script is as follows:

#
# 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() )

To create a custom installation script or modify the default script, you should use the supported commands available.

A complete list of supported commands to use with installation scripts can be found in the vSphere Installation and Setup Guidehttps://docs.vmware.com/en/VMware-vSphere/6.7/vsphere-esxi-67-installation-setup-guide.pdf.

To configure an unattended installation booting from a USB stick, perform the following steps:

  1. Navigate to the installation media and edit the boot.cfg file. Replace kernelopt=runweasel with kernelopt=runweasel ks=usb:/ks.cfg. This allows the system to automatically use the script located on the USB drive. Make sure you use an editor that can handle UNIX encoding.
  2. Create a ks.cfg file in the root directory of the USB device that the installer will use for the unattended installation. Edit the file and create the script. You can use the following simple script as an example:
vmaccepteula
rootpw mypassword
install --firstdisk –overwritevmfs
keyboard English
network --bootproto=dhcp --device=vmnic0
reboot
  1. Save and close the file. Plug in the USB stick and power on the server.
  2. To manually run the installer script when the ESXi installer window appears, press Shift + O to edit boot options. At the runweasel command line, type ks=usb:/ks.cfg. To specify the path to an installation script, you may also use the ks=http://ip_address/kickstart/ks.cfg command, where the IP address refers to the machine where the script resides.
  3. The system will boot from the USB stick and do an unattended installation.

The main benefit of using unattended installations for ESXi is not only that it speeds up the installation process, but it also ensures a consistent configuration of all ESXi hosts.

There are certain caveats when using unattended installation such as an IP configuration. Generally, you do not want to use a dynamically assigned IP address, but instead use a statically configured address. To do that without any additional modifications, you would need to have individual config files for each ESXi server you want to configure and select them during the boot process: ks=http://ip_address/kickstarts/ks_ESXi-36.cfg.

You can automate the whole procedure using some scripts.

The first requirement is to have MAC address mapping to the individual ESXi servers since the DHCP server knows the mapping between MAC address and the IP address.

Once your ESXi servers connect to the web server where the script resides over IP, you will know which ESXi server it is thanks to this mapping. Now, based on this information, you can dynamically create the correct kickstart file with appropriate IP address for the management interface or other variables individual for each ESXi server, such as DNS settings.

You can, of course, use the more convenient method, Auto Deploy, which will do all the work for you, but this feature is only available in Enterprise editions of vSphere.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.22.61.246