Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions pve/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/make -f

include ../scripts/check.mk

PACKER ?= packer
PACKER_LOG ?= 0
export PACKER_LOG

BOOT ?= uefi
OVMF ?= OVMF

ifeq ($(wildcard /usr/share/$(OVMF)/$(OVMF)_CODE.fd),)
OVMF_SFX ?= _4M
else
OVMF_SFX ?=
endif

.PHONY: all clean

all: pve

$(eval $(call check_packages_deps,cloud-image-utils ovmf,cloud-image-utils ovmf))

lint:
packer validate .
packer fmt -check -diff .

format:
packer fmt .

OVMF_VARS.fd: /usr/share/${OVMF}/${OVMF}_VARS${OVMF_SFX}.fd
cp -v $< OVMF_VARS.fd

OVMF_CODE.fd: /usr/share/${OVMF}/${OVMF}_CODE${OVMF_SFX}.fd
cp -v $< OVMF_CODE.fd

pve: check-deps clean OVMF_CODE.fd OVMF_VARS.fd
${PACKER} init . && ${PACKER} build .

clean:
${RM} -rf output-* \
OVMF_VARS.fd \
OVMF_CODE.fd
97 changes: 97 additions & 0 deletions pve/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# Proxmox Virtual Environment (PVE) Packer Templates for MAAS

## Introduction

The Packer templates in this directory creates pve image for use with MAAS.

## Prerequisites (to create the image)

* A machine running Ubuntu 18.04+ with the ability to run KVM virtual machines.
* qemu-utils, libnbd-bin, nbdkit and fuse2fs
* qemu-system
* ovmf
* cloud-image-utils
* [Packer](https://www.packer.io/intro/getting-started/install.html), v1.7.0 or newer

## Requirements (to deploy the image)

* [MAAS](https://maas.io) 3.2+
* [Curtin](https://launchpad.net/curtin) 21.0+
* Create inside of MAAS a vmbr0 bridge with your interfaces.

## Supported Proxmox Versions

The builds and deployment has been tested on MAAS 3.5.4 with Noble ephemeral images,
in UEFI mode. The process currently works with the following PVE versions:

* Proxmox Virtual Environment 8.4-1

## Supported Architectures

Currently amd64 (x86_64) architecture is supported.

## Known Issues

* After the deployment process PXE Boot directly into PVE is not working
* Proxmox Services will not start because in /etc/hosts there is 127.0.0.1 configured for the hostname/fqdn. Please change the 127.0.0.1 to the correct ip address

## pve.pkr.hcl

This template builds a dd.gz image from the official Proxmox iso.

### Building the image

The build the image you give the template a script which has all the
customizations:

```shell
packer init .
packer build .
```

Using make:

```shell
make pve
```

### Custom Preseed for Proxmox

As mentioned above, pve images require a custom preseed file to be present in the
preseeds directory of MAAS region controllers.

When used snaps, the path is /var/snap/maas/current/preseeds/curtin_userdata_custom

Example ready to use preesed files has been included with this repository. Please
see curtin_userdata_custom_amd64.

**Please be aware** this could potentially create a conflict with the rest of custom
images present in your setup. To work around a conflict, it is possible to rename the
preseed file something similar to curtin_userdata_custom_amd64_generic_pve-8-4-1 assuming
the architecture was set to amd64/generic and the uploaded **name** was set to custom/pve-8-4-1.

In other words, depending on the image name parameter used during the import, the preseed
file(s) can be renamed to apply in a targetted manner.

For more information about the preseed file naming schema, see
[Custom node setup (Preseed)](https://github.com/CanonicalLtd/maas-docs/blob/master/en/nodes-custom.md) and
[Preseed filenames](https://github.com/canonical/maas/blob/master/src/maasserver/preseed.py#L756).

### Makefile Parameters

#### PACKER_LOG

Enable (1) or Disable (0) verbose packer logs. The default value is set to 0.

## Uploading images to MAAS

DD.GZ

```shell
maas $PROFILE boot-resources create \
name='custom/pve-8-4-1' \
title='Proxmox VE 8.4-1' \
architecture='amd64/generic' \
filetype='ddgz' \
content@=pve_lvm.dd.gz
```
24 changes: 24 additions & 0 deletions pve/curtin_userdata_custom_amd64
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#cloud-config
kernel:
fallback-package: proxmox-default-kernel
package: proxmox-default-kernel

apt:
preserve_sources_list: true

debconf_selections:
maas: |
{{for line in str(curtin_preseed).splitlines()}}
{{line}}
{{endfor}}

late_commands:
maas: [wget, '--no-proxy', '{{node_disable_pxe_url}}', '--post-data', '{{node_disable_pxe_data}}', '-O', '/dev/null']
late_1: mount --bind $TARGET_MOUNT_POINT /mnt
late_2: grep -A2 datasource /etc/cloud/cloud.cfg.d/91_kernel_cmdline_url.cfg | sed 's/curtin//' | tee /mnt/etc/cloud/cloud.cfg.d/debian.cfg
late_3: sed -i 's@ubuntu.com/ubuntu@debian.org/debian@g;s@archive@deb@g;s@ubuntu@debian@g;s@Ubuntu@Debian@g;s@security.debian.org/debian@security.debian.org@g' /mnt/etc/cloud/cloud.cfg
late_5: debver=$(cat /mnt/etc/debian_version | awk -F. '{print $1}'); if [ ${debver} -eq 11 ]; then rel="bullseye"; elif [ ${debver} -eq 12 ]; then rel="bookworm"; elif [ ${debver} -eq 13 ]; then rel="trixie"; fi; sed -i s/stable/${rel}/g /mnt/etc/apt/sources.list;
late_6: sed -i '/^set -e/{n;N;d}' /mnt/etc/kernel/postinst.d/zz-update-grub
late_7: rm -f /usr/local/bin/dpkg-query
late_8: rm -f /usr/local/bin/netplan

4 changes: 4 additions & 0 deletions pve/files/99_eni.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
system_info:
network:
renderers: ['eni']
activators: ['eni']
8 changes: 8 additions & 0 deletions pve/files/interfaces
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
auto lo
iface lo inet loopback

auto eth0
allow-hotplug eth0
iface eth0 inet dhcp

source /etc/network/interfaces.d/*
Loading