neilkidd / packer-ubuntu-2004

Packer template to auto build ubuntu 20.04 lts

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

packer-ubuntu-2004

Build Status MIT License

This repository contains Packer templates for creating, and publishing, Ubuntu 20.04 Vagrant boxes based on Virtualbox.

Goals

There are a good number of public vagrant boxes, however each one has some issue that made them unsuitable for my out of box usage. I wanted to experiment freely, and iterate rapidly, so decided to build and publish my own with the following goals:

  • English GB localisation. (Locale and keyboard)
  • Ubuntu LTS OOB experience to mimic a locally installed server.
  • All Updates applied.
  • Travis to build and publish.
  • Ubuntu-mate-core desktop
  • Github actions to auto build and publish up to date boxes. (No VM support)

Credits

Published Boxes

Requirements

The versions of software I used are in parenthesis. YMMV.

Local development

To experiment locally, without uploading to Vagrant cloud, provide the packer argument -except=.

  1. Run:
    packer build -except=vagrant-cloud ubuntu.json.
    After a few minutes a ready to use box will be in the builds directory.
  2. Edit the provided Vagrantfile to point to the local box.
  3. Run:
    vagrant up

Publishing a Box to Vagrant Cloud

  1. Log in to your Vagrant Cloud Account

  2. Create an Authentication Token

    1. Save the long string somewhere safe. Later, this will be exported as the env variable VAGRANT_CLOUD_TOKEN.
  3. Create a new Vagrant Box

    1. Tip: Enter the Name as ubuntu2004
      In the next step, the value for "vm_name": will not need editing.
  4. Edit ubuntu.json, changing the values for:
    "vagrantcloud_username": "neil_kidd"
    "vm_name": "ubuntu2004".

  5. Paste your Auth Token into the following command and run:
    VAGRANT_CLOUD_TOKEN={REPLACE_THIS} packer build ubuntu.json

  6. Sometime later the terminal should have output similar to:

    ...
    virtualbox-iso (vagrant-cloud): Box successfully uploaded
    ==> virtualbox-iso (vagrant-cloud): Releasing version: 2004.20200628.082705
    virtualbox-iso (vagrant-cloud): Version successfully released and   available
    Build 'virtualbox-iso' finished.
  7. Edit the provided Vagrantfile to point to your cloud release.

  8. To import the box and experiment, run:
    vagrant up

Notes

Version Numbers

Version numbers are generated incrementally using a combination of ubuntu release number + UTC date-time.
e.g: 2004.20200618.203713
Where:

  • 2004 = the Ubuntu release 20.04
  • 20200618 = the 18th of June 2020
  • 203713 = 8 PM, 37 minutes, 13 seconds

Flexible Configuration

It is possible to re-use the templates without editing the provided templates directly. Many of the variables, in ubuntu.json, can be overridden on the command line or using a secondary json file.

Example Publishing to Specified Cloud Account

This example will build as is and publish to your pre configured Vagrant Cloud account ( you/myvm ):

VAGRANT_CLOUD_TOKEN={your_token} \
packer build \
-var 'vagrantcloud_username=you' \
-var 'vm_name=myvm' \
ubuntu.json

Example Building a Local Box for the US

This example will build a local box, in US configuration with a 50GB hdd, 2 cpus and 4gb of Ram.

packer build \
-except=vagrant-cloud \
-var 'keyboard_country=US' \
-var 'locale=en_US.UTF-8' \
-var 'cpus=2' \
-var 'disk_size=50000' \
-var 'memory=4096' \
ubuntu.json

License

MIT

About

Packer template to auto build ubuntu 20.04 lts

License:MIT License


Languages

Language:Shell 100.0%