Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
VMware vSphere 6.7 Cookbook

You're reading from   VMware vSphere 6.7 Cookbook Practical recipes to deploy, configure, and manage VMware vSphere 6.7 components

Arrow left icon
Product type Paperback
Published in Aug 2019
Publisher
ISBN-13 9781789953008
Length 570 pages
Edition 4th Edition
Tools
Arrow right icon
Author (1):
Arrow left icon
Abhilash G B Abhilash G B
Author Profile Icon Abhilash G B
Abhilash G B
Arrow right icon
View More author details
Toc

Table of Contents (18) Chapters Close

Preface 1. Deploying a New vSphere 6.7 Infrastructure FREE CHAPTER 2. Planning and Executing the Upgrade of vSphere 3. Configuring Network Access Using vSphere Standard Switches 4. Configuring Network Access Using vSphere Distributed Switches 5. Configuring Storage Access for Your vSphere Environment 6. Creating and Managing VMFS Datastores 7. SIOC, Storage DRS, and Profile-Driven Storage 8. Configuring vSphere DRS, DPM, and VMware EVC 9. Achieving High Availability in a vSphere Environment 10. Achieving Configuration Compliance Using vSphere Host Profiles 11. Building Custom ESXi Images Using Image Builder 12. Auto-Deploying Stateless and Stateful ESXi Hosts 13. Creating and Managing Virtual Machines 14. Upgrading and Patching Using vSphere Update Manager 15. Securing vSphere Using SSL Certificates 16. Monitoring the vSphere Infrastructure 17. Other Books You May Enjoy

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.

You have been reading a chapter from
VMware vSphere 6.7 Cookbook - Fourth Edition
Published in: Aug 2019
Publisher:
ISBN-13: 9781789953008
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at R$50/month. Cancel anytime