ESXi5.1 KS.Conf for HP DL380p Gen8
Because I noticed some searches on ESXi5.1, Gen8 and KS.conf I have an example of what I use. I will try to do a bit more explanation later
I didn’t comment all the actions, but some are pretty clear.
# +-----------------------------------+ # | Begin default ESXi 5.1 install | # +-----------------------------------+ # VMWare License options accepting EULA vmaccepteula # Partitioning install --firstdisk=usb-storage,hpsa,local --overwritevmfs --novmfsondisk # root Password rootpw --iscrypted <password> # Network install type network --device=vmnic0 --bootproto=static --ip=[HOSTIP] --netmask=<subnet> --gateway=<gateway> --nameserver=<nameserver> --hostname=[HOSTNAME] --addvmportgroup=0 %post --interpreter=busybox Echo Installing ESXi5.1 #Reboot after copying image to disk reboot %firstboot --interpreter=busybox # +---------------------------------------------------------------------------+ # | Creating management network | # +---------------------------------------------------------------------------+ # Remove vSwitch0 sleep 30 esxcli network ip interface remove -i vmk0 esxcli network vswitch standard portgroup remove -p 'Management Network' -v vSwitch0 esxcli network vswitch standard remove -v vSwitch0 # Create management switch esxcli network vswitch standard add -v vsw-management # Add nics to management switch esxcli network vswitch standard uplink add -u vmnic0 -v vsw-management esxcli network vswitch standard uplink add -u vmnic7 -v vsw-management # Add portgroups to management switch esxcli network vswitch standard portgroup add -p 'Management Network' -v vsw-management # Configure vmkNIC esxcli network ip interface add -i vmk0 -p 'Management Network' # Set IP Settings [HOSTIP] is dynamic resolved from the template esxcli network ip interface ipv4 set --interface-name=vmk0 --ipv4=[HOSTIP] -N <subnet> -t static # Set default gateway esxcfg-route -a default <gateway> # Put management nics to active esxcli network vswitch standard policy failover set --active-uplinks vmnic0,vmnic7 --vswitch-name vsw-management # Setting the Network NIC Speed esxcli network nic set -n vmnic0 -S 1000 -D full esxcli network nic set -n vmnic1 -S 1000 -D full esxcli network nic set -n vmnic2 -S 1000 -D full esxcli network nic set -n vmnic3 -S 1000 -D full esxcli network nic set -n vmnic4 -S 1000 -D full esxcli network nic set -n vmnic5 -S 1000 -D full esxcli network nic set -n vmnic6 -S 1000 -D full esxcli network nic set -n vmnic7 -S 1000 -D full esxcli network nic set -n vmnic8 -S 1000 -D full esxcli network nic set -n vmnic9 -S 1000 -D full echo Create VMotion netwerk # +---------------------------------------------------------------------+ # | Creating vMotion Netwerk | # +---------------------------------------------------------------------+ # Create vMotion vSwitch esxcli network vswitch standard add -v vsw-vmotion # Add nics to vsw-vmotion esxcli network vswitch standard uplink add -u vmnic2 -v vsw-vmotion esxcli network vswitch standard uplink add -u vmnic5 -v vsw-vmotion # Add portgroups to vsw-vmotion esxcli network vswitch standard portgroup add -p 'vmotion' -v vsw-vmotion # Configure vmkNIC esxcli network ip interface add -i vmk1 -p 'vmotion' esxcli network ip interface ipv4 set --interface-name=vmk1 --ipv4=[VMOTIONIP] --netmask=<subnet> --type=static # Put management nics to active esxcli network vswitch standard policy failover set --active-uplinks vmnic2,vmnic5 --vswitch-name vsw-vmotion echo Create Virtual Machine netwerk # +-------------------------------------------------------------------+ # | Create alle Virtual Machine VLANs | # +-------------------------------------------------------------------+ # Create 256 port switch instead of default 64 esxcfg-vswitch -a vsw-vms01:256 # Add nics to vsw-vms01 esxcfg-vswitch -L vmnic1 vsw-vms01 esxcfg-vswitch -L vmnic3 vsw-vms01 esxcfg-vswitch -L vmnic4 vsw-vms01 esxcfg-vswitch -L vmnic6 vsw-vms01 # Add portgroups. # Download vsw-vms01-<esxcl>.sh script for the portgroup settings wget http://<httpserver>/esx51rep/scripts/vsw-vms01-[CLUSTER].sh -O /tmp/vsw-vms01-[CLUSTER].sh chmod a+x /tmp/vsw-vms01-[CLUSTER].sh /tmp/vsw-vms01-[CLUSTER].sh > /tmp/vsw-vms01-[CLUSTER].log 2>&1 # Set DNS and hostname esxcli system hostname set --fqdn=[HOSTNAME] esxcli network ip dns server add --server=<nameserver> esxcli network ip dns server add --server=145.70.12.203 #echo add DNS configuration echo search domain.corp.net > /etc/resolv.conf echo nameserver <nameserver> >> /etc/resolv.conf echo nameserver <nameserver> >> /etc/resolv.conf echo Configure NTP # +--------------------------------------------------------------------+ # | Add NTP Settings | # +--------------------------------------------------------------------+ # Backup mv /etc/ntp.conf /etc/ntp.conf.bak # ntp.conf creation cat > /etc/ntp.conf << __NTP_CONFIG__ restrict default kod nomodify notrap noquerynopeer restrict 127.0.0.1 server <NTP Server> __NTP_CONFIG__ /sbin/chkconfig --level 345 ntpd on echo "driftfile /etc/ntp.drift" >> /etc/ntp.conf echo Configure Syslog # +--------------------------------------------------------------------+ # | Add syslog confiuration to ESX host | # +--------------------------------------------------------------------+ vim-cmd hostsvc/advopt/update Syslog.Remote.Hostname string <Syslog Server> #Disable MOB vim-cmd proxysvc/remove_service "/mob" "httpsWithRedirect" # +--------------------------------------------------------------------+ # | SNMP Trap | # +--------------------------------------------------------------------+ #echo "<config><snmpSettings><enable>true</enable><communities>patrol</communities><port>161</port><targets>snmp1.fqdn@162 patrol;snmp2.fqdn@162 patrol</targets></snmpSettings></config>" > /etc/vmware/snmp.xml echo Rename local datastore # +---------------------------------------------------------------------------+ # | Rename local datastore if --novmfsondisk is not used | # +---------------------------------------------------------------------------+ vim-cmd hostsvc/datastore/rename datastore1 "[SUBTEMPLATE]-local" # +---------------------------------------------------------------------------+ # |Create SSH Banner | # +---------------------------------------------------------------------------+ /bin/cat > /etc/banner.new <<SSHEOF ${INDENTATION:-}<Company> ${INDENTATION:-}ESXi 5.1 ${INDENTATION:-}========================================= ${INDENTATION:-}WARNING: UNAUTHORIZED USE IS PROHIBITED ${INDENTATION:-}----------------------------------------- ${INDENTATION:-}Property of <Company> Groep, and should only ${INDENTATION:-}be accessed by authorized <Company> employees. ${INDENTATION:-}Do not attempt to login unless you are an ${INDENTATION:-}authorized user. ${INDENTATION:-}Any authorized or unauthorized access and use, ${INDENTATION:-}will be monitored and anyone using this system ${INDENTATION:-}expressly consents to such monitoring. If such ${INDENTATION:-}monitoring reveals possible envidence of criminal ${INDENTATION:-}activity, such evidence will be provided to law ${INDENTATION:-}enforcement personnel and can result in criminal ${INDENTATION:-}or civil prosecution under applicable law of ${INDENTATION:-}<country>. ${INDENTATION:-}This system is restricted to authorized users. ${INDENTATION:-}Individuals attempting unauthorized access ${INDENTATION:-}will be prosecuted. If unauthorized, ${INDENTATION:-}terminate access now! ${INDENTATION:-}By logging in you indicate your acceptance of ${INDENTATION:-}the information above. ${INDENTATION:-}----------------------------------------- SSHEOF # copy new banner file to overwrite /etc/issue (esxi 5 store it's banner file here) cp /etc/banner.new /etc/issue # +---------------------------------------------------------------------------+ # | enable VMotion | # +---------------------------------------------------------------------------+ vim-cmd hostsvc/vmotion/vnic_set vmk1 vim-cmd internalsvc/refresh_network # Set Multipatch Policies for i in `esxcli storage nmp device list | grep -E naa.\{33\}$` ; do esxcli storage nmp device set --device $i --psp "VMW_PSP_RR"; esxcli storage nmp psp roundrobin deviceconfig set --device $i --type "iops" --iops=1; done esxcli storage nmp satp set --default-psp "VMW_PSP_RR" --satp "VMW_SATP_SVC" # backup ESXi configuration to persist changes /sbin/auto-backup.sh #enter maintenance mode esxcli system maintenanceMode set -e true #Removing iSCSI driver and CD-ROM driver esxcli software vib remove -n scsi-bnx2i esxcli software vib remove -n ata-pata-amd #Removing iSCSI initiator esxcli iscsi software set -e false # Needed for configuration changes that could not be performed in esxcli esxcli system shutdown reboot -d 60 -r "Rebooting after host configurations"