Created
December 5, 2017 16:49
-
-
Save jeffgreenca/6fd28b144371379e81b4db079f6eea7c to your computer and use it in GitHub Desktop.
hacked together centos template configuration script for VM provisioning
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#References | |
https://lonesysadmin.net/2013/03/26/preparing-linux-template-vms/ | |
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Virtualization_Deployment_and_Administration_Guide/sect-Guest_virtual_machine_disk_access_with_offline_tools-Using_virt_sysprep.html | |
http://everything-virtual.com/2016/05/06/creating-a-centos-7-2-vmware-gold-template/ | |
#Installed using latest CentOS 7 minimal media (June 6th) | |
#Enabled SELinux to the second option (default policies, minimum basically) | |
yum update -y | |
#Install these packages: | |
yum install open-vm-tools epel-release -y | |
yum install sysstat screen mlocate python-simplejson python-pip \ | |
libselinux-python net-tools perl git -y | |
#Run this script: | |
#Part 1 | |
/sbin/service rsyslog stop | |
/sbin/service auditd stop | |
/bin/package-cleanup --oldkernels --count=1 | |
#Install vRA Guest Agent (if using with vRA) | |
https://<vra-server>/software/download/prepare_vra_template.sh | |
#Part 2 | |
/usr/bin/yum clean all | |
/usr/sbin/logrotate -f /etc/logrotate.conf | |
/bin/rm -f /var/log/*-???????? /var/log/*.gz | |
/bin/rm -f /var/log/dmesg.old | |
/bin/rm -rf /var/log/anaconda | |
/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 | |
/bin/sed -i '/^(HWADDR|UUID)=/d' /etc/sysconfig/network-scripts/ifcfg-* | |
/bin/rm -rf /tmp/* | |
/bin/rm -rf /var/tmp/* | |
/bin/rm -f /etc/ssh/*key* | |
/bin/rm -f ~root/.bash_history | |
unset HISTFILE | |
/bin/rm -rf ~root/.ssh/ | |
/bin/rm -f ~root/anaconda-ks.cfg | |
history -c | |
#Part 3 - This will cause power off immediately | |
sys-unconfig |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment