/packer-ubuntu-zfs

Packer templates for Ubuntu AMIs with a ZFS Root filesystem.

Primary LanguagePythonMozilla Public License 2.0MPL-2.0

Packer Templates for Ubuntu with ZFS Root

This repository contains Packer templates for building Amazon Machine Images for Ubuntu with a ZFS root filesystem. Currently the following distributions are supported:

  • Ubuntu 20.04 ("Focal") LTS with AWS-Optimized Kernel
  • Ubuntu 18.04 ("Bionic") LTS with AWS-Optimized Kernel
  • Ubuntu 16.04 ("Xenial") LTS with AWS-Optimized Kernel

The template is easily modified for Debian and other Ubuntu distributions.

You can read about how this template works on the jen20.dev blog. Some relevant posts:

Differences between versions

As well as installing different versions of the Ubuntu distribution, the templates in this repository have evolved at different rates. The focal template is the most complete, and includes the following changes compared to other versions:

  • Support for AWS NVME device rules
  • Support for expanding the ZFS root filesystem via Cloud-Init
  • Clearing of the apt-cache as part of the build

These changes could likely be backported to other distributions, but they are mostly there for information only since I personally only use (and test) the latest LTS distribution for new images.

Running a build (Focal)

Use the focal target of the Makefile in the root of the repository to build an AMI in us-west-2. If you wish to copy the AMI to other regions, edit the template to specify aws_regions in the amazon-ebssurrogate.source source. It is also possible to change the region in which the AMI is built directly, though editing files/sources-us-west-2.list is necessary if the initial packages must be obtained from a region other than us-west-2.

AWS credentials are sourced from the environment using the standard AWS chain exposed by Packer. The template has only been tested using v1.6.0 of Packer - the latest available at the time of writing.

Running a build (Bionic and Xenial)

Use the bionic or xenial targets of the Makefile in root of the repository to build an AMI in us-west-2, and copy it to all regions. Use a recent version of Packer - version 1.3.1 has been tested.

The following environment variables must be set in order for the build to succeed:

  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY

Credits

Thanks to: