8 min read

In this article by Konstantin Kuminsky author of the book, VMware vCenter Cookbook, we will review some options and features available in vCenter to improve an administrator’s efficiency.

(For more resources related to this topic, see here.)

Deploying new hosts faster with scripted installation

Scripted installation is an alternative way to deploy ESXi hosts. It can be used when several hosts need to be deployed or upgraded.

The installation script contains ESXi settings and can be accessed by a host during the ESXi boot from the following locations:

  • FTP
  • HTTP or HTTPS
  • NFS
  • USB flash drive or CD-ROM

How to do it…

The following sections describe the process of creating an installation script and using it to boot the ESXi host.

Creating an installation script

An installation script contains installation options for ESXi. It’s a text file with the .cfg extension.

The best way to create an installation script is to use the default script supplied with the ESXi installer and modify it. The default script is located in the /etc/vmware/weasel/ folder location and is called ks.cfg.

Commands that can be modified include, but are not limited to:

  • The install, installorupgrade, or upgrade commands define the ESXi disk—location, where the installation or upgrade will be installed. The available options are:
    • –disk: This option is the disk name which can be specified as path (/vmfs/devices/disks/vmhbaX:X:X), VML name (vml.xxxxxxxx) or as LUN UID (vmkLUM_UID)
    • –overwritevmfs: This option wipes the existing datastore.
    • –preservevmfs: This option keeps the existing datastore.
    • –novmfsondisk: This option prevents a new partition from being created.
  • The Network command, which specifies the network settings. Most of the available options are self-explanatory:
    • –bootproto=[dhcp|static]
    • –device: MAC address of NIC to use
    • –ip
    • –gateway
    • –nameserver
    • –netmask
    • –hostname
    • –vlanid

A full list of installation and upgrade commands can be found in the vSphere5 documentation on the VMware website at https://www.vmware.com/support/pubs/.

Use the installation script to configure ESXi

In order to use the installation script, you will need to use additional ESXi boot options.

  1. Boot a host from the ESXi installation disk.
  2. When the ESXi installer screen appears, press Shift + O to provide additional boot options.
  3. In the command prompt, type the following:
    ks=<location of the script> <additional boot options>

The valid locations are as follows:

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

The additional options available are as follows:

  • gateway: This option is the default gateway
  • ip: This option is the IP address
  • nameserver: This option is the DNS server
  • netmask: This option is the subnet mask
  • vlanid: This option is the VLAN ID
  • netdevice: This option is the MAC address of NIC to use
  • bootif: This option is the MAC address of NIC to use in PXELINUX format

For example, for the HTTP location, the command will look like this:

ks=http://XX.XX.XX.XX/scripts/ks-v1.cfg nameserver=XX.XX.XX.XX
ip=XX.XX.XX.XX netmask=255.255.255.0 gateway=XX.XX.XX.XX

Deploying new hosts faster with auto deploy

vSphere Auto Deploy is VMware’s solution to simplify the deployment of large numbers of ESXi hosts. It is one of the available options for ESXi deployment along with an interactive and scripted installation.

The main difference of Auto Deploy compared to other deployment options is that the ESXi configuration is not stored on the host’s disk. Instead, it’s managed with image and host profiles by the Auto Deploy server.

Getting ready

Before using Auto Deploy, confirm the following:

  • The Auto Deploy server is installed and registered with vCenter.

    It can be installed as a standalone server or as part of the vCenter installation.

  • The DHCP server exists in the environment.
  • The DHCP server is configured to point to the TFTP server for PXE boot (option 66) with the boot filename undionly.kpxe.vmw-hardwired.
  • The TFTP server that will be used for PXE boot exists and is configured properly.
  • The machine where Auto Deploy cmdlets will run has the following installed:
    • Microsoft .NET 2.0 or later
    • PowerShell 2.0 or later
    • PowerCLI including Auto Deploy cmdlets
  • New hosts that will be provisioned with Auto Deploy must:
    • Meet the hardware requirements for ESXi 5
    • Have network connectivity to vCenter, preferably 1 Gbps or higher
    • Have PXE boot enabled

How to do it…

Once prerequisites are met, the following steps are required to start deploying hosts.

Configuring the TFTP server

In order to configure the TFTP server with the correct boot image for ESXi, execute the following steps:

  1. In vCenter, go to Home | Auto Deploy.
  2. Switch to the Administration tab.
  3. From the Auto Deploy page, click on Download TFTP Boot ZIP.
  4. Download the file and unzip it to the appropriate folder on the TFTP server.

