HashiCorp Packer templates for building VyOS images.
packer-vyos builds customized VyOS images from an official VyOS ISO. It runs
the standard VyOS installer in a QEMU VM, applies configuration using the normal
set / commit workflow, and writes out a reusable qcow2 image.
The project is intended for DevOps users who already understand Packer and want a repeatable way to produce VyOS images for QEMU-compatible environments, including Proxmox, Vagrant, VirtualBox, VMware, cloud platforms, and local labs.
Use packer-vyos when you want to:
- build a reusable VyOS
qcow2image from an ISO; - customize the image before first boot;
- install extra packages or agents;
- prepare an image for cloud-init;
- produce images for multiple virtualization targets using Packer.
If you want to build VyOS itself from source, use
vyos-build.
- You provide a VyOS ISO: LTS, rolling/nightly, or one built locally with
vyos-build. - Packer boots the ISO in a QEMU VM.
- The boot/login flow is driven over the console using the default
vyos/vyoscredentials. - The installer is run with
install image. - Base networking is configured, typically with DHCP on
eth0. - Customization scripts under
scripts/vyos/are executed according tovyos.pkr.hcl. - Optional packages, agents, cloud-init support, and cleanup steps are applied.
- The final image is written under
output-*/and copied toiso/as a reusableqcow2.
When headless=false, Packer exposes a VNC server so you can watch or debug
the installer.
- Build VyOS images from official, rolling, or locally built ISOs
- Two-stage build flow: install first, customize second
- Add or remove Debian apt sources before installation
- Install custom packages with
apt - Install cloud-init, either upstream Debian or VyOS-patched variants
- Run arbitrary shell or VyOS commands during customization
- Prepare images for cloud or template usage
- Install
qemu-guest-agentand other virtualization agents - Configure GRUB for KVM and serial console usage
- Toggle SSH and DHCP
- Configure interface address and default gateway
- Keep or replace the default
vyos/vyoscredentials - Tune disk size and output image name
- Use the same Packer workflow for QEMU and other compatible builders
pyvyos— Python SDK for the VyOS HTTPS API. Useful after the image boots, for automated configuration or testing.vyos-build— official VyOS build system for building VyOS images from source.vyos-vm-images— Ansible-based VyOS VM image build automation. Archived in May 2024 and now read-only.
- Linux host with hardware virtualization.
- QEMU/KVM support.
- Packer.
make.- A VyOS ISO.
This project is developed and tested on Ubuntu 24.04 LTS. Debian should also work. Other distributions may work but are not the primary target.
Check that hardware virtualization is available:
egrep '(vmx|svm)' /proc/cpuinfoIf running inside a Proxmox VM, enable host CPU passthrough so nested virtualization is available:
qm set <vmid> --cpu hostFor production builds, run on a dedicated Linux build host or a dedicated VM with nested virtualization enabled.
On Debian/Ubuntu:
apt install make qemu-systemFor graphical debugging with VNC:
apt install tigervnc-viewerFor remote/headless debugging with a virtual X server:
apt install xvfbThe build reads variables from:
local.pkrvars.hcl, if present;- otherwise
vyos.pkrvars.hcl; .env, if present.
Use example.env as the starting point for environment variables.
cp example.env .envEdit .env and the relevant .pkrvars.hcl file before building.
Run once before the first build:
make initTo upgrade Packer plugins:
make upgradeThe build has two stages:
build1-*: boots the VyOS ISO and runsinstall image;build2-*: boots the installed disk image and applies customization.
Examples:
make build1-1.3 && make build2-1.3
make build1-1.4 && make build2-1.4
make build1-1.5 && make build2-1.5Generated files:
iso/vyos-X.Y.iso
iso/vyos-X.Y.qcow2
iso/SHA256SUM
packer-vyos can build from:
- VyOS LTS ISOs, available through a commercial subscription;
- VyOS rolling/nightly builds;
- locally built ISOs from
vyos-build.
Common release branches:
equuleus/ 1.3sagitta/ 1.4circinus/ 1.5current
headless=true is the recommended default for automated builds.
Set headless=false when you want to watch the installer through VNC.
For local debugging, install a VNC client:
apt install tigervnc-viewerFor remote or headless hosts, start an X server with Xvfb and forward X11
over SSH:
ssh -X user@host
# or
ssh -Y user@hostStart the virtual X server:
make x11serverTo attach a VNC viewer automatically, edit vnc-connect.sh and set a fixed
VNC port in .env:
VNC_PORT_FIXED=5900For SSH access into the temporary VM during a build, hold the VM after scripts finish:
SLEEP_BEFORE_SHUTDOWN=600
HOST_PORT_FIXED=2222Then connect with:
ssh vyos@127.0.0.1 -p 2222Default credentials are:
username: vyos
password: vyos
- The generated image may contain credentials or configuration from your local build variables. Treat build artifacts as sensitive.
- Do not publish customized images without reviewing the generated configuration.
- Use
local.pkrvars.hclfor machine-local overrides and keep it out of git. - Prefer
headless=truefor repeatable automated builds.