How to create a Ubuntu 18.04.5 template in VSphere ESXi 6.7
October 14, 2020 at 4:19 pm Leave a comment
As usual you need to create a VM and install Ubuntu in to it. Thereafter you need to follow the below steps to strip out the unique data being propagated to the VM’s you create from the template.
+Update the OS
#sudo apt -y update
#sudo apt -y upgrade
+Clear audit logs
truncate -s0 /var/log/wtmp
truncate -s0 /var/log/lastlog
+Clear the tmp
#rm -rf /tmp/*
rm -rf /var/tmp/*
+Clear the SSH
#rm -f /etc/ssh/ssh_host_*
+Reset the hostname
#sed -i ‘s/preserve_hostname: false/preserve_hostname: true/g’ /etc/cloud/cloud.cfg
#truncate -s0 /etc/hostname
#hostnamectl set-hostname localhost
+Clean apt
#apt clean
+Remove the default *.yaml file from the /etc/netplan. The VMware customizaion will create it’s own file 99-netcfg-vmware.yaml.
#rm -f /etc/netplan/*.yaml
+Reset the machine id
#echo -n > /etc/machine-id
+Clear the history & shutdown the VM
#history -c
#shutdown -h now
On the vCenter you need to create a VM Customization specification to be used when deploying the VM’s from the template(Refer:How to create a RHEL 7 template in VSphere ESXi 6.7 for steps).
However , when I created the VM’s from this template I realised that
- All the VM’s are having the same hostid. Some applications uses the hostid in their licensing .Thus, it has to be unique across the VM’s. Since I did not find a way to solve this while deploying the VM’, I had to do a manual modification as mentioned below on the VM’s after it being created.
#vi /etc/hosts
replace the line “127.0.1.1 localhost” with
your IP FQDN Hostname (E.g: 1.1.1.1 server.test.local server). - You need to manually select the “Connected” option in The VM network Adapter in the VM properties.
Entry filed under: Linux.
Trackback this post | Subscribe to the comments via RSS Feed