Created on: 2015 June 26
Last Updated: 2018 January 29
Synopsis: CentOS 7 on vSphere 5.5 does not clone out correctly using normal cloning methods. Running these fixes allows VMware to deploy from a CentOS 7 template with proper customizations.
Failure to perform these actions can result in :
- Naming failure inside the VM
- DNS Registration Failure
- IP and MAC address conflicts
- DHCP Failure
rm -f /etc/redhat-release && touch /etc/redhat-release && echo "Red Hat Enterprise Linux Server release 7.0 (Maipo)" > /etc/redhat-release`
https://lonesysadmin.net/2013/03/26/preparing-linux-template-vms/
Stop logging service
/sbin/service rsyslog stop
/sbin/service auditd stop
Remove old kernels
/bin/package-cleanup --oldkernels --count=1
Update and clean out YUM
yum upate
yum clean all
Truncate the audit logs (and other logs we want to keep placeholders for).
/bin/cat /dev/null > /var/log/audit/audit.log
/bin/cat /dev/null > /var/log/wtmp
/bin/cat /dev/null > /var/log/lastlog
/bin/cat /dev/null > /var/log/grubby
Remove all udev persistent device rules. Specifically the net-rules must be deleted to remove any MAC addresses.
This must be run every time you boot up / shutdown the template.
rm -f /etc/udev/rules.d/70*
Remove ifcfgs
rm -f /etc/sysconfig/network-scripts/ifcfg-e*
-- Note: This might not have a ifcfg-eth0 due to "sane" naming. Fix your biosdevnames if not, and try again.
https://github.com/chef-partners/knife-vsphere/wiki/Making-a-template-for-cloning
Clean out /tmp
rm –rf /tmp/*
rm –rf /var/tmp/*
Remove Host SSH Keys
rm –f /etc/ssh/*key*
Remove root shell history
rm -f ~root/.bash_history
unset HISTFILE
Remove SSH history
/bin/rm -rf ~root/.ssh/
/bin/rm -f ~root/anaconda-ks.cfg