Created on: June 26, 2015
Last Updated: July 14, 2015
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 traces of MAC and UUIDs
sed -i ‘/^(HWADDR|UUID)=/d’ /etc/sysconfig/network-scripts/ifcfg-eth0
-- Note: This might not have a ifcfg-eth0. Check for the correct name and fix as needed
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