Create a VMware vSphere template for Ubuntu Server 18.04

The following README will guide you on how to create an Ubuntu Server 18.04 VMware vSphere virtual machine template.

Prerequisites

Note: This guide assumes that you have some VMware vSphere familiarity. It is also does not designed to go over either VMware and/or Ubuntu best-practices.

Creating Ubuntu 18.04 VM Template

Deploying & Installing Ubuntu

  • Deploy new virtual machine

    Create new VMware vSphere VM

    Create new VMware vSphere VM

    Create new VMware vSphere VM

    Create new VMware vSphere VM

    Create new VMware vSphere VM

    Create new VMware vSphere VM

  • Make sure to select Ubuntu Linux (64-bit) as the Guest OS.

    Ubuntu Linux (64-bit) Guest OS

  • Point to the Ubuntu Server ISO file location.

    Create new VMware vSphere VM

    Create new VMware vSphere VM

  • Power-on the VM and start the Ubuntu installation. No specific instructions here but:

    • (Optional) Consider using static IP

    • Install OpenSSH server

      Power-on the VM

      Ubuntu installation

      Ubuntu installation

      Ubuntu installation

      Ubuntu installation

      Ubuntu installation

      Ubuntu installation

      Ubuntu installation

      Ubuntu installation

      Ubuntu installation

      Ubuntu installation

      Ubuntu installation

      Ubuntu installation

      Ubuntu installation

      Ubuntu installation

      Ubuntu installation

      Ubuntu installation

      Ubuntu installation

      Ubuntu installation

      Ubuntu installation

      Ubuntu installation

Post-installation

Before converting the VM to a template, few actions are needed.

  • It’s better to have your OS packages up-to-date

    sudo apt-get update
    sudo apt-get upgrade -y
    
  • Prevent cloudconfig from preserving the original hostname and reset the hostname

    sudo sed -i 's/preserve_hostname: false/preserve_hostname: true/g' /etc/cloud/cloud.cfg
    sudo truncate -s0 /etc/hostname
    sudo hostnamectl set-hostname localhost
    
  • Remove the current network configuration

    sudo rm /etc/netplan/50-cloud-init.yaml
    
  • Clean shell history and shutdown the VM

    cat /dev/null > ~/.bash_history && history -c
    sudo shutdown now
    

Convert to Template

Reduce the VM CPU count & memory resources to the minimum and convert the VM to template, switch the CD/DVD drive to client device as well disconnect it and convert the VM to template.

Reduce the VM CPU count & Memory

Convert the VM to template