So as promised I’ve copied the kickstart which I used to deploy our lab. Some options are default, others are not. Also I’ve added all the references that I used during the creation of the script. Options defined between [] are variables used in the sub template part of UDA. Before scrolling down to the deployment script I think you ought to look at the sub template part. This can save you loads and loads of time. Personally, I think creating such a script is loads of fun. You can configure almost anything you want and in the end all ESX servers will be identical. One of the benefits for me is that there is less change to make any mistakes during a manual installation
Back to the scripting part. Although you probably will notice that the sub template is just partial, I think you will get the idea.
The sub template:
SUBTEMPLATE;IPADDR;HOSTNAME;FQDN;SUBNET;GW;DNS;
INSTALL_ESX01;192.168.255.11;ESX01;ESX01.domain.com;255.255.255.0;192.168.255.254;192.168.255.1;
INSTALL_ESX02;192.168.255.12;ESX02;ESX02.domain.com;255.255.255.0;192.168.255.254;192.168.255.1;
And the Kickstart Script:
# VMware ESX4 template Kickstart file # Installation Method install url <a href="http://[UDA_IPADDR]/[OS]/[FLAVOR]">http://[UDA_IPADDR]/[OS]/[FLAVOR]</a> # root Password rootpw EnteryourPasswordHere # Authconfig auth --enableshadow --enablemd5 # BootLoader ( The user has to use grub by default ) bootloader --location=mbr # Timezone timezone Europe/Amsterdam # Network install type # This defines our final static IP on the vswif0 management interface of vmnic0 (aka the Service Console) and addvmportgroup=0 disables the default VM network creation. network --device=vmnic0 --bootproto=static --ip=[IPADDR] --netmask=[SUBNET] --gateway=[GW] --nameserver=[DNS] --hostname=[FQDN] --addvmportgroup=0 # Keyboard keyboard us # Reboot after install ? reboot # Firewall from the installer itself will be disabled firewall --disabled # Clear Partitions clearpart --overwritevmfs --firstdisk=local --all # Either choose autopartitioning # autopart --disk=[DISKTYPE] # Or do the partitioning yourself echo "Configuring Partitions" part /boot --fstype=ext3 --size=250 --onfirstdisk=local part local_[HOSTNAME] --fstype=vmfs3 --size=9000 --onfirstdisk=local --grow part None --fstype=vmkcore --size=250 --onfirstdisk=local virtualdisk cos --size=7500 --onvmfs=local_[HOSTNAME] part / --fstype=ext3 --size=3000 --onvirtualdisk=cos --grow part swap --fstype=swap --size=1000 --onvirtualdisk=cos part /opt --fstype=ext3 --size=1000 --onvirtualdisk=cos part /tmp --fstype=ext3 --size=1000 --onvirtualdisk=cos part /home --fstype=ext3 --size=1000 --onvirtualdisk=cos # VMware Specific Commands vmaccepteula %packages %post --interpreter=bash ## ---------------- References ----------------------------- ## <a href="http://www.vmware.com/pdf/vi3_35/esx_3/r35u2/vi3_35_25_u2_installation_guide.pdf">http://www.vmware.com/pdf/vi3_35/esx_3/r35u2/vi3_35_25_u2_installation_guide.pdf</a> ## <a href="http://www.vmware.com/pdf/vsphere4/r40/vsp_40_esx_vc_installation_guide.pdf">http://www.vmware.com/pdf/vsphere4/r40/vsp_40_esx_vc_installation_guide.pdf</a> ## <a href="http://www.vmware.com/pdf/vsphere4/r40/vsp_40_esx_server_config.pdf">http://www.vmware.com/pdf/vsphere4/r40/vsp_40_esx_server_config.pdf</a> ## <a href="http://www.jume.nl/articles/vmware/125-following-the-uda-20-beta-found-workarounds">http://www.jume.nl/articles/vmware/125-following-the-uda-20-beta-found-workarounds</a> ## <a href="http://www.dailyhypervisor.com/2009/03/23/automated-deployment-of-esx-hosts-part-iii/">http://www.dailyhypervisor.com/2009/03/23/automated-deployment-of-esx-hosts-part-iii/</a> ## <a href="http://vmware-land.com/esxcfg-help.html">http://vmware-land.com/esxcfg-help.html</a> ## <a href="http://www.l4l.be/index.php/virtualisatie/40-vmware/157-esx35-kickstart">http://www.l4l.be/index.php/virtualisatie/40-vmware/157-esx35-kickstart</a> ## <a href="http://www.vreference.com/2010/01/14/ad-and-sudo-integratation-in-kickstart/">http://www.vreference.com/2010/01/14/ad-and-sudo-integratation-in-kickstart/</a> ## --------------------------------------------------------- ## Create one time only script which kicks in after reboot for networking part touch /etc/default/esxcfg.sh chmod 777 /etc/default/esxcfg.sh cat > /etc/default/esxcfg.sh <<EOF #!/bin/sh # wait a couple of minutes to make sure that the # hostd-daemon is started sleep 2m ## Adding the VMkernel/VMotion port group to vSwitch0 echo "Configuring the VMkernel/VMotion port group" /usr/sbin/esxcfg-vswitch -A VMotion vSwitch0 /usr/sbin/esxcfg-vmknic --add --ip [VMOTIONIP] --netmask [VMOTIONSUB] VMotion /usr/sbin/esxcfg-route [VMOTIONGW] ## Wait a couple of seconds to give ESX the time to create the vmknic sleep 10s /usr/bin/vmware-vim-cmd hostsvc/vmotion/vnic_set vmk0 /usr/bin/vmware-vim-cmd internalsvc/refresh_network EOF # runonce script cp /etc/rc.d/rc.local /etc/rc.d/rc.local.bak cat >> /etc/rc.d/rc.local <<EOF3 /etc/default/esxcfg.sh mv -f /etc/rc.d/rc.local.bak /etc/rc.d/rc.local EOF3 ## ------------------------------------------------------- ## ----- the rest of the script which can run directly --- ## ------------------------------------------------------- ## Give new accounts the path variables to run esxcfg commands without the need to find the correct path cat >> /etc/skel/.bash_profile <<EOF # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs PATH=$PATH:$HOME/bin:/usr/local/sbin:/sbin:/usr/sbin:$HOME/bin” export PATH unset USERNAME EOF ## -------------------------------------------------------- ## -------------------------------------------------------- ## -------------------------------------------------------- # Configure Active Directory authentication (change both domains to yours) esxcfg-auth --enablead --addomain=domain.com --addc=domain.com # Add active directory users to the local database /usr/sbin/useradd ADuser1 -c "Full user name" -m /usr/sbin/useradd ADuser2 -c "Full user name" -m /usr/sbin/useradd ADuser3 -c "Full user name" -m # Additional DNS configuration when IP's are known. echo nameserver 10.0.0.0 >> /etc/resolv.conf ## -------------------------------------------------------- ## -------------------------------------------------------- ## -------------------------------------------------------- ## Adding the local users to groups /usr/sbin/usermod -G wheel ADuser1 /usr/sbin/usermod -G wheel ADuser2 /usr/sbin/usermod -G wheel ADuser3 ## Adding SUDO rights to the users cat >> /etc/sudoers << SUDO root ALL=(ALL) ALL ## Allows people in group wheel to run all commands %wheel ALL=(ALL) ALL SUDO ## Configuring NTP services # Backup ntpd.conf and step-tickers file mv /etc/ntpd.conf /etc/ntpd.conf.bak mv /etc/ntpd/step-tickers /etc/ntpd/step-tickers.bak # Add Servers to step-tickers cat > /ect/ntp/step-tickers <<EOF dc01.domain.com dc02.domain.com # create ntp.conf EOF cat > /etc/ntp.conf << EOF restrict 127.0.0.1 restrict dc01.domain.com mask 255.255.255.255 nomodify notrap noquery restrict dc02.domain.com mask 255.255.255.255 nomodify notrap noquery server dc01.domain.com server dc02.domain.com driftfile /var/lib/ntp/drift EOF # Service restart service ntpd restart # Make ntp start at boot time chkconfig --level 345 ntpd on # Sync hardware clock hwclock -–systohc ## Automatically enable and starts the webservices preventing 503 errors using the web browser ## This because the web service is per default disabled /sbin/chkconfig --level 345 vmware-webAccess on service vmware-webAccess restart ## Firewall configuration /usr/sbin/esxcfg-firewall --enableService webAccess /usr/sbin/esxcfg-firewall --enableService sshClient /usr/sbin/esxcfg-firewall --enableService ntpClient /usr/sbin/esxcfg-firewall –openport 88,tcp,out,KerberosClientTCP /usr/sbin/esxcfg-firewall –openport 53,tcp,out,dns ## Adding illegal notice warning during SSH login touch /etc/default/banner chmod 777 /etc/default/banner cat > /etc/default/banner << EOF ******************************************************************************** This is a private system. Do not attempt to login unless you are an authorized user. Any authorized or unauthorized access and use, may be monitored and can result in criminal or civil prosecution under applicable law of The Netherlands ******************************************************************************** EOF chmod 755 /etc/default/banner echo Banner /etc/default/banner >> /etc/ssh/sshd_config