Creating an image profile

Image profies are created using Image Builder PowerCLI cmdlets. Image Builder requires PowerCLI and can be installed on a machine that’s used to run administrative tasks. It doesn’t have to be a vCenter server or Auto Deploy server and the only requirement for this machine is that it must have access to the software depot—a file server that stores image profiles.

Image profiles can be created from scratch or by cloning an existing profile. The following steps outline the process of creating an image profile by cloning. The steps assume that:

  • The Image Builder has been installed.
  • The appropriate software depot has been downloaded from the VMware website by going to http://www.vmware.com/downloads and searching for the software depot.

Cloning an existing profile included in the depot is the easiest way to create a new profile. The steps to do so are as follows:

  1. Add a depot with the image profile to be cloned:
    Add-EsxSoftwareDepot -DepotUrl <Path to softwaredepot>
  2. Find the name of the profile to be cloned using Get-ESXImageProfile.
  3. Clone the profile:
     New-EsxImageProfile -CloneProfile <Existing profile name> - Name <New profile name>
  4. Add a software package to the new image profile:
    Add-EsxSoftwarePackage -ImageProfile <New profile name> - SoftwarePackage <Package>

At this point, the software package will be validated and in case of errors, or if there are any dependencies that need to be resolved, an appropriate message will be displayed.

Assigning an image profile to hosts

To create a rule that assigns an image profile to a host, execute the following steps:

  1. Connect to vCenter with PowerCLI:
    Connect-VIServer <vCenter IP or FQDN>
  2. Add the software depot with the correct image profile to the PowerCLI session:
    Add-EsxSoftwareDepot <depot URL>
  3. Locate the image profile using the Get-EsxImageProfile cmdlet.
  4. Define a rule that assigns hosts with certain attributes to an image profile. For example, for hosts with IP addresses for a range, run the following command:
    New-DeployRule -Name <Rule name> -Item <Profile name> -Pattern "ipv4=192.168.1.10-192.168.1.20"
    Add-DeployRule <Rule name>

Assigning a host profile to hosts

Optionally, the existing host profile can be assigned to hosts. To accomplish this, execute the following steps:

  1. Connect to vCenter with PowerCLI:
     Connect-VIServer <vCenter IP or FQDN>
  2. Locate the host profile name using the Get-VMhostProfile command.
  3. Define a rule that assigns hosts with certain attributes to a host profile. For example, for hosts with IP addresses for a range, run the following command:
    New-DeployRule -Name <Rule name> -Item <Profile name> -Pattern "ipv4=192.168.1.10-192.168.1.20"
    Add-DeployRule <Rule name>

Assigning a host to a folder or cluster in vCenter

To make sure a host is placed in a certain folder or cluster once it boots, do the following:

  1. Connect to vCenter with PowerCLI:
    Connect-VIServer <vCenter IP or FQDN>
  2. Define a rule that assigns hosts with certain attributes to a folder or cluster. For example, for hosts with IP addresses for a range, run the following command:
    New-DeployRule -Name <Rule name> -Item <Folder name> -Pattern
    "ipv4=192.168.1.10-192.168.1.20"
    Add-DeployRule <Rule name>

    If a host is assigned to a cluster it inherits that cluster’s host profile.

How it works…

Auto Deploy utilizes the PXE boot to connect to the Auto Deploy server and get an image profile, vCenter location, and optionally, host profiles. The detailed process is as follows:

  • The host gets gPXE executable and gPXE configuration files from the PXE TFTP server.
  • As gPXE executes, it uses instructions from the configuration file to query the Auto Deploy server for specific information.
  • The Auto Deploy server returns the requested information specified in the image and host profiles.
  • The host boots using this information.
  • Auto Deploy adds a host to the specified vCenter server.
  • The host is placed in maintenance mode when additional information such as IP address is required from the administrator.
  • To exit maintenance mode, the administrator will need to provide this information and reapply the host profile.

When a new host boots for the first time, vCenter creates a new object and stores it together with the host and image profiles in the database. For any subsequent reboots, the existing object is used to get the correct host profile and any changes that have been made.

More details can be found in the vSphere 5 documentation on the VMware website at https://www.vmware.com/support/pubs/.

Summary

In this article we learnt how new hosts can be deployed with scripted installation and auto deploy techniques.

Resources for Article:


Further resources on this subject:


LEAVE A REPLY

Please enter your comment!
Please enter your name here