Create a VMware vSphere template for Ubuntu Server 18.04

This article provides guidance for creating an Ubuntu Server 18.04 VMware vSphere virtual machine template.

Prerequisites

Note

This guide assumes that you have some VMware vSphere familiarity. It's not designed to review either VMware or Ubuntu best practices.

Creating Ubuntu 18.04 VM template

Deploying and installing Ubuntu

  • Deploy new virtual machine

    A screenshot of how to create a new VMware vSphere virtual machine.

    Second screenshot of how to create a new VMware vSphere virtual machine.

    Third screenshot of how to create a new VMware vSphere virtual machine.

    Fourth screenshot of how to create a new VMware vSphere virtual machine.

    Fifth screenshot of how to create a new VMware vSphere virtual machine.

    Sixth screenshot of how to create a new VMware vSphere virtual machine.

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

    A screenshot of Ubuntu Linux (64-bit) guest OS.

  • Point to the Ubuntu server ISO file location.

    Seventh screenshot of how to create a new VMware vSphere virtual machine.

    Eighth screenshot of how to create a new VMware vSphere virtual machine.

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

    • Consider using a static IP address

    • Install OpenSSH server

      First screenshot of an Ubuntu installation

      Second screenshot of an Ubuntu installation.

      Third screenshot of an Ubuntu installation.

      Fourth screenshot of an Ubuntu installation.

      Fifth screenshot of an Ubuntu installation.

      Sixth screenshot of an Ubuntu installation.

      Seventh screenshot of an Ubuntu installation.

      Eighth screenshot of an Ubuntu installation.

      Ninth screenshot of an Ubuntu installation.

      Tenth screenshot of an Ubuntu installation.

      Eleventh screenshot of an Ubuntu installation.

      Twelfth screenshot of an Ubuntu installation.

      Thirteenth screenshot of an Ubuntu installation.

      Fourteenth screenshot of an Ubuntu installation.

      Fifteenth screenshot of an Ubuntu installation.

      Sixteenth screenshot of an Ubuntu installation.

      Seventeenth screenshot of an Ubuntu installation.

      Eighteenth screenshot of an Ubuntu installation.

      Nineteenth screenshot of an Ubuntu installation.

      Twentieth screenshot of an Ubuntu installation.

      Twenty-first screenshot of an Ubuntu installation.

Post-installation

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

  • Update your OS packages:

    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 and 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.

A screenshot of how to reduce a virtual machine's CPU count and memory.

A screenshot of how to convert a virtual machine to a template.