Create clean RHEL/CentOS 6 Template for VMware

Here is how I’m creating Templates for VMware

1.) Update the OS and install vmware tools

# yum update

2.) Clean the yum cache

# yum clean all

2.) Remove SSH host keys

# rm -f /etc/ssh/ssh_host_*

3.) Remove MAC and UUID’s from network configuration files.

# sed -i ā€˜/^(HWADDR|UUID)=/dā€™ /etc/sysconfig/network-scripts/ifcfg-eth*

4.) Remove persistent device rules

# rm -f /etc/udev/rules.d/70-persistent-*

5.) Force the log rotate and clean the log files

# logrotate ā€“f /etc/logrotate.conf
# rm ā€“f /var/log/*-???????? /var/log/*.gz
# cat /dev/null > /var/log/audit/audit.log
# cat /dev/null > /var/log/wtmp
# cat /dev/null > /var/log/messages

6.) Clean the /tmp

# rm -rf /tmp/*
# rm -rf /var/tmp/*

7.) un-configured the system if you’r not using customization specification

# touch /.unconfigured

7.) Remove the shell history

# rm -f ~/.bash_history
# unset HISTFILE

8.) Finally poweroff the system.

# poweroff