Home » VMware » vSphere 5.5

Category: vSphere 5.5

ESXi Host is downloading/reading file from HTTP mirror

Automated installation with VMware ESXi 5.5/6.0/6.5

Information

In this blog post we are going to automate the installation of VMware ESXi 5.5, 6.0 and 6.5. This can be done with a so called “kickstart” configuration file which is officially supported by VMware. The file contains the configuration for a VMWare ESXi Host to setup settings like IP address, subnet mask, hostname, license key, etc.

The kickstart configuration file can be made available on the following locations:
* FTP
* HTTP/HTTPS
* NFS Share
* USB flash drive
* CD/DVD device

Personally I prefer the HTTP protocol.

Use Case

You might ask yourself, why should I install an ESXi Host with a kickstart file? Some of the use cases I identified over the years:
* The very first ESXi Hosts for your SDDC environment (before VMware vCenter is deployed or vSphere Auto Deploy is configured)
* A standalone ESXi Host for a small environment
* A Home Lab environment to install nested VMware ESXi Hosts

Setup a webserver

To make the kickstart configuration file available for the ESXi Host we need a webserver.
Basically every webserver can serve this file. Some webserver products: Apache, Microsoft IIS and NGINX.

In this environment I used a Microsoft IIS server on a Windows 10 Client, don’t forget to add the cfg extension to the MIME types.

Configuration file

Now it’s time to create a text file with your favorite text editor. The text file in this example is called (ks.cfg).
I have added two configuration files as samples, one with the minimum settings and one I normally use for my lab environment.

Configuration file – Simple (ks.cfg)
#
# 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

# The install media is in the CD-ROM drive
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() )
Configuration file – Advanced (ks.cfg)
### ESXi Installation Script
### Hostname: LAB-ESXi01A
### Author: M. Buijs
### Date: 2017-08-11
### Tested with: ESXi 6.0 and ESXi 6.5

##### Stage 01 - Pre installation:

	### Accept the VMware End User License Agreement
	vmaccepteula

	### Set the root password for the DCUI and Tech Support Mode
	rootpw VMware1!
	
	### The install media (priority: local / remote / USB)
	install --firstdisk=local --overwritevmfs --novmfsondisk

	### Set the network to DHCP on the first network adapter
	network --bootproto=static --device=vmnic0 --ip=192.168.151.101 --netmask=255.255.255.0 --gateway=192.168.151.254 --nameserver=192.168.126.21,192.168.151.254 --hostname=LAB-ESXi01A.lab.local --addvmportgroup=0

	### Reboot ESXi Host
	reboot --noeject

##### Stage 02 - Post installation:

	### Open busybox and launch commands
	%firstboot --interpreter=busybox

	### Set Search Domain
	esxcli network ip dns search add --domain=lab.local

	### Add second NIC to vSwitch0
	esxcli network vswitch standard uplink add --uplink-name=vmnic1 --vswitch-name=vSwitch0

	###  Disable IPv6 support (reboot is required)
	esxcli network ip set --ipv6-enabled=false

	### Add NTP Server addresses
	echo "server 192.168.126.21" >> /etc/ntp.conf;
	echo "server 192.168.151.254" >> /etc/ntp.conf;

	### Allow NTP through firewall
	esxcfg-firewall -e ntpClient
	
	### Enable NTP autostartup
	/sbin/chkconfig ntpd on;

	### Rename local datastore (currently disabled because of --novmfsondisk)
	#vim-cmd hostsvc/datastore/rename datastore1 "DAS - $(hostname -s)"

	### Disable CEIP
	esxcli system settings advanced set -o /UserVars/HostClientCEIPOptIn -i 2
	
	### Enable maintaince mode
	esxcli system maintenanceMode set -e true
	
	### Reboot
	esxcli system shutdown reboot -d 15 -r "rebooting after ESXi host configuration"
Installing a ESXi Host with Kickstart file

Step 1: Boot the ESXi host with a VMware ESXi ISO.
Step 2: Press ”'”shift + o””’ at boot
Step 3: Enter the following line after runweasel:
** For a HTTP share: ”'”ks=http://%IP_or_FQDN%/kg.cfg””’
** For a HTTPS share: ”'”ks=https://%IP_or_FQDN%/kg.cfg””’
** For a NFS share: ”'”ks=nfs://%IP_or_FQDN%/ks.cfg””’
Step 4: The installation will start and finish the ESXi Host installation based on the ks.cfg configuration file.

Screenshots
Insert the path to the ks.cfg configuration file.
Insert the path to the ks.cfg configuration file.
ESXi Host is downloading/reading file from HTTP mirror
ESXi Host is downloading/reading file from HTTP mirror

VMware Product Vulnerability (CVE-2017-5638)

A security vulnerability has been discoverd in some VMware products (CVE-2017-5638).
It’s a critical vulnerability which allows remote code execution (RCE) on Apache Struts 2.

The vulnerability effects the following VMware products:
– DaaS 6.X / 7.X
– Hyperic 5.X
– vCenter 5.5 / 6.0 / 6.5
– vRops 6.X

Read more

Changing Guest Time Synchronization Setting From Within-Guest OS

I recently got a question about enabling and disabling time synchronization for virtual machines.
The customer ask about a solution to change the settings from within the operating system.

Normally I would change the virtual machine time synchronization settings by hand with the vSphere Client/Web Client/HTML5 or with a PowerCLI script, but after some searching it appears, there is a solution provided by VMware.
Read more

PowerCLI Datastore Selection without Storage DRS (SDRS)

I recently ran into the following problem: the situation occurs when you want to deploy a virtual machines with PowerCLI to a cluster with multiple datastores but your not licensed for Storage DRS.
The default PowerCLI behavior is to select the first datastore detected (alphabetic order). To solve this problem I created the following PowerCLI code:

### Variables
	$CLUSTER = "Production" 					# Cluster name
	$FOLDER = "Deployed VMs"					# Virtual Machine folder

### Select datastores available and sort them on free space (select the one with most space free)
$DS = Get-Cluster -Name $CLUSTER | Get-Datastore | Select Name, FreeSpaceGB | Sort-Object FreeSpaceGB -Descending | Select -first 1

### Create a virtual machine called VM01
New-VM -Name VM01 -ResourcePool $CLUSTER -Datastore $DS.Name -Location $FOLDER -MemoryGB 1 -CD -DiskGB 5

The code is tested with PowerCLI 6.5 R1 against a VMware vCenter 6.0 server.