Bare Metal Deployment of ESXi on HP Proliant Hardware: Part 3

Save to My DOJO

Bare Metal Deployment of ESXi on HP Proliant Hardware: Part 3

Table of contents

This is the final part of our series on automating the bare metal install of ESXi on an HP Proliant Server. In part 1 of this series, we went over the workflow of the bare metal deployment process as well as created a web server to host our ISOs. We also got a jump on downloading the latest HP Proliant Support Pack and installed the HP iLO PowerShell cmdlets. In part 2, we built our RAID configuration ISOs and our unattended ESXi install ISO. Part 3 is where all the magic happens. We are going to make a few small edits to the deployment script and finally give it a run. Let’s get started.

Deployment Script

Below is the deployment script you should use. I made it into a function so that it can be used with -verbose as well as the other benefits you get when making a cmdlet binding function. You will need to modify these lines to change the location of each ISO and the IP Scheme for your particular staging environment. Notice that I select the IP of the iLO and ESXi configurations by adding the staging slot number to the end of the address. So in my example, the iLO in staging slot 1 would get 192.168.0.21. The idea is that we have multiple slots in the staging server rack for deployments, this allows us to deploy multiple servers at once and only have to specify the staging slot parameter to configure IPs:

Copy the code to a text file and save it as a .ps1. Change out the highlighted lines shown above:

