Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bby-bishopclark/b95fac5146f4029b86861e21c76b7734 to your computer and use it in GitHub Desktop.
Save bby-bishopclark/b95fac5146f4029b86861e21c76b7734 to your computer and use it in GitHub Desktop.
CentOS 7 VMware Customization

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

CentOS 7 Template

Fix Redhat-Release for customization

https://serverfault.com/questions/653052/from-vsphere-5-5-deploying-centos-7-from-template-ignores-customizations

rm -f /etc/redhat-release && touch /etc/redhat-release && echo "Red Hat Enterprise Linux Server release 7.0 (Maipo)" > /etc/redhat-release`
Preparing Template

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment