I've been having troubles when deploying CentOS7 from template in that the customizations do not take effect. For the VM OS setting - I have selected RHEL7 as the OS rather than CentOS (previously having learned that lesson with Oracle Linux 6.5 at my previous job). It should work right? Not exactly.
After deploying a new VM from the CentOS7 template, on first boot the server comes up with the correct hostname, then the customization scripts execute, and after the VM reboots it has the original template hostname again, and while /etc/sysconfig/network-scripts/ifcfg-ether has the correct settings, the ifcfg settings for the correct nic (ifcfg-e*) have not been implemented.
I followed the VMWare's instructions for CentOS setup: http://partnerweb.vmware.com/GOSIG/CentOS_7.html
After a few package additions (including net-tools which is required for vSphere customizations), I then buttoned up the template as follows using my "templatize script" (credit to http://lonesysadmin.net/2013/03/26/preparing-linux-template-vms/ for steps):
#!/bin/bash # clean yum cache /usr/bin/yum clean all #remove udev hardware rules /bin/rm -f /etc/udev/rules.d/70* #remove nic mac addr and uuid from ifcfg scripts /bin/sed -i '/^\(HWADDR\|UUID\)=/d' /etc/sysconfig/network-scripts/ifcfg-eth0 #remove host keys (important step security wise. similar to system GUID in Windows) /bin/rm /etc/ssh/ssh_host_* #engage logrotate to shrink logspace used /usr/sbin/logrotate -f /etc/logrotate.conf #and lets shutdown init 0
Supported Versions where workarounds are no longer needed:
- vSphere 5.5u3 (build 3000241 or higher)
- vSphere 6.0 and higher
VMWare's "Guest OS Customization Support Matrix": http://partnerweb.vmware.com/programs/guestOS/guest-os-customization-matrix.pdf