A while back I wrote a scripted install aka “cfg” file, and I just noticed I never published it. Check it out, it might be useful in one way or another. It also available for download here!

Especially changing the amount of active nics in a team can be useful(I’ve commented this out again, as of ESX 3.5 U3 this isn’t necessary anymore. Enabling vmotion via the vimsh command is still valid. This changed since ESX 3.5. Setting IP-Hash was also a nice one to figure out


# Regional Settings
keyboard us
lang en_US
langsupport --default en_US
timezone Europe/Amsterdam

# Installatition settings
skipx
mouse none
firewall --disabled
# Unencrypted root password:
rootpw --iscrypted
reboot
install

# Driver disks

# Load drivers

# Bootloader options
bootloader --location=mbr --driveorder=sda

# Authentication
auth --enableshadow --enablemd5

# Partitioning
clearpart --all --drives=sda --initlabel
part /boot --fstype ext3 --size=250 --ondisk sda --asprimary
part / --fstype ext3 --size=6144 --ondisk sda --asprimary
part /var/log --fstype ext3 --size=2048 --ondisk sda
part swap --size=1600 --ondisk sda --asprimary
part /tmp --fstype ext3 --size=1024 --ondisk sda
part None --fstype vmkcore --size=110 --ondisk sda
part None --fstype vmfs3 --size=1 --grow --ondisk sda

# Network Configurations # VARIABEL
network --device eth0 --bootproto static --ip 10.40.254.201 --netmask 255.255.254.0 --nameserver 10.40.1.251 --hostname esx01.yellow-bricks.local --addvmportgroup=0

# VMWare License options
vmaccepteula
vmlicense --mode=server --server=27000@vc01.yellow-bricks.local --edition=esxfull --features=backup,vsmp

%vmlicense_text

%packages
@base

%post

cat > /tmp/esxcfg.sh <

#!/bin/sh

# enable SSH root-access
mv /etc/ssh/sshd_config /etc/ssh/sshd_config.old
/bin/sed -e "s/PermitRootLogin no/PermitRootLogin yes/g" /etc/ssh/sshd_config.old > /etc/ssh/sshd_config
/etc/init.d/sshd restart

# Upsize console memory
mv -f /etc/vmware/esx.conf /etc/vmware/esx.conf.old
/bin/sed -e 's/boot\/memSize = \"272\"/boot\/memSize = \"800\"/g' /etc/vmware/esx.conf.old >> /etc/vmware/esx.conf
mv -f /boot/grub/grub.conf /tmp/grub.conf.bak
/bin/sed -e 's/uppermem 277504/uppermem 818176/g' -e 's/mem=272M/mem=800M/g' /tmp/grub.conf.bak >> /boot/grub/grub.conf

# DNS and Gateway
mv /etc/resolv.conf /etc/resolv.conf.old
echo "search yellow-bricks.local" >> /etc/resolv.conf
echo "nameserver 10.40.1.251" >> /etc/resolv.conf
echo "nameserver 10.40.1.252" >> /etc/resolv.conf
echo "GATEWAY=10.40.254.1" >> /etc/sysconfig/network

# set uselunreset enabled and devicereset disabled
/usr/sbin/esxcfg-advcfg -s 0 /Disk/UseDeviceReset
/usr/sbin/esxcfg-advcfg -s 1 /Disk/UseLunReset

# set queuedepth for qlogic adapter
/usr/sbin/esxcfg-module -s ql2xmaxqdepth=64 qla2300_707_vmw
/usr/sbin/esxcfg-boot -b

# add extrra nic to vSwitch0
/usr/sbin/esxcfg-vswitch -L vmnic3 vSwitch0

# Create a vswitch with 2 nics, a vlan and ip-hash
/usr/sbin/esxcfg-vswitch -a vSwitch1
/usr/sbin/esxcfg-vswitch -A "Server vlan 10" vSwitch1
/usr/sbin/esxcfg-vswitch -L vmnic1 vSwitch1
/usr/sbin/esxcfg-vswitch -L vmnic4 vSwitch1

# Create a vswitch with 2 nics, a vlan
/usr/sbin/esxcfg-vswitch -a vSwitch2
/usr/sbin/esxcfg-vswitch -A VMotion vSwitch2
/usr/sbin/esxcfg-vswitch -L vmnic2 vSwitch2
/usr/sbin/esxcfg-vswitch -L vmnic5 vSwitch2
/usr/sbin/esxcfg-vmknic -a VMotion -i 10.40.199.201 -n 255.255.255.0
sleep 3

# refresh nic settings with vimsh
/usr/bin/vimsh -n -e "hostsvc/net/refresh"
/usr/bin/vimsh -n -e "internalsvc/refresh_network"

# Obsolete as of ESX 3.5 U3
# Active and standby setup and maxActive from 1 to 2
# mv /etc/vmware/esx.conf /tmp/esx.conf.bak
# /bin/sed -e 's/net\/vswitch\/child\[0001\]\/teamPolicy\/maxActive = \"1\"/net\/vswitch\/child\[0001\]\/teamPolicy\/maxActive = \"2\"/g' /tmp/esx.conf.bak >> /etc/vmware/esx.conf

/usr/bin/vimsh -n -e "hostsvc/net/portgroup_set --nicorderpolicy-active=vmnic2 --nicorderpolicy-standby=vmnic5 vSwitch2 VMotion"
/usr/bin/vimsh -n -e "hostsvc/net/portgroup_set --nicorderpolicy-active=vmnic0 --nicorderpolicy-standby=vmnic3 vSwitch0 'Service Console'"

/usr/bin/vimsh -n -e "hostsvc/net/refresh"
/usr/bin/vimsh -n -e "internalsvc/refresh_network"

# Activiate IP Hash and 2 actieve nics on vSwitch1
/usr/sbin/esxcfg-vswitch -U vmnic1 vSwitch1
sleep 3
/usr/sbin/esxcfg-vswitch -U vmnic4 vSwitch1
sleep 3
/usr/sbin/esxcfg-vswitch -L vmnic1 vSwitch1
sleep 3
/usr/sbin/esxcfg-vswitch -L vmnic4 vSwitch1
sleep 5
/usr/bin/vimsh -n -e "hostsvc/net/refresh"
/usr/bin/vimsh -n -e "internalsvc/refresh_network"

/usr/bin/vimsh -n -e "hostsvc/net/vswitch_setpolicy --nicteaming-policy=loadbalance_ip vSwitch1"

# VLAN ID portgroups
/usr/sbin/esxcfg-vswitch -p "Server vlan 10" -v 10 vSwitch1
/usr/sbin/esxcfg-vswitch -p VMotion -v 199 vSwitch2
sleep 5
/usr/bin/vimsh -n -e "hostsvc/net/refresh"
/usr/bin/vimsh -n -e "internalsvc/refresh_network"

# fill up Host file
rm -rf /etc/hosts
echo "# Do not remove the following line, or various programs" >> echo /etc/hosts
echo "# that require network functionality will fail." >> /etc/hosts
echo "127.0.0.1 localhost.localdomain localhost" >> /etc/hosts
echo "10.40.254.201 esx01.yellow-bricks-nhn.local esx01" >> /etc/hosts
echo "10.40.254.202 esx02.yellow-bricks.local esx02" >> /etc/hosts
echo "10.40.254.200 vc01.yellow-bricks.local vc01" >> /etc/hosts

# enable and configure ntp
/usr/sbin/esxcfg-firewall --enableService ntpClient
mv /etc/ntp.conf /etc/ntp.conf.old
mv /etc/ntp/step-tickers /etc/ntp/step-tickers.old
echo "restrict 127.0.0.1" >> /etc/ntp.conf
echo "restrict default kod nomodify notrap" >> /etc/ntp.conf
echo "server 10.40.254.11" >> /etc/ntp.conf
echo "server 10.40.254.12" >> /etc/ntp.conf
echo "driftfile /var/lib/ntp/drift" >> /etc/ntp.conf
echo "10.40.254.11" >> /etc/ntp/step-tickers
echo "10.40.254.12" >> /etc/ntp/step-tickers
/sbin/chkconfig --level 345 ntpd on
/etc/init.d/ntpd restart
/sbin/hwclock --systohc

# Enable VMotion
/usr/bin/vimsh -n -e "hostsvc/vmotion/vnic_set vmk0"

/etc/init.d/mgmt-vmware restart

EOF1

/bin/chmod 755 /tmp/esxcfg.sh
cp /etc/rc.d/rc.local /etc/rc.d/rc.local.bak
cat >> /etc/rc.d/rc.local <
cd /tmp
/tmp/esxcfg.sh
mv -f /etc/rc.d/rc.local.bak /etc/rc.d/rc.local
EOF