VMware 5.5 U3 CentOS 7 Image Prep
You can find a lot of scripts for vSphere 5.5 CentOS 7 images + customization specs but I found most were dated due to newer releases of open vm tools. I experimented with the CentOS 7 minimal ISO and found this script accomplished everything I needed with guest OS set to ‘CentOS 4/5/6/7 (64-bit)’, NIC using DHCP, and only containing root user:
# Step 1 - Upgrade OS, install necessary packages for vSphere customization
yum upgrade -y && yum install -y yum-utils perl open-vm-tools && systemctl reboot
# Step 2 - Prepare OS for conversion to template
# Remove old kernels
if [ $(rpm -q kernel | wc -l) != '1' ]; then package-cleanup -y --oldkernels --count=1; fi
# Remove the traces of the template MAC address and UUIDs
sed -i '/^\(HWADDR\|UUID\)=/d' /etc/sysconfig/network-scripts/ifcfg-e*
# enable network interface onboot
sed -i 's/^ONBOOT=no/ONBOOT=yes/' /etc/sysconfig/network-scripts/ifcfg-e*
# Remove the SSH host keys
rm -f /etc/ssh/*key*
# Remove the root user’s SSH history
rm -rf ~root/.ssh/
rm -f ~root/anaconda-ks.cfg
# Clean out yum
yum clean all
# Clean out temp files
rm -rf /tmp/*
rm -rf /var/tmp/*
# Stop logging services and clear existing log files
systemctl stop rsyslog
service auditd stop
find /var/log/ -type f -exec cp /dev/null {} \;
# Clean up root command history
cat /dev/null > ~root/.bash_history
history -cw
# manually run for now to create new machine id after template deployment
# rm -f /etc/machine-id && systemd-machine-id-setup
# Shutdown
systemctl poweroff
These reference pages helped out along the way: lonesysadmin.net and banck.net