function New-ProliantServer {
<#
.SYNOPSIS
Configures ilo, updates firmware, configures RAID, and installs ESXi automatically
#>

[CmdletBinding(SupportsShouldProcess=$True)]

param(
[Parameter(Position=0,Mandatory=$True,ValueFromPipelineByPropertyName=$true,HelpMessage="Enter the current IP address of the ilo")]
[String]$iloIP,

[Parameter(Position=1,Mandatory=$True,ValueFromPipelineByPropertyName=$true,HelpMessage="What timezone would you like the iLO to be configured for (Eastern ,Central ,Pacific)")]
[ValidateSet('Central','Pacific','Eastern','Mountain')]
[String]$Timezone,

[Parameter(Position=2,Mandatory=$True,ValueFromPipelineByPropertyName=$true,HelpMessage="Enter the default password of the ilo")]
[String]$DefaultPassword,

[Parameter(Position=3,Mandatory=$True,ValueFromPipelineByPropertyName=$true,HelpMessage="Enter the name of the esxi host")]
[String]$ESXiHostName,

[Parameter(Position=4,Mandatory=$True,ValueFromPipelineByPropertyName=$true,HelpMessage="Enter the new Administrator password that you would like to configure the ilo with")]
[Security.SecureString]$NewiLOPassword,

[Parameter(Position=5,Mandatory=$True,ValueFromPipelineByPropertyName=$true,HelpMessage="Enter the ilo Advanced license key")]
[String]$iloKey,

[Parameter(Position=6, Mandatory=$true,ValueFromPipelineByPropertyName=$true,HelpMessage="How many drives are in this server?)")]
[ValidateSet('4','5','6','7','8','9','10','11','12','13''14','15','16','17','18','19','20','21','22','23','24')]
[String]$Drives,

[Parameter(Position=7, Mandatory=$true,ValueFromPipelineByPropertyName=$true,ParameterSetName='StagingIP',HelpMessage="What Staging rack slot would you like to IP this ilo?)")]
[ValidateSet('1','2','3')]
[String]$StagingSlot
)

Begin{

#ISO files - edit these when you update your ISO files

$webserverfilelocation= "\\192.168.0.7\c$\inetpub\deployment\" #include the \ at the end
$RAIDConfISO= "http://192.168.0.7/deployment/" + $drives + "Drives.iso"
$ESXiISO= "http://192.168.0.7/deployment/" + $stagingslot + ".iso"
$HPSPP= "http://192.168.0.7/deployment/P05006_001_spp-2018.03.0-SPP2018030.2018_0226.84_Disk8.iso"

#Networking for Each Staing slot - Edit these to change the IP that the ilo and ESXi are going to get for each staging slot
If ($stagingslot -contains '1' -or '2' -or '3') {
$NewiLOSubnet = "255.255.255.0"
$NewiLOGateway = "192.168.0.1"
$NewiLOIPaddress = "192.168.0.2" + $StagingSlot
$NewiLODNS1 = "192.168.0.1"
$newiLODNS2 = "192.168.0.2"
$ESXiSubnet = "255.255.255.0"
$ESXiGateway = "192.168.0.1"
$ESXiIpAddress = "192.168.0.3" + $StagingSlot
$ESXiDNS1 = "192.168.0.1"
$ESXiDNS2 = "192.168.0.2"
}

#prompts for Admin creds to upload the kickstart file to the web server
$WebServerCreds = get-credential -message "List your creds for connecting to the web server."

#lower case the esxi host server name
$servername = $ESXiHostName.ToLower()

#Check for HP ILO MOdules
if (!(get-command Test-HPEiLOConnection -ErrorAction SilentlyContinue )){
Write-error "HP Cmdlets are not installed. Script will exit." -ForegroundColor Red
sleep -Seconds 30
break
}

#decodes secure password for new Administrator ilo password
$NewPassword = (New-Object System.Management.Automation.PSCredential("Administrator",$NewIloPassword)).GetNetworkCredential().password

}

Process{
#creates ilo name based on server name
$iloname = $servername -ireplace "esx","ilo"

#timezone logic
if ($Timezone -eq "Eastern"){$zone = "US/Eastern"}
if ($Timezone -eq "Central"){$zone = "US/Central"}
if ($Timezone -eq "Pacific"){$zone = "US/Pacific"}
if ($Timezone -eq "Mountain"){$zone = "US/Mountain"}

#hide warnings
$WarningActionPreference = ‘SilentlyContinue’

#connect to ilo
$iloConnection = Connect-HPEiLO -IP $iloIP -Username Administrator -Password $DefaultPassword -DisableCertificateAuthentication

#Change Administrator password
Set-HPEiLOAdministratorPassword -Connection $iloConnection -Password $NewPassword -Force -confirm:$false

#re-initiate connection with new password
$iloConnection = Connect-HPEiLO -IP $iloIP -Username Administrator -Password $NewPassword -DisableCertificateAuthentication

Write-host "Changing Administrator Password" -ForegroundColor Cyan

#power settings
Set-HPEiLOPowerRegulatorSetting -Connection $iloconnection -Mode Max

Write-host "Modifying Power Settings" -ForegroundColor Cyan

#Add ilo advanced key
Set-HPEiLOLicense -Connection $iloConnection -key $ilokey

Write-host "Activating ilo Advanced" -ForegroundColor Cyan

#configure Access settings
Set-HPEiLOAccessSetting -Connection $iloConnection -ServerName $servername

write-host "Setting server name" -ForegroundColor Cyan

#Configures the networking settings in the ilo
$params = @{interfacetype ="Dedicated";
IPv4Address = "$NewiLOIPaddress";
IPv4SubnetMask = "$NewiLOSubnet";
IPv4Gateway = "$NewiLOGateway";
DHCPEnabled = "no";
DNSName = "$iloname";
DHCPv4WINSServer = "disabled";
RegisterWINSServer = "disabled" }

#The HP Cmdlet only likes this format for some reason
$DNSServerTypes = ,@("Primary","Secondary")
$DNSServers = ,@("$NewiLODNS1","$newiLODNS2")

Write-host "Configuring Network settings, ilo will reset after completed" -ForegroundColor Cyan

Set-HPEiLOIPv4NetworkSetting @params -Connection $iloConnection -force -DNSServerType $DNSServerTypes -DNSServer $DNSServers | out-null

#Wait for ilo reset
sleep -Seconds 10
do {
$iloConnection = Connect-HPEiLO -IP $NewiLOIPaddress -Username Administrator -Password $NewPassword -DisableCertificateAuthentication -WarningAction SilentlyContinue -ErrorAction SilentlyContinue -Verbose:$false
sleep -s 2
} until ($iloConnection.IsConnected -eq "True")

#Configures the ipv6 networking settings in the ilo
$params = @{ interfacetype ="Dedicated";
DHCPv6Stateful = "Disabled";
statelessAddressAutoconfiguration = "Disabled";
DHCPv6Statelessmode = "Disabled";
RegDDNSServer = "Disabled";
PreferredProtocol = "Disabled";
}
Write-host "Configuring ipv6 Network settings, ilo will reset after completed" -ForegroundColor Cyan

Set-HPEiLOSNTPSetting -Connection $iloConnection -DHCPv4NTPServer Disabled -DHCPv6NTPServer Disabled -SNTPServer time.google.com -Timezone $Timezone
Set-HPEiLOipv6NetworkSetting @params -connection $iloConnection -force | out-null

#wait for ilo reset
sleep -Seconds 10
do {
$status = Get-HPEiLOHealthSummary -Connection $iloConnection -WarningAction SilentlyContinue -ErrorAction SilentlyContinue -Verbose:$false
sleep -s 2
} until ($status.Status -eq "OK")

#update firmware
Write-host "Mounting HP fimrware disk from $HPSPP powering on server, server will boot to SPP and automatically install new updates. A message will display once completed" -ForegroundColor Cyan

Set-HPEiLOBootMode -Connection $iloConnection -PendingBootMode LegacyBIOS -WarningAction SilentlyContinue | out-null
Mount-HPEiLOVirtualMedia -Connection $iloConnection -device CD -ImageURL $HPSPP -WarningAction SilentlyContinue | out-null
Set-HPEiLOVirtualMediaStatus -Connection $iloConnection -Device CD -VMBootOption BootOnNextReset -WarningAction SilentlyContinue | out-null
set-hpEiloserverpower -Connection $iloConnection -Power On -WarningAction SilentlyContinue | out-null

#Wait time and loop for firmware to update
sleep -Seconds 180
do {
$fwupdatestatus = get-hpeiloserverpower -Connection $iloConnection -WarningAction SilentlyContinue
sleep -s 1
}until ($fwupdatestatus.Power -eq "Off")
sleep -Seconds 30

#Create RAID configuration
write-host "Configuring RAID Configuration, booting server to WinPE to run HP Array Scripts." -ForegroundColor Cyan
Mount-HPEiLOVirtualMedia -Connection $iloConnection -device CD -ImageURL $RAIDConfISO -WarningAction SilentlyContinue | out-null
Set-HPEiLOVirtualMediaStatus -Connection $iloConnection -Device CD -VMBootOption BootOnNextReset -WarningAction SilentlyContinue | out-null

sleep -seconds 120

Write-host "waiting for Raid config to be done" -ForegroundColor Cyan

#wait until server is powered off by raid config disk
do {
$powerstatus = get-hpeiloserverpower -Connection $iloConnection -WarningAction SilentlyContinue
sleep -s 10
}while ($powerstatus.Power -eq "ON")

#long sleep time after RAID configured, I find this helps with ensuring that the RAID is built before ESXi is installed
sleep -Seconds 350

#Create ESXi Configuration
write-host "Creating ESXi install config file" -ForegroundColor Cyan

#create config file
$esxihostname = $esxihostname.ToLower()
$passwordHash = '$1$RYrDe0s7$saHQ6deVkNW8mQn8bgGDT1'
$Config= @"

#Accept the VMware End User License Agreement

vmaccepteula



# clear paritions and install

clearpart --firstdisk --overwritevmfs

install --firstdisk --overwritevmfs



#set the root password

rootpw --iscrypted $passwordHash



#Host Network Settings

network --bootproto=static --addvmportgroup=1 --ip=$ESXiIpAddress --netmask=$ESXiSubnet --gateway=$ESXiGateway --nameserver=$ESXiDNS1 --hostname=$ESXiHostName





reboot



#Firstboot

%firstboot --interpreter=busybox

sleep 30



#Disable IPv6

esxcli network ip set --ipv6-enabled=false

esxcli system shutdown reboot -d 60 -r "making IPv6 config changes"



#Enter Maintenance mode

vim-cmd hostsvc/maintenance_mode_enter



#suppress Shell Warning

esxcli system settings advanced set -o /UserVars/SuppressShellWarning -i 1

esxcli system settings advanced set -o /UserVars/ESXiShellTimeOut -i 1



#Add DNS Nameservers to /etc/resolv.conf

cat > /etc/resolv.conf << \DNS

nameserver $ESXiDNS1

nameserver $ESXiDNS2

DNS



#VSwitch Configurations

esxcli network vswitch standard add --vswitch-name=vSwitch0 --ports=24

esxcli network vswitch standard uplink add --uplink-name=vmnic0 --vswitch-name=vSwitch0

esxcli network vswitch standard uplink add --uplink-name=vmnic1 --vswitch-name=vSwitch0

esxcli network vswitch standard uplink add --uplink-name=vmnic2 --vswitch-name=vSwitch0

esxcli network vswitch standard uplink add --uplink-name=vmnic3 --vswitch-name=vSwitch0

esxcli network vswitch standard policy failover set --active-uplinks=vmnic0,vmnic1,vmnic2,vmnic3 --vswitch-name=vSwitch0

esxcli network vswitch standard portgroup policy failover set --portgroup-name="Management Network" --active-uplinks=vmnic0,vmnic1,vmnic2,vmnic3

esxcli network vswitch standard portgroup add --portgroup-name=$ESXiHostName-prod0 --vswitch-name=vSwitch0

esxcli network vswitch standard portgroup remove --portgroup-name="VM Network" --vswitch-name=vSwitch0









#Reboot

sleep 30

reboot



"@

#output the config file to the web server

$newdrive = New-PSDrive Temp -PSProvider FileSystem -Root $webserverfilelocation -Credential $WebServerCreds
$config | out-file -filepath ("Temp:\ESXiStagingslot" + $StagingSlot + ".cfg") -Encoding ascii -force
Remove-PSDrive Temp

#install ESXi
write-host "Installing ESXi, booting up to install disk" -ForegroundColor Cyan

Mount-HPEiLOVirtualMedia -Connection $iloConnection -device CD -ImageURL $ESXiISO -WarningAction SilentlyContinue | out-null
Set-HPEiLOVirtualMediaStatus -Connection $iloConnection -Device CD -VMBootOption BootOnNextReset -WarningAction SilentlyContinue | out-null
set-hpEiloserverpower -Connection $iloConnection -Power On -WarningAction SilentlyContinue | out-null

#wait for ESXi to complete installing
sleep -Seconds 500

#configure boot order
Set-HPEiLOPersistentBootOrder -Connection $iloConnection -BootOrder @("Boot0008,Boot000C") | out-null
Write-host "Installation is done" -ForegroundColor green

}



}










