Crafting custom Ubuntu images for MAAS: a packer tutorial
Errors or typos? Topics missing? Hard to read? Let us know!
Creating a custom Ubuntu image for MAAS can be a breeze with Packer. This tutorial takes you through the essentials: from prerequisites to building and finally deploying your custom image.
Before diving in, ensure your system is up to speed:
Install packer:
bash
sudo apt install packer
Gather the dependencies:
bash
sudo apt install qemu-utils qemu-system ovmf cloud-image-utils
Clone your templates: get the packer blueprints
Here's how to pull the essential Packer templates for MAAS:
git clone https://github.com/canonical/packer-maas.git
Craft your image: build a custom Ubuntu for MAAS
Time to create the magic. Follow these steps:
Navigate to the template directory:
bash
cd packer-maas/ubuntu
Fire up the build:
bash
make custom-ubuntu-lvm.dd.gz
This process will take a few moments. Good time for a cup of tea.
Push to MAAS: upload your masterpiece
With your image built, it's time to make it accessible in MAAS:
maas $MAAS_USER boot-resources create name=custom/ubuntu architecture=amd64/generic filetype=ddgz content@=custom-ubuntu-lvm.dd.gz
Deployment: unleash your custom image
Finally, deploy your custom image onto a node in MAAS:
Deploy the image to a node:
bash
maas $MAAS_USER machine deploy $SYSTEM_ID osystem=$OS [$distro_series=$DISTRO]
Confirm it's really yours:
bash
maas $MAAS_USER machines read | jq '.[] | {hostname, osystem}'
That's it! You've built and unleashed your custom Ubuntu image into the MAAS ecosystem. For those eager to dive deeper, consult the Packer MAAS documentation^ for advanced practices.