Book Image

VMware vSphere 6.7 Cookbook - Fourth Edition

By : Abhilash G B
Book Image

VMware vSphere 6.7 Cookbook - Fourth Edition

By: Abhilash G B

Overview of this book

VMware vSphere is the most comprehensive core suite of SDDC solutions on the market. It helps transform data centers into simplified on-premises private cloud infrastructures. This edition of the book focuses on the latest version, vSphere 6.7. The books starts with chapters covering the greenfield deployment of vSphere 6.7 components and the upgrade of existing vSphere components to 6.7. You will then learn how to configure storage and network access for a vSphere environment. Get to grips with optimizing your vSphere environment for resource distribution and utilization using features such as DRS and DPM, along with enabling high availability for vSphere components using vSphere HA, VMware FT, and VCHA. Then, you will learn how to facilitate large-scale deployment of stateless/stateful ESXi hosts using Auto Deploy. Finally, you will explore how to upgrade/patch a vSphere environment using vSphere Update Manager, secure it using SSL certificates, and then monitor its performance with tools such as vSphere Performance Charts and esxtop. By the end of this book, you'll be well versed in the core functionalities of vSphere 6.7 and be able to effectively deploy, manage, secure, and monitor your environment.
Table of Contents (18 chapters)

Scripted deployment of ESXi

When you have a large number of ESXi hosts to deploy, any method to automate and reduce the amount of manual work is considered gold. The main benefit of automating installation is that it helps standardize multiple installations without having to carefully audit each installation. VMware has always supported the scripted installation of ESXi hosts, and that has not changed with vSphere 6.7.

Like with any automated task, the scripted installation of an ESXi host requires the use of a configuration file that contains the intended host configuration that's stored at a location that's accessible to the ESXi host. The configuration file is referred to as a kickstart file (.cfg).

A kickstart file can be stored at any of the following supported locations:

  • A webserver (access over HTTP or HTTPS)
  • A network file server (FTP/NFS)
  • A local storage medium that's accessible to the host (CD-ROM/USB)

In this recipe, we will learn how to perform an unattended installation of ESXi using the installer medium, a local USB device, and a network location.

Getting ready

Before you begin, prepare a script for the installation. A default script is available on every ESXi host at /etc/vmware/weasel/ks.cfg. Although the extension is .cfg, the filename doesn't need to be the same. It should be a plain text file with the .cfg extension.

Here is a sample script:

# Sample scripted installation file for vdescribed.lab
# Accept the VMware End User License Agreement
vmaccepteula
# Clear/format existing partitions
clearpart --firstdisk --overwritevmfs
# Set the root password for the DCUI and Tech Support Mode
rootpw password@123
# The install media is in the CD-ROM drive
install --firstdisk --overwritevmfs
# Set a static IP Configuration
network --bootproto=static --device=vmnic0 --ip=192.168.78.91 --netmask=255.255.255.0 --gateway=192.168.78.1 --nameserver=192.168.78.130 --hostname=bkesx02
reboot
# Post Installation Tasks
%firstboot --interpreter=busybox
#Create vSwitch
esxcli network vswitch standard add --vswitch-name=vSwitch2
# Disable ipv6
esxcli network ip set --ipv6-enabled=false
sleep 30
reboot

Once the script has been prepared, store it in one of the support locations. For this recipe, I have stored it on an NFS server.

How to do it...

The following procedure will guide you through the steps that are required to perform a scripted installation of the ESXi host:

  1. Boot the server using the ESXi ISO. The ISO can be mounted to the server via its IPMI interface (DRAC, ILO, and so on).
  2. At the Loading ESXi Installer screen, before it automatically boots, hit Shift + O to edit the boot options. This is indicated in the bottom right-hand corner of the screen:
  1. On the next screen, enter the location of the kickstart file and hit Enter to begin the installation:
  1. Once the installation is complete, if the kickstart script includes a reboot command, like it does in our script, the server will be rebooted; otherwise, you will be prompted for confirmation.

How it works...

When using a kickstart file, the ESXi installation requires no user intervention. The kickstart file can be configured to run a variety of tasks. It can also be configured to run Python scripts after the installation.

Let's examine the sample script that was used in this recipe. This script is available in the Getting ready section:

Script command

Purpose

vmaccepteula

Accepts the ESXi End User License Agreement.

clearpart --firstdisk --overwritevmfs

Used to format the selected disk and overwrite any VMFS volume. This is a destructive process and cannot be reversed.

install --firstdisk --overwritevmfs

Used to indicate that this is a fresh installation, and the installation will be informed on the first disk in the list by overwriting any VMFS volume.

rootpw password@123

Sets the root password as password@123.

network --bootproto=static --device=vmnic0 --ip=192.168.78.91 --netmask=255.255.255.0 --gateway=192.168.78.1 --nameserver=192.168.78.130 --hostname=bkesx02

Configures a static IP address, a DNS server address, and a hostname for ESXi.

reboot

Reboots the ESXi host.

%firstboot --interpreter=busybox

This is used to indicate that the commands following this line will be executed on first boot. Setting the interpreter to busybox will let you execute the CLI command. Setting it to Python will let you run Python scripts.

esxcli network vswitch standard add -v=vSwitch2

Creates a second standard switch with the name vSwitch2.

esxcli network ip set --ipv6-enabled=false

Disables IPv6.

sleep 30

Will not execute any commands for 30 seconds.

For a list of all supported commands in the kickstart file, refer to the Installation and Upgrade Script Commands section on page 78 of the VMware ESXi Installation and Setup guide, which can be found at https://docs.vmware.com/en/VMware-vSphere/6.7/vsphere-esxi-67-installation-setup-guide.pdf.

There's more...

Although scripted installation automates the process to some extent, it still requires you to log in to each ESXi host and supply a location for the script file. An unattended deployment should not require any user intervention other than just booting up the server. This is achieved by PXE booting the hosts and using the kickstart script from a network location to run the installation. However, if unattended deployment has been considered, then the recommendation is to use vSphere Auto Deploy, which offers more control and manageability. vSphere Auto Deploy will be covered in a later chapter.