This tutorial covers building custom Ubuntu images for MAAS using Packer.
Prerequisites
-
Install Packer:
sudo apt install packer
-
Install dependencies:
sudo apt install qemu-utils qemu-system ovmf cloud-image-utils
Getting the Packer templates
Clone the Packer MAAS templates:
```
git clone https://github.com/canonical/packer-maas.git
```
Building a custom image
-
Navigate to the template directory:
cd packer-maas/ubuntu
-
Build the image:
make custom-ubuntu-lvm.dd.gz
This will take a few minutes to complete.
Uploading to MAAS
Upload the image to MAAS:
```
maas admin boot-resources create name=custom/ubuntu architecture=amd64/generic filetype=ddgz content@=custom-ubuntu-lvm.dd.gz
```
Deploying the Image
-
Now deploy the custom image to a node in MAAS.
-
Check the node details to confirm the custom OS:
maas admin machines read | jq '.[] | {hostname, osystem}'
With these steps, you’ve built and deployed a custom Ubuntu image with Packer and MAAS. Refer to the Packer MAAS documentation for more advanced usage.