The Demo

Let’s give this a run. First, we need some info for the parameters of the script. On the physical server, to simulate a brand new server install, we will need the default ilo name and password:

Now let’s ensure we can ping the server by name:

NOTE: Just an FYI, in these screenshots I’m using a fake serial number and license key.

Now its time to run the script. Open up an administrative PowerShell console and type in the following command. I saved this code to a .ps1 file called New-ProliantServer.ps1. I’m going to import this function into my PowerShell session so then I can run it with parameters. So we’ll start by typing in the following command:

Import-Module "C:\Temp\New-ProliantServer.ps1"

Now we will run our function with the required parameters:

-iloIP (the ilo name or IP Address)
-Timezone (mine is Eastern)
-DefaultPassword (the default ilo Password)
-ESXIHostname (the name of the ESXi host)
-ILOKey (the ilo advanced license key)
-Stagingslot (we set up 3 staging slots for IP Address schemes and ESXi images)
-Drives (the number of disks in the server)

New-ProliantServer -iloIP ilo2m222500v1 -timezone Eastern -Defaultpassword CXIWONWK -ESXiHostname ESXHOST1 -ilokey 3MMRW-DMTVD-WLWLQ-PXCL8-ZVBKW -Stagingslot 1 -drives 8

I left out the new iLO password  parameter so we would get prompted for it and I could securely type it in:

