Script to automate ESXI deployment

 ################################################

## vSphere ESXi 7.0 Scripted Install - Part 1 ##

################################################

# Accept the VMware End User License Agreement

vmaccepteula


# Set the root password for DCUI

rootpw Passw0rd!!


# Install on the first local disk available on machine

install --firstdisk --overwritevmfs


# Set the network to Static on the first network adapter

network --hostname=esxi7-Auto --device=vmnic0 --bootproto=static --ip=192.168.1.215 --netmask=255.255.255.0 --gateway=192.168.1.1 --nameserver=192.168.1.16


# Reboot

reboot


################################################

## vSphere ESXi 7.0 Scripted Install - Part 2 ##

################################################


# Use busybox interpreter

%firstboot --interpreter=busybox


# Set DNS Suffix

esxcli network ip dns search add --domain=ads.com


# Disable IPv6

esxcli network ip set --ipv6-enabled=false


# Enable SSH

vim-cmd hostsvc/enable_ssh

vim-cmd hostsvc/start_ssh


# Enable NTP

echo "server 0.au.pool.ntp.org" >> /etc/ntp.conf;

echo "server 1.au.pool.ntp.org" >> /etc/ntp.conf;

/sbin/chkconfig ntpd on;


# Create vSwitches

esxcli network vswitch standard add -v vSwitch1

esxcli network vswitch standard add -v vSwitch2


# Set vSwitch MTU's

esxcli network vswitch standard set -v vSwitch1 -m 9000

esxcli network vswitch standard set -v vSwitch2 -m 9000


# Add Additional NIC to vSwitches

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

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

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

esxcli network vswitch standard uplink add --uplink-name=vmnic4 --vswitch-name=vSwitch2

esxcli network vswitch standard uplink add --uplink-name=vmnic5 --vswitch-name=vSwitch2


# Create VMKernel Ports

esxcli network vswitch standard portgroup add --portgroup-name=vMotion --vswitch-name=vSwitch1

esxcli network vswitch standard portgroup add --portgroup-name=NFS --vswitch-name=vSwitch2

esxcli network ip netstack add --netstack=vmotion

esxcli network ip interface add --interface-name=vmk1 --portgroup-name=vMotion --netstack=vmotion --mtu=9000

esxcli network ip interface add --interface-name=vmk2 --portgroup-name=NFS --mtu=9000

esxcli network ip interface ipv4 set --interface-name=vmk1 --ipv4=192.168.10.215 --netmask=255.255.255.0 --type=static

esxcli network ip interface ipv4 set --interface-name=vmk2 --ipv4=192.168.5.215 --netmask=255.255.255.0 --type=static


# Put host in maintenance mode

esxcli system maintenanceMode set -e true


# Reboot to apply settings (disabling IPv6)

esxcli system shutdown reboot -d 15 -r "rebooting after disabling IPv6"

No comments:

Post a Comment

Featured Post

HPE MSA 2040 configuration step by step

HPE MSA 2040 configuration Default IP range for HP SAN storage MSA 2040 is 10.0.0.1/2 You need to connect your laptop and storage with...