So with most of the configuration done, it is time to add a template. I do this now since I had an outdated template as it is and I wanted to also note down a bit of the things I do for the template.
I am not going to go through the installation of the linux distro I will be using, which is CentOS. There are enough other pages to do this and the installation is quite intuitive. At the time of writing this, version 7.6 is still the newest release so I will go with that.
I do tend to select a minimal installation with 512 mb ram and 5 GB harddisk. I do not usually want to have a whole lot of extra things added to my Linux system for various reasons.
I set the root password (of course) and I do create a custom user with non admin rights.
I also tend to configure sudo rights, and for the user I create as a non administrator.
The next steps are as follows (First the step and then the command to do it).
As per VMware you need to make sure a couple of things are included into the manual installation apart from what is included by default. These things are listed here.
Unzip, Perl, wget, ip-tools are the three extra repositories required from VMware.
0: Install prerequisites that are not installed in the minimal installation.
- yum install perl net-tools wget unzip yum-utils -y
1: Update the system via Yum
- Log in as your secondary user
- run sudo yum update -y and let the system perform updates
- Reboot the host (This is needed to load on the latest kernel and allow you to do step 3).
2: Stop logging services
- systemctl stop rsyslog
- service auditd stop (This is why I love systemctl, systemctl does not permit it to stop).
3: Clean up old kernels
Since we installed a minimal installation we need to first install the yum-utils.
- /bin/package-cleanup –oldkernels –count=1 -y
- /usr/bin/yum clean all
4: Shrink/Clean the log space.
- /usr/sbin/logrotate -f /etc/logrotate.conf
- rm -f /var/log/*-???????? /var/log/*.gz
- rm -f /var/log/dmesg.old
- rm -rf /var/log/anaconda
- cat /dev/null > /var/log/audit/audit.log
- cat /dev/null > /var/log/wtmp
- cat /dev/null > /var/log/lastlog
- cat /dev/null > /var/log/grubby
5: Remove old hardware rules and the UUID from the ifcfg scripts
- /bin/sed -i ‘/^(HWADDR|UUID)=/d’ /etc/sysconfig/network-scripts/ifcfg-e*
- In /etc/sysconfig/network-scripts/ifcff-ens-192
- Change ONBOOT to “yes”
- CHange BOOTPROTO to “dhcp”
- Remove HWADDR/UUID
6: Remove the SSH host keys so it is generated with each new VM
- /bin/rm -f /etc/ssh/*key*
7: Clear the temp folders:
- /bin/rm -rf /tmp/*
- /bin/rm -rf /var/tmp/*
8: Remove the root users shell history
- rm -f ~root/.bash_history
- unset HISTFILE
9: Final step is to remove the users ssh history and then shut down the machine to create the template. The final command shuts down the guest and you should be ready with the template. Any additional commands you want to run on the template should be run before sys-unconfig.
- rm -rf ~root/.ssh/
- history -c
After this is performed you can convert the vm to a template. Remember to create a new VM customization specification to use with VRA for the blueprint creation.