We then get our last prompt for credentials to the web server. This is used for when we generate our ESXi kickstart file, we need to copy it to the web server so that we can call it during the ESXi install:

Click Ok and away we go! Each step is called out:

Once its done, let’s check out our ESXi host, it now has our configuration:

And we’re done!

This process has saved me so many hours with building servers and the best part is, its FREE! By following the steps outlined in this 3 part series you can now be as Jeffery Snover puts it, “the hero of your company”.

Thanks for Reading!

[the_ad id=”4738″][thrive_leads id=’18673′]

Altaro VM Backup
Share this post

Not a DOJO Member yet?

Join thousands of other IT pros and receive a weekly roundup email with the latest content & updates!

3 thoughts on "Bare Metal Deployment of ESXi on HP Proliant Hardware: Part 3"

  • newbie says:

    ..great report, thank you very much.

    I try to create a RAID 1 on 2 system disks (2x Intel SSD S3520 Series 480GB, B140i Controller, DL380 Gen9) but in my RAID configuration there seems to be a fault. I get no error during the procedure but no RAID results.

    I can create the RAID 1 manually via SSA GUI without any problems. Unfortunately not via RAID ISO according to the report.

    RAID configuration for deploy.ini:
    ****************************************
    #create RAID Configuration Script
    “@Action= Configure
    Method= Custom
    Controller= SLOT 0b
    ; PowerMode= MaxPerformance
    ReadCache= 10
    WriteCache= 90
    RebuildPriority= High
    ExpandPriority= Medium
    ParallelSurfaceScanCount= 1
    SurfaceScanMode= Idle
    SurfaceScanDelay= 3
    Latency= Disable
    DriveWriteCache= Disabled
    NoBatteryWriteCache= Disabled
    MNPDelay= 60
    IRPEnable= Disabled
    DPOEnable= Disabled
    ElevatorSortEnable= Enabled
    QueueDepth= Automatic
    PredictiveSpareActivation= Disable

    ; Array Specifications
    Array= A
    Drive= 2
    OnlineSpare= 1

    ; Logical Drive Specifications
    LogicalDrive= 1
    RAID= 1
    Size= MAX
    Sectors= 32
    StripSize= 256
    Caching= Enabled

    @” | out-file C:templocationmountScriptDeploy.ini -Encoding ascii
    ****************************************

    Can someone give me a hint what I am doing wrong?

    Thanks for every help!

    Translated with http://www.DeepL.com/Translator

    • Luke Orellana says:

      The best way to figure out the config for a specific RAID set up, is to set up the RAID configuration manually on the server. THEN, boot to your WinPE cd that has the HP Scripting tools loaded on it, browse to the directory that has the SSASCRIPTING tool in it and run the following command to export your current RAID settings to a file. You’ll want to map a network drive and save the exported file there (make a share somewhere that everyone has permissions too):

      ssascripting -c s:datafilename

Leave a comment

Your email address will not be published. Required fields are marked *