Skip to main content

Virtual machine template

Prepare VM template

This template will be used for all new VM's to be linked and cloned from.

  • Download Ubuntu server LTS for arm via Ubuntu website
  • Once downloaded open Parallels control centre and select new from the menu
    • Choose: Install Windows, Linux, or macOS from an image file and continue
    • Select a file: choose this option and select the iso from your downloads folder and then continue
    • Change the name from Ubuntu Linux to dev-template, tick the box: Customise settings before installation and create
    • The configuration options will display
      • Name: dev-template
      • Sharing: disable all sharing
      • Hardware. CPU & Memory: 2 Processors with 2048MB memory
      • Hardware. Shared Printers: Do not share mac printers
      • Hardware. Network: Change to Wi-Fi
      • Hardware. Sound and Camera: Disable all
      • Hardware. Boot order: only enable Hard Disk
    • Continue install
      • Allocate all space to VM
      • Enable SSH server
      • Create username
        • username: dev
    • Install completed
  • From parallels dashboard
    • Start dev-template VM and console window will launch
    • Right click and select configure
      • Option: Startup and Shutdown
        • Change to custom: On Window Close change to Keep running in background
    • Console
      • Choose a password and repeat it
      • Login using username: dev and new password
      • Start interactive shell as root: sudo -i
      • Update packages: apt update
      • Upgrade packages: apt upgrade
      • Install additional packages: apt install net-tools traceroute ntp locate
      • Check ethernet name and IP address: ifconfig
      • Run the following command to edit the Netplan config:
        vi /etc/netplan/50-cloud-init.yaml
      • Then change the contents in the file to your IP and gateway, making a note of the ethernet adapter - in my virtual environment it is: enp0s5
        network:
        version: 2
        ethernets:
        enp0s5:
        addresses:
        - '192.168.1.209/24'
        routes:
        - to: 'default'
        via: '192.168.1.254'
      • Apply the changes: netplan apply
    • Close console (the VM will continue to run in the background)

Template preparation

Continue from ssh session.

  • Connect to VM IP address in a new terminal session: ssh dev@192.168.1.209
  • Login with username: dev and password
  • Switch to root user: sudo -i
  • Check routing table: ip route
  • Check ping to google: ping 8.8.8.8
  • Check time and date: timedatectl
  • Check swap usage: swapon
  • Disable swap temporarily (reboot clears it): swapoff -a
  • Disable swap perm
    vi /etc/fstab
  • Comment out swap
    # /swap.img	none	swap	sw	0	0
  • Prepare DNS - my router provides DNS
    mkdir /etc/systemd/resolved.conf.d
    vi /etc/systemd/resolved.conf.d/dns_servers.conf
    [Resolve]
    DNS=192.168.1.254
    Domains=~.
  • Enable and restart services
    systemctl enable systemd-resolved
    sudo systemctl restart systemd-resolved
  • Confirm local name resolution: ping lab.internal.example.com
  • Confirm external name resolution: ping www.google.com.au
  • Configure NTP (note NTP is now part of NTPSEC)
    vi /etc/ntpsec/ntp.conf
  • Add local NTP server and comment out the defaults - my router provides NTP
    pool 192.168.1.254 iburst
    # pool 0.ubuntu.pool.ntp.org iburst
    # pool 1.ubuntu.pool.ntp.org iburst
    # pool 2.ubuntu.pool.ntp.org iburst
    # pool 3.ubuntu.pool.ntp.org iburst
    # server ntp.ubuntu.com
  • Restart NTP services for changes to take effect: service ntp restart
  • Check that NTP services are being picked up: ntpq -p
  • Check time and date: timedatectl
  • Set timezone: timedatectl set-timezone Australia/Perth
  • Update database for locate package: updatedb
  • Add additional user: adduser YOUR_USER
  • Add new user to sudo list: usermod -aG sudo andy
  • Disable IPv6
    vi /etc/default/grub
  • Change the default
    GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 ipv6.disable=1 quiet splash"
  • Update grub for changes to take effect: update-grub
  • Disable cloud init: touch /etc/cloud/cloud-init.disabled
  • Install NFS: apt install nfs-common -y
  • Reboot VM to ensure all changes have taken effect: reboot
  • Log back into the VM and shutdown template VM so that it can be linked and cloned from (DO NOT power up again): shutdown -P now
    • Once a linked clone is created, it’s frozen to the parent’s disk as it was at clone time. Future changes to the parent (template), package installs, updates, config edits, etc., will NOT propagate to existing clones but could break their dependency chain

From Parallels desktop control panel

  • Right click on dev-template and select Linked-clone and repeat for each linked clone, naming them:

    • ansible-1
    • lb-1
    • master-1
    • worker-1
  • DON'T start them yet

    • Only one will be powered on at a time until its IP address has been changed and rebooted
    • Each will start with the template IP address: 192.168.1.209
  • Start ansible-1 by right clicking on it

    • Console will display

      • Change the IP address to 192.168.1.208
      sudo vi /etc/netplan/50-cloud-init.yaml
      network:
      version: 2
      ethernets:
      enp0s5:
      addresses:
      - '192.168.1.208/24'
      • Apply the changes: sudo netplan apply
      • Check new IP: ifconfig
      • Change hostname: sudo hostnamectl set-hostname ansible-1
      • Reboot: sudo reboot
  • Start lb-1 by right clicking on it

    • Console will display

      • Change the IP address to 192.168.1.201
      sudo vi /etc/netplan/50-cloud-init.yaml
      network:
      version: 2
      ethernets:
      enp0s5:
      addresses:
      - '192.168.1.201/24'
      • Apply the changes: sudo netplan apply
      • Check new IP: ifconfig
      • Change hostname: sudo hostnamectl set-hostname lb-1
      • Reboot: sudo reboot
  • Configure master-1 by right clicking on it

    • Increase the number of processors to 4 and memory to 4096MB

    • Power on VM

    • Console will display

      • Change the IP address to 192.168.1.203
      sudo vi /etc/netplan/50-cloud-init.yaml
      network:
      version: 2
      ethernets:
      enp0s5:
      addresses:
      - '192.168.1.203/24'
      • Apply the changes: sudo netplan apply
      • Check new IP: ifconfig
      • Change hostname: sudo hostnamectl set-hostname master-1
      • Reboot: sudo reboot
  • Configure worker-1

    • Increase the memory to 4096MB
    • Power on VM
    • Console will display
    • Change the IP address to 192.168.1.206
    sudo vi /etc/netplan/50-cloud-init.yaml
    network:
    version: 2
    ethernets:
    enp0s5:
    addresses:
    - "192.168.1.206/24"
    • Apply the changes: sudo netplan apply
    • Check new IP: ifconfig
    • Change hostname: sudo hostnamectl set-hostname worker-1
    • Reboot: sudo reboot