<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Complete ESXi 5.1 Host Installation Script in Application Integration</title>
    <link>https://community.hpe.com/t5/application-integration/complete-esxi-5-1-host-installation-script/m-p/6983515#M421</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I thought I'd put up the ESXi deployment script that I've brought together from various sources for the scripting blitz.&amp;nbsp; There's a couple Nimble-centric settings in it.&amp;nbsp; In addition to all the 'normal' setup options, it will change the default path selection policy, rename the iSCSI initiator to match the host name, scans the Nimble for existing luns, and sets the round robin PSP to change every 0 iops.&amp;nbsp; I've got one for each of our hosts and it makes re-deploying a snap.&amp;nbsp; Every time I need to restore our dev server to a 'new' state I'm happy to have it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13910339730843702" jivemacro_uid="_13910339730843702" modifiedtitle="true"&gt;&lt;BR /&gt;&lt;P&gt;#########################################&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;#&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ESXi 5.1 Config Script #&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;#########################################&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# command&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;SPAN&gt;# ks=&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="ftp://10.10.1.17/esxi_config_script.cfg"&gt;ftp://10.10.1.17/esxi_config_script.cfg&lt;/A&gt;&lt;SPAN&gt; nameserver=10.10.1.14 ip=10.10.1.199 netmask=255.255.0.0 gateway=10.10.1.244&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# Accept EULA, install, set root password, reboot&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;vmaccepteula&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# install to first disk, set root password, and reboot&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;install --firstdisk --overwritevmfs&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;rootpw pa$$word&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;reboot&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;%include /tmp/networkconfig&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;%pre --interpreter=busybox&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;#########################################&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# Change the following: #&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;IPADDR="10.10.3.92"&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;HOSTNAME="ESXi1"&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;NETMASK="255.255.0.0"&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;DNS="10.10.1.14,10.10.1.9"&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;GATEWAY="10.10.1.244"&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;#########################################&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# Configure management network&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;echo "network --bootproto=static --addvmportgroup=false --device=vmnic0 --ip=${IPADDR} --netmask=${NETMASK} --gateway=${GATEWAY} --nameserver=${DNS} --hostname=${HOSTNAME}" &amp;gt; /tmp/networkconfig&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;%firstboot --interpreter=busybox&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;#########################################&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# Change the following:&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;#&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;ISCSI1_ADDRESS="1.1.1.111"&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;ISCSI2_ADDRESS="1.1.1.112"&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;HOSTNAME="ESXi1"&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;NIMBLEIP="1.1.1.10"&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;#########################################&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;###########################&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;#&amp;nbsp; vSwitch configuration&amp;nbsp; #&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;###########################&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;#########################################&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;#&amp;nbsp; Data Network &lt;/P&gt;&lt;BR /&gt;&lt;P&gt;#&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;#&amp;nbsp; vSwitch0 : Active -&amp;gt; vmnic0,vmnic4&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# failback: yes&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# failback detection: link&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# load balancing: portid&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# notify switches: yes&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# allow forged transmits: yes&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# allow mac changes: yes&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# allow promiscuous mode: no&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# cdp status: both&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# Add NIC&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network vswitch standard uplink add --uplink-name vmnic4 --vswitch-name vSwitch0&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# Add Port Groups&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network vswitch standard portgroup add --portgroup-name "Voice VLAN" --vswitch-name vSwitch0&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network vswitch standard portgroup set --portgroup-name "Voice VLAN" --vlan-id 3&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network vswitch standard portgroup add --portgroup-name "VM Network" --vswitch-name vSwitch0&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# Config vSwitch&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network vswitch standard set --cdp-status both --vswitch-name vSwitch0&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network vswitch standard policy failover set --active-uplinks vmnic0,vmnic4 --vswitch-name vSwitch0&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network vswitch standard policy failover set --failback yes --failure-detection link --load-balancing portid --notify-switches yes --vswitch-name vSwitch0&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network vswitch standard policy security set --allow-forged-transmits yes --allow-mac-change yes --allow-promiscuous no --vswitch-name vSwitch0&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# Enable vMotion on vmk0&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;vim-cmd hostsvc/vmotion/vnic_set vmk0&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# make vmnics active on Management Network&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network vswitch standard portgroup policy failover set --active-uplinks=vmnic0 --portgroup-name="Management Network"&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;#########################################&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;#&amp;nbsp; iSCSI Network&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;#&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# vSwitch1 : Active -&amp;gt; vmnic1,vmnic5&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# failback: yes&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# failback detection: link&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# load balancing: portid&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# notify switches: yes&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# allow forged transmits: yes&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# allow mac changes: yes&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# allow promiscuous mode: no&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# cdp status: both&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# mtu: 9000&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# create vSwitch and add NICs&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network vswitch standard add --ports 128 --vswitch-name vSwitch1&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network vswitch standard uplink add --uplink-name vmnic1 --vswitch-name vSwitch1&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network vswitch standard uplink add --uplink-name vmnic5 --vswitch-name vSwitch1&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# setup port groups&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network vswitch standard portgroup add --portgroup-name "iSCSI Network" --vswitch-name vSwitch1&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network vswitch standard portgroup add --portgroup-name "iSCSI1" --vswitch-name vSwitch1&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network vswitch standard portgroup add --portgroup-name "iSCSI2" --vswitch-name vSwitch1&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# Config vSwitch&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network vswitch standard set --mtu 9000 --cdp-status both --vswitch-name vSwitch1&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network vswitch standard policy failover set --active-uplinks vmnic1,vmnic5 --vswitch-name vSwitch1&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network vswitch standard policy failover set --failback yes --failure-detection link --load-balancing portid --notify-switches yes --vswitch-name vSwitch1&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network vswitch standard policy security set --allow-forged-transmits yes --allow-mac-change yes --allow-promiscuous no --vswitch-name vSwitch1&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# add network interfaces and assign IPs&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network ip interface add --interface-name vmk1 --mtu 9000 --portgroup-name iSCSI1&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network ip interface add --interface-name vmk2 --mtu 9000 --portgroup-name iSCSI2&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network ip interface ipv4 set --interface-name vmk1 --ipv4 ${ISCSI1_ADDRESS} --netmask 255.255.255.0 --type static&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network ip interface ipv4 set --interface-name vmk2 --ipv4 ${ISCSI2_ADDRESS} --netmask 255.255.255.0 --type static&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# Set Active&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network vswitch standard portgroup policy failover set --active-uplinks=vmnic1 --portgroup-name=iSCSI1&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network vswitch standard portgroup policy failover set --active-uplinks=vmnic5 --portgroup-name=iSCSI2&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# Override Failover&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network vswitch standard portgroup policy failover set -p iSCSI1 -a vmnic1&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network vswitch standard portgroup policy failover set -p iSCSI2 -a vmnic5&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# Bond NICs to ISCSI Adapters&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli iscsi networkportal add -A ${ADAPTER} -n vmk1&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli iscsi networkportal add -A ${ADAPTER} -n vmk2&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;##########################&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;#&amp;nbsp; ISCSI Configuration&amp;nbsp;&amp;nbsp; #&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;##########################&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# Set PSP to default to Round Robin for Nimble&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli storage nmp satp set --satp VMW_SATP_ALUA --default-psp VMW_PSP_RR&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# Enable iSCSI software adapter&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli iscsi software set --enabled=true&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# Get iSCSI software initator Name and Rename iSCSI Initiator to match hostname&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;ADAPTER=`esxcli iscsi adapter list | grep Software | awk '{print $1;}'`&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli iscsi adapter set -A ${ADAPTER} --name iqn.1998-01.com.vmware:${HOSTNAME}&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# Add Nimble target IP&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli iscsi adapter discovery sendtarget add -A ${ADAPTER} -a ${NIMBLEIP}&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# Scan software ISCSI bus for datastores&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli storage core adapter rescan --adapter ${ADAPTER}&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# change round robin path selection policy to switch every 0 iops&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;i=`esxcli storage nmp device list | awk '/Nimble iSCSI Disk/{print $7}' | sed -e 's/(//' -e 's/)//'`&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;for p in $i; do esxcli storage nmp psp roundrobin deviceconfig set -d $p --iops 0 --type=iops;done&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# NTP Config&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;cat &amp;gt; /etc/ntp.conf &amp;lt;&amp;lt; __NTP_CONFIG__&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;restrict default kod nomodify notrap noquerynopeer&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;restrict 127.0.0.1&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;server 0.us.pool.ntp.org&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;server 1.us.pool.ntp.org&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;__NTP_CONFIG__&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;/sbin/chkconfig ntpd on&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# backup ESXi configuration to persist changes &lt;/P&gt;&lt;BR /&gt;&lt;P&gt;/sbin/auto-backup.sh&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# enter maintenance mode&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli system maintenanceMode set -e true&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# copy logs to datastore&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;cp /var/log/hostd.log "/vmfs/volumes/DS2/DeploymentLogs/${HOSTNAME}/firstboot-hostd.log"&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;cp /var/log/esxi_install.log "/vmfs/volumes/DS2/DeploymentLogs/${HOSTNAME}/firstboot-esxi_install.log"&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;SPAN style="font-size: 9pt; line-height: 12pt;"&gt;# Reboot host to finish all setup&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli system shutdown reboot -d 60 -r "rebooting after host configurations"&lt;/P&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Deploying is pretty easy, put in the install media, hit Shift-O when prompted, put in the location of your script (we deploy from an FTP server, but VMware says you can also use HTTP, NFS, USB, or CDROM), and wait.&amp;nbsp; After a few reboots you'll have a fully configured host waiting for you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Once I have a host deployed, I use Derek Seaman's great script to deploy a SSL cert from here:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.derekseaman.com/2013/02/vmware-vcenter-51-installation-part-15.html"&gt;http://www.derekseaman.com/2013/02/vmware-vcenter-51-installation-part-15.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Add it to vCenter and away we go.&amp;nbsp; I haven't looked at ESXi 5.5 yet, but likely there would only have to be a few changes to make work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hopefully this helps someone out there, I know we like it!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 29 Jan 2014 22:31:28 GMT</pubDate>
    <dc:creator>jefhauschild10</dc:creator>
    <dc:date>2014-01-29T22:31:28Z</dc:date>
    <item>
      <title>Complete ESXi 5.1 Host Installation Script</title>
      <link>https://community.hpe.com/t5/application-integration/complete-esxi-5-1-host-installation-script/m-p/6983515#M421</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I thought I'd put up the ESXi deployment script that I've brought together from various sources for the scripting blitz.&amp;nbsp; There's a couple Nimble-centric settings in it.&amp;nbsp; In addition to all the 'normal' setup options, it will change the default path selection policy, rename the iSCSI initiator to match the host name, scans the Nimble for existing luns, and sets the round robin PSP to change every 0 iops.&amp;nbsp; I've got one for each of our hosts and it makes re-deploying a snap.&amp;nbsp; Every time I need to restore our dev server to a 'new' state I'm happy to have it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13910339730843702" jivemacro_uid="_13910339730843702" modifiedtitle="true"&gt;&lt;BR /&gt;&lt;P&gt;#########################################&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;#&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ESXi 5.1 Config Script #&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;#########################################&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# command&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;SPAN&gt;# ks=&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="ftp://10.10.1.17/esxi_config_script.cfg"&gt;ftp://10.10.1.17/esxi_config_script.cfg&lt;/A&gt;&lt;SPAN&gt; nameserver=10.10.1.14 ip=10.10.1.199 netmask=255.255.0.0 gateway=10.10.1.244&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# Accept EULA, install, set root password, reboot&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;vmaccepteula&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# install to first disk, set root password, and reboot&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;install --firstdisk --overwritevmfs&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;rootpw pa$$word&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;reboot&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;%include /tmp/networkconfig&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;%pre --interpreter=busybox&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;#########################################&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# Change the following: #&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;IPADDR="10.10.3.92"&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;HOSTNAME="ESXi1"&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;NETMASK="255.255.0.0"&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;DNS="10.10.1.14,10.10.1.9"&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;GATEWAY="10.10.1.244"&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;#########################################&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# Configure management network&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;echo "network --bootproto=static --addvmportgroup=false --device=vmnic0 --ip=${IPADDR} --netmask=${NETMASK} --gateway=${GATEWAY} --nameserver=${DNS} --hostname=${HOSTNAME}" &amp;gt; /tmp/networkconfig&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;%firstboot --interpreter=busybox&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;#########################################&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# Change the following:&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;#&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;ISCSI1_ADDRESS="1.1.1.111"&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;ISCSI2_ADDRESS="1.1.1.112"&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;HOSTNAME="ESXi1"&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;NIMBLEIP="1.1.1.10"&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;#########################################&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;###########################&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;#&amp;nbsp; vSwitch configuration&amp;nbsp; #&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;###########################&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;#########################################&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;#&amp;nbsp; Data Network &lt;/P&gt;&lt;BR /&gt;&lt;P&gt;#&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;#&amp;nbsp; vSwitch0 : Active -&amp;gt; vmnic0,vmnic4&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# failback: yes&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# failback detection: link&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# load balancing: portid&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# notify switches: yes&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# allow forged transmits: yes&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# allow mac changes: yes&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# allow promiscuous mode: no&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# cdp status: both&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# Add NIC&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network vswitch standard uplink add --uplink-name vmnic4 --vswitch-name vSwitch0&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# Add Port Groups&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network vswitch standard portgroup add --portgroup-name "Voice VLAN" --vswitch-name vSwitch0&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network vswitch standard portgroup set --portgroup-name "Voice VLAN" --vlan-id 3&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network vswitch standard portgroup add --portgroup-name "VM Network" --vswitch-name vSwitch0&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# Config vSwitch&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network vswitch standard set --cdp-status both --vswitch-name vSwitch0&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network vswitch standard policy failover set --active-uplinks vmnic0,vmnic4 --vswitch-name vSwitch0&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network vswitch standard policy failover set --failback yes --failure-detection link --load-balancing portid --notify-switches yes --vswitch-name vSwitch0&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network vswitch standard policy security set --allow-forged-transmits yes --allow-mac-change yes --allow-promiscuous no --vswitch-name vSwitch0&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# Enable vMotion on vmk0&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;vim-cmd hostsvc/vmotion/vnic_set vmk0&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# make vmnics active on Management Network&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network vswitch standard portgroup policy failover set --active-uplinks=vmnic0 --portgroup-name="Management Network"&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;#########################################&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;#&amp;nbsp; iSCSI Network&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;#&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# vSwitch1 : Active -&amp;gt; vmnic1,vmnic5&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# failback: yes&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# failback detection: link&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# load balancing: portid&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# notify switches: yes&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# allow forged transmits: yes&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# allow mac changes: yes&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# allow promiscuous mode: no&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# cdp status: both&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# mtu: 9000&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# create vSwitch and add NICs&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network vswitch standard add --ports 128 --vswitch-name vSwitch1&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network vswitch standard uplink add --uplink-name vmnic1 --vswitch-name vSwitch1&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network vswitch standard uplink add --uplink-name vmnic5 --vswitch-name vSwitch1&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# setup port groups&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network vswitch standard portgroup add --portgroup-name "iSCSI Network" --vswitch-name vSwitch1&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network vswitch standard portgroup add --portgroup-name "iSCSI1" --vswitch-name vSwitch1&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network vswitch standard portgroup add --portgroup-name "iSCSI2" --vswitch-name vSwitch1&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# Config vSwitch&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network vswitch standard set --mtu 9000 --cdp-status both --vswitch-name vSwitch1&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network vswitch standard policy failover set --active-uplinks vmnic1,vmnic5 --vswitch-name vSwitch1&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network vswitch standard policy failover set --failback yes --failure-detection link --load-balancing portid --notify-switches yes --vswitch-name vSwitch1&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network vswitch standard policy security set --allow-forged-transmits yes --allow-mac-change yes --allow-promiscuous no --vswitch-name vSwitch1&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# add network interfaces and assign IPs&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network ip interface add --interface-name vmk1 --mtu 9000 --portgroup-name iSCSI1&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network ip interface add --interface-name vmk2 --mtu 9000 --portgroup-name iSCSI2&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network ip interface ipv4 set --interface-name vmk1 --ipv4 ${ISCSI1_ADDRESS} --netmask 255.255.255.0 --type static&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network ip interface ipv4 set --interface-name vmk2 --ipv4 ${ISCSI2_ADDRESS} --netmask 255.255.255.0 --type static&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# Set Active&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network vswitch standard portgroup policy failover set --active-uplinks=vmnic1 --portgroup-name=iSCSI1&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network vswitch standard portgroup policy failover set --active-uplinks=vmnic5 --portgroup-name=iSCSI2&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# Override Failover&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network vswitch standard portgroup policy failover set -p iSCSI1 -a vmnic1&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli network vswitch standard portgroup policy failover set -p iSCSI2 -a vmnic5&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# Bond NICs to ISCSI Adapters&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli iscsi networkportal add -A ${ADAPTER} -n vmk1&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli iscsi networkportal add -A ${ADAPTER} -n vmk2&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;##########################&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;#&amp;nbsp; ISCSI Configuration&amp;nbsp;&amp;nbsp; #&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;##########################&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# Set PSP to default to Round Robin for Nimble&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli storage nmp satp set --satp VMW_SATP_ALUA --default-psp VMW_PSP_RR&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# Enable iSCSI software adapter&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli iscsi software set --enabled=true&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# Get iSCSI software initator Name and Rename iSCSI Initiator to match hostname&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;ADAPTER=`esxcli iscsi adapter list | grep Software | awk '{print $1;}'`&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli iscsi adapter set -A ${ADAPTER} --name iqn.1998-01.com.vmware:${HOSTNAME}&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# Add Nimble target IP&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli iscsi adapter discovery sendtarget add -A ${ADAPTER} -a ${NIMBLEIP}&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# Scan software ISCSI bus for datastores&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli storage core adapter rescan --adapter ${ADAPTER}&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# change round robin path selection policy to switch every 0 iops&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;i=`esxcli storage nmp device list | awk '/Nimble iSCSI Disk/{print $7}' | sed -e 's/(//' -e 's/)//'`&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;for p in $i; do esxcli storage nmp psp roundrobin deviceconfig set -d $p --iops 0 --type=iops;done&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# NTP Config&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;cat &amp;gt; /etc/ntp.conf &amp;lt;&amp;lt; __NTP_CONFIG__&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;restrict default kod nomodify notrap noquerynopeer&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;restrict 127.0.0.1&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;server 0.us.pool.ntp.org&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;server 1.us.pool.ntp.org&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;__NTP_CONFIG__&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;/sbin/chkconfig ntpd on&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# backup ESXi configuration to persist changes &lt;/P&gt;&lt;BR /&gt;&lt;P&gt;/sbin/auto-backup.sh&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# enter maintenance mode&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli system maintenanceMode set -e true&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;# copy logs to datastore&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;cp /var/log/hostd.log "/vmfs/volumes/DS2/DeploymentLogs/${HOSTNAME}/firstboot-hostd.log"&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;cp /var/log/esxi_install.log "/vmfs/volumes/DS2/DeploymentLogs/${HOSTNAME}/firstboot-esxi_install.log"&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;SPAN style="font-size: 9pt; line-height: 12pt;"&gt;# Reboot host to finish all setup&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;esxcli system shutdown reboot -d 60 -r "rebooting after host configurations"&lt;/P&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Deploying is pretty easy, put in the install media, hit Shift-O when prompted, put in the location of your script (we deploy from an FTP server, but VMware says you can also use HTTP, NFS, USB, or CDROM), and wait.&amp;nbsp; After a few reboots you'll have a fully configured host waiting for you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Once I have a host deployed, I use Derek Seaman's great script to deploy a SSL cert from here:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.derekseaman.com/2013/02/vmware-vcenter-51-installation-part-15.html"&gt;http://www.derekseaman.com/2013/02/vmware-vcenter-51-installation-part-15.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Add it to vCenter and away we go.&amp;nbsp; I haven't looked at ESXi 5.5 yet, but likely there would only have to be a few changes to make work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hopefully this helps someone out there, I know we like it!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Jan 2014 22:31:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/application-integration/complete-esxi-5-1-host-installation-script/m-p/6983515#M421</guid>
      <dc:creator>jefhauschild10</dc:creator>
      <dc:date>2014-01-29T22:31:28Z</dc:date>
    </item>
    <item>
      <title>Re: Complete ESXi 5.1 Host Installation Script</title>
      <link>https://community.hpe.com/t5/application-integration/complete-esxi-5-1-host-installation-script/m-p/6983516#M422</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Great stuff.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Feb 2014 19:29:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/application-integration/complete-esxi-5-1-host-installation-script/m-p/6983516#M422</guid>
      <dc:creator>warkaj1</dc:creator>
      <dc:date>2014-02-06T19:29:32Z</dc:date>
    </item>
  </channel>
</rss>

