This repository contains Packer template definitions for building images for use with Azimuth.
The templates work by provisioning machines in an OpenStack project and configuring them using Ansible before converting to an image. These images are then downloaded from OpenStack and uploaded to S3 for distribution in an Azimuth release.
Before building an image, you must configure OpenStack authentication, using either
an RC file or clouds.yaml, e.g.:
export OS_CLOUD=openstackThis repository has a concept of "environments", allowing builds to be customised for
different clouds if required, for example in a fork. These manifest as directories
under env, where environment are set that in turn can specify Packer var files
under var.
Currently, the repository contains a base environment with cloud-agnostic configuration
and an arcus environment that contains configuration for the continuous integration
environment, which is kindly hosted on the Arcus cloud at the University of Cambridge.
To build images manually, outside of CI, first ensure you have Packer installed and the required providers installed:
packer init ./config.pkr.hclNext, create a Python virtual environment to use and install the Python and Ansible dependencies:
python -m venv .venv
source .venv/bin/activate
pip install -r ./requirements.txt
ansible-galaxy install -f -r requirements.ymlFinally, set up an environment using the arcus environment for inspiration.
You can then build images using the ./bin/build-image script. This script expects the
following environment variables to be set:
ENVIRONMENT- the environment to usePACKER_TEMPLATE- the Packer template inpackerto useENV_VAR_FILES- the environment variable files to include
The values for PACKER_TEMPLATE and ENV_VAR_FILES can be determined by looking at
the defined builds.
For example, to build a workstation image, the following command can be used:
ENVIRONMENT=myenv \
PACKER_TEMPLATE=linux-desktop \
ENV_VAR_FILES=common,kvm,linux,ubuntu-jammy \
./bin/build-imageThis will result in a private image being created in the target OpenStack project.
To run the GitHub Actions linters locally, use:
docker run --rm \
-e RUN_LOCAL=true \
--env-file "super-linter.env" \
-v "$(pwd)":/tmp/lint \
ghcr.io/super-linter/super-linter:v7.3.0ansible-lint -c .ansible-lint.yml ansible/