222 lines
4.5 KiB
Markdown
222 lines
4.5 KiB
Markdown
|
|
Image was built using Debian 12, kernel 6.1.0-50-cloud-amd64, Docker version 29.6.1, build 8900f1d
|
|||
|
|
|
|||
|
|
Built date is 12/07/2026
|
|||
|
|
|
|||
|
|
|
|||
|
|
Here, an existing rolling release ISO is modified to include qemu-guest-agent and to be CloudInit capable instead of building the whole QCOW2 image from the ground up.
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
First download the prerequisites
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
sudo apt update
|
|||
|
|
|
|||
|
|
sudo apt install -y \
|
|||
|
|
git \
|
|||
|
|
make \
|
|||
|
|
qemu-system-x86 \
|
|||
|
|
qemu-utils \
|
|||
|
|
wget \
|
|||
|
|
gpg \
|
|||
|
|
lsb-release
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
|
|||
|
|
Install Packer from HashiCorp’s repository
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
wget -O - https://apt.releases.hashicorp.com/gpg |
|
|||
|
|
sudo gpg --dearmor \
|
|||
|
|
-o /usr/share/keyrings/hashicorp-archive-keyring.gpg
|
|||
|
|
|
|||
|
|
echo \
|
|||
|
|
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] \
|
|||
|
|
https://apt.releases.hashicorp.com \
|
|||
|
|
$(grep -oP '(?<=UBUNTU_CODENAME=).*' /etc/os-release || lsb_release -cs) main" |
|
|||
|
|
sudo tee /etc/apt/sources.list.d/hashicorp.list
|
|||
|
|
|
|||
|
|
sudo apt update
|
|||
|
|
sudo apt install -y packer
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
|
|||
|
|
Verify everything
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
packer version
|
|||
|
|
qemu-system-x86_64 --version
|
|||
|
|
qemu-img --version
|
|||
|
|
|
|||
|
|
test -e /dev/kvm && echo "KVM available" || echo "KVM unavailable"
|
|||
|
|
egrep -m1 '(vmx|svm)' /proc/cpuinfo
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
|
|||
|
|
# Clone packer-vyos
|
|||
|
|
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
ISO_SOURCE="./vyos-2026.03-generic-amd64.iso"
|
|||
|
|
VM_NAME="$(basename "$ISO_SOURCE" .iso)"
|
|||
|
|
|
|||
|
|
cp "$ISO_SOURCE" "iso/${VM_NAME}.iso"
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
|
|||
|
|
Create and verify checksums
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
cd iso
|
|||
|
|
sha256sum "${VM_NAME}.iso" > SHA256SUM
|
|||
|
|
cd ..
|
|||
|
|
|
|||
|
|
cat iso/SHA256SUM
|
|||
|
|
sha256sum -c iso/SHA256SUM
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
|
|||
|
|
First, remove the VyOS current repository from the temporary APT source used by Packer
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
sed -i \
|
|||
|
|
'\|dev.packages.vyos.net/repositories/current|d' \
|
|||
|
|
http/debian_12-vyos.list
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
Now replace the script that normally reinstalls Cloud-Init
|
|||
|
|
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
cat > scripts/vyos/cloud-init-vyos.sh <<'EOF'
|
|||
|
|
#!/bin/bash
|
|||
|
|
|
|||
|
|
set -euo pipefail
|
|||
|
|
set -x
|
|||
|
|
|
|||
|
|
if [[ "${CLOUD_INIT:-}" != "vyos" ]]; then
|
|||
|
|
echo "VyOS Cloud-Init preservation not requested; skipping"
|
|||
|
|
exit 0
|
|||
|
|
fi
|
|||
|
|
|
|||
|
|
# Fail rather than silently replacing the Stream ISO's Cloud-Init package.
|
|||
|
|
if ! dpkg-query -W -f='${Status}\n' cloud-init 2>/dev/null |
|
|||
|
|
grep -qx 'install ok installed'; then
|
|||
|
|
echo "ERROR: The installed VyOS image does not contain cloud-init."
|
|||
|
|
exit 1
|
|||
|
|
fi
|
|||
|
|
|
|||
|
|
# Enable the existing VyOS-patched Cloud-Init installation.
|
|||
|
|
systemctl enable cloud-init.service
|
|||
|
|
|
|||
|
|
# Do not let generic Cloud-Init networking conflict with VyOS interface
|
|||
|
|
# configuration. Interfaces will be configured using vyos_config_commands.
|
|||
|
|
mkdir -p /etc/cloud/cloud.cfg.d
|
|||
|
|
|
|||
|
|
cat > /etc/cloud/cloud.cfg.d/99-disable_network_config.cfg <<'CFG'
|
|||
|
|
network: {config: disabled}
|
|||
|
|
CFG
|
|||
|
|
|
|||
|
|
# Match the image-builder behaviour: do not execute generic config-stage
|
|||
|
|
# modules. VyOS-specific user-data processing remains available.
|
|||
|
|
cat > /etc/cloud/cloud.cfg.d/90-disable_config_stage.cfg <<'CFG'
|
|||
|
|
cloud_config_modules:
|
|||
|
|
CFG
|
|||
|
|
|
|||
|
|
rm -f /etc/network/interfaces.d/50-cloud-init
|
|||
|
|
EOF
|
|||
|
|
|
|||
|
|
chmod +x scripts/vyos/cloud-init-vyos.sh
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
|
|||
|
|
The repository normally installs vim and net-tools during stage two. They are unnecessary for this image, so make that script a no-op
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
cat > scripts/vyos/apt-install.sh <<'EOF'
|
|||
|
|
#!/bin/bash
|
|||
|
|
|
|||
|
|
set -euo pipefail
|
|||
|
|
|
|||
|
|
echo "Skipping optional vim and net-tools installation"
|
|||
|
|
EOF
|
|||
|
|
|
|||
|
|
chmod +x scripts/vyos/apt-install.sh
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
The Makefile checks specifically for **local-vyos-1.5.pkrvars.hcl**, not merely **local.pkrvars.hcl**, so create it
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
cat > local-vyos-1.5.pkrvars.hcl <<EOF
|
|||
|
|
ssh_username = "vyos"
|
|||
|
|
ssh_password = "vyos"
|
|||
|
|
|
|||
|
|
# Exact ISO basename without ".iso"
|
|||
|
|
vm_name = "${VM_NAME}"
|
|||
|
|
|
|||
|
|
# Causes scripts/vyos/platform-qemu.sh to install qemu-guest-agent
|
|||
|
|
platform = "qemu"
|
|||
|
|
|
|||
|
|
# Keep and configure the VyOS-patched Cloud-Init from the Stream ISO
|
|||
|
|
cloud_init = "vyos"
|
|||
|
|
|
|||
|
|
# Allow Proxmox NoCloud and ConfigDrive sources
|
|||
|
|
cloud_init_datasource = "nocloud_configdrive"
|
|||
|
|
|
|||
|
|
# Stream 2026.03 belongs to the Circinus/1.5 generation
|
|||
|
|
vyos_release = "circinus"
|
|||
|
|
|
|||
|
|
# Serial console for Proxmox
|
|||
|
|
grub_serial = 1
|
|||
|
|
|
|||
|
|
# Automated build without VNC
|
|||
|
|
headless = true
|
|||
|
|
|
|||
|
|
# Size in MB: 10 GiB
|
|||
|
|
disk_size = 10240
|
|||
|
|
EOF
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
Create a minimal .env
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
cat > .env <<'EOF'
|
|||
|
|
PACKER_LOG=1
|
|||
|
|
PARALLEL_BUILDS=1
|
|||
|
|
SLEEP_BEFORE_SHUTDOWN=0
|
|||
|
|
|
|||
|
|
# Leave these unset so Packer selects available ports.
|
|||
|
|
# VNC_PORT_FIXED=
|
|||
|
|
# HOST_PORT_FIXED=
|
|||
|
|
EOF
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
Initialize Packer. The target initializes the QEMU plugin for all supported templates
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
make init
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
Optional validation
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
packer validate \
|
|||
|
|
-var-file=local-vyos-1.5.pkrvars.hcl \
|
|||
|
|
vyos-image1-1.5.pkr.hcl
|
|||
|
|
|
|||
|
|
packer validate \
|
|||
|
|
-var-file=local-vyos-1.5.pkrvars.hcl \
|
|||
|
|
vyos-image2-1.5.pkr.hcl
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
Build stage one
|
|||
|
|
|
|||
|
|
make build1-1.5
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|