summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile121
-rw-r--r--README.md38
-rw-r--r--http/debian_11-vyos.list4
-rw-r--r--http/debian_11.list4
-rw-r--r--http/debian_12-vyos.list9
-rw-r--r--http/debian_12.list16
-rw-r--r--vyos-1.3.pkrvars.hcl56
-rw-r--r--vyos-1.4.pkrvars.hcl56
-rw-r--r--vyos-1.5.pkrvars.hcl56
-rw-r--r--vyos-image1-1.3.pkr.hcl (renamed from vyos-image1.pkr.hcl)6
-rw-r--r--vyos-image1-1.4.pkr.hcl218
-rw-r--r--vyos-image1-1.5.pkr.hcl218
-rw-r--r--vyos-image2-1.3.pkr.hcl (renamed from vyos-image2.pkr.hcl)2
-rw-r--r--vyos-image2-1.4.pkr.hcl261
-rw-r--r--vyos-image2-1.5.pkr.hcl261
15 files changed, 1287 insertions, 39 deletions
diff --git a/Makefile b/Makefile
index 8bcb8b3..e8feee0 100644
--- a/Makefile
+++ b/Makefile
@@ -42,52 +42,135 @@ help:
# endif
-.PHONY: build1
-build1:
+.PHONY: build1-1.3
+build1-1.3:
# if exist local.pkrvars.hcl load it
-ifneq ($(wildcard local.pkrvars.hcl),)
+ifneq ($(wildcard local-vyos-1.3.pkrvars.hcl),)
packer build \
- -var-file=local.pkrvars.hcl \
+ -var-file=local-vyos-1.3.pkrvars.hcl \
-parallel-builds=0 \
- vyos-image1.pkr.hcl
+ vyos-image1-1.3.pkr.hcl
else
packer build \
- -var-file=vyos.pkrvars.hcl \
+ -var-file=vyos-1.3.pkrvars.hcl \
-parallel-builds=0 \
- vyos-image1.pkr.hcl
+ vyos-image1-1.3.pkr.hcl
+endif
+
+.PHONY: build1-1.4
+build1-1.4:
+# if exist local.pkrvars.hcl load it
+ifneq ($(wildcard local-vyos-1.4.pkrvars.hcl),)
+ packer build \
+ -var-file=local-vyos-1.4.pkrvars.hcl \
+ -parallel-builds=0 \
+ vyos-image1-1.4.pkr.hcl
+else
+ packer build \
+ -var-file=vyos-1.4.pkrvars.hcl \
+ -parallel-builds=0 \
+ vyos-image1-1.4.pkr.hcl
endif
-.PHONY: build2
-build2:
- # create a copy of qcow2 - if build2 fail you can run again
+.PHONY: build1-1.5
+build1-1.5:
+# if exist local.pkrvars.hcl load it
+ifneq ($(wildcard local-vyos-1.5.pkrvars.hcl),)
+ packer build \
+ -var-file=local-vyos-1.5.pkrvars.hcl \
+ -parallel-builds=0 \
+ vyos-image1-1.5.pkr.hcl
+else
+ packer build \
+ -var-file=vyos-1.5.pkrvars.hcl \
+ -parallel-builds=0 \
+ vyos-image1-1.5.pkr.hcl
+endif
+
+
+.PHONY: build2-1.3
+build2-1.3:
+# create a copy of qcow2 - if build2 fail you can run again
cp -f $(SRC_QCOW2) $(DST_QCOW2)
cp -f $(SRC_CHECKSUM) $(DST_CHECKSUM)
sed -i 's/$(VM_NAME)-build1.qcow2/$(VM_NAME)-build2.qcow2/' $(DST_CHECKSUM)
cat iso/*.checksum > iso/SHA256SUM
# if exist local.pkrvars.hcl load it
-ifneq ($(wildcard local.pkrvars.hcl),)
+ifneq ($(wildcard local-vyos-1.3.pkrvars.hcl),)
packer build \
- -var-file=local.pkrvars.hcl \
+ -var-file=local-vyos-1.3.pkrvars.hcl \
-parallel-builds=0 \
- vyos-image2.pkr.hcl
+ vyos-image2-1.3.pkr.hcl
else
packer build \
- -var-file=vyos.pkrvars.hcl \
+ -var-file=vyos-1.3.pkrvars.hcl \
-parallel-builds=0 \
- vyos-image2.pkr.hcl
+ vyos-image2-1.3.pkr.hcl
endif
+
+.PHONY: build2-1.4
+build2-1.4:
+# create a copy of qcow2 - if build2 fail you can run again
+ cp -f $(SRC_QCOW2) $(DST_QCOW2)
+ cp -f $(SRC_CHECKSUM) $(DST_CHECKSUM)
+ sed -i 's/$(VM_NAME)-build1.qcow2/$(VM_NAME)-build2.qcow2/' $(DST_CHECKSUM)
+ cat iso/*.checksum > iso/SHA256SUM
+
+# if exist local.pkrvars.hcl load it
+ifneq ($(wildcard local-vyos-1.4.pkrvars.hcl),)
+ packer build \
+ -var-file=local-vyos-1.4.pkrvars.hcl \
+ -parallel-builds=0 \
+ vyos-image2-1.4.pkr.hcl
+else
+ packer build \
+ -var-file=vyos-1.4.pkrvars.hcl \
+ -parallel-builds=0 \
+ vyos-image2-1.4.pkr.hcl
+endif
+
+.PHONY: build2-1.5
+build2-1.5:
+# create a copy of qcow2 - if build2 fail you can run again
+ cp -f $(SRC_QCOW2) $(DST_QCOW2)
+ cp -f $(SRC_CHECKSUM) $(DST_CHECKSUM)
+ sed -i 's/$(VM_NAME)-build1.qcow2/$(VM_NAME)-build2.qcow2/' $(DST_CHECKSUM)
+ cat iso/*.checksum > iso/SHA256SUM
+
+# if exist local.pkrvars.hcl load it
+ifneq ($(wildcard local-vyos-1.5.pkrvars.hcl),)
+ packer build \
+ -var-file=local-vyos-1.5.pkrvars.hcl \
+ -parallel-builds=0 \
+ vyos-image2-1.5.pkr.hcl
+else
+ packer build \
+ -var-file=vyos-1.5.pkrvars.hcl \
+ -parallel-builds=0 \
+ vyos-image2-1.5.pkr.hcl
+endif
+
+
.PHONY: init
init:
- packer init vyos-image1.pkr.hcl
- packer init vyos-image2.pkr.hcl
+ packer init vyos-image1-1.3.pkr.hcl
+ packer init vyos-image1-1.4.pkr.hcl
+ packer init vyos-image1-1.5.pkr.hcl
+ packer init vyos-image2-1.3.pkr.hcl
+ packer init vyos-image2-1.4.pkr.hcl
+ packer init vyos-image2-1.5.pkr.hcl
.PHONY: upgrade
upgrade:
- packer init -upgrade vyos-image1.pkr.hcl
- packer init -upgrade vyos-image2.pkr.hcl
+ packer init -upgrade vyos-image1-1.3.pkr.hcl
+ packer init -upgrade vyos-image1-1.4.pkr.hcl
+ packer init -upgrade vyos-image1-1.5.pkr.hcl
+ packer init -upgrade vyos-image2-1.3.pkr.hcl
+ packer init -upgrade vyos-image2-1.4.pkr.hcl
+ packer init -upgrade vyos-image2-1.5.pkr.hcl
.PHONY: clean
clean:
diff --git a/README.md b/README.md
index 0263737..e55100d 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
-# Introdution
+# Introduction
As VyOS is becoming more popular, building and automating images are essential. Packer is flexible and
can create custom images easily for any cloud and bare metal needs.
@@ -101,7 +101,7 @@ Use:
* ```make upgrade```, when want to upgrade plugins
## Build images
-* ```make build1```
+* ```make build1-x.x```
* build first stage image
* create a new qcow2 image
* mount iso as cdrom
@@ -111,7 +111,7 @@ Use:
* source: iso/vyos-1.3.6.iso
* output: iso/vyos-1.3.6.qcow2
* checksum: iso/SHA256SUM
-* ```make build2```
+* ```make build2-x.x```
* build second stage image
* use same qcow2 image from first stage
* customize image
@@ -119,4 +119,34 @@ Use:
* source: iso/vyos-1.3.6.qcow2
* output: iso/vyos-1.3.6.qcow2
* checksum: iso/SHA256SUM
- \ No newline at end of file
+
+## Vyos releases supported
+* subscribe to [commercial edition](https://vyos.io/subscriptions/software) and use an LTS iso
+* use [rolling releases](https://vyos.net/get/nightly-builds/)
+* use [vyos-build](https://github.com/vyos/vyos-build) to build an iso from source from desired branch (1.3/equuleus, 1.4/sagitta, 1.5/circinus or current)
+
+### Build instructions for each release
+* common: use ubuntu 24 in a vm with virtualization host cpu instruction to build
+```
+apt update
+# apt install -y make qemu-system # for headless=true
+apt install -y make qemu-system xvfb tigervnc-viewer # for headless=false
+make x11server # will turn on x11 server, you can use headless=false in pkrvars.hcl to build without vnc
+make init # install packer plugins
+```
+
+* 1.3
+```
+make build1-1.3
+make build2-1.3
+```
+* 1.4
+```
+make build1-1.4
+make build2-1.4
+```
+* 1.5
+```
+make build1-1.5
+make build2-1.5
+```
diff --git a/http/debian_11-vyos.list b/http/debian_11-vyos.list
index f91508d..5c94539 100644
--- a/http/debian_11-vyos.list
+++ b/http/debian_11-vyos.list
@@ -1,6 +1,6 @@
# temporary debian list to add debian software
deb http://deb.debian.org/debian buster main contrib non-free
-deb-src http://deb.debian.org/debian buster main contrib non-free
+#deb-src http://deb.debian.org/debian buster main contrib non-free
deb http://security.debian.org/debian-security/ buster/updates main contrib non-free
-deb-src http://security.debian.org/debian-security/ buster/updates main contrib non-free
+#deb-src http://security.debian.org/debian-security/ buster/updates main contrib non-free
deb http://dev.packages.vyos.net/repositories/equuleus equuleus main
diff --git a/http/debian_11.list b/http/debian_11.list
index a791d21..a5315c9 100644
--- a/http/debian_11.list
+++ b/http/debian_11.list
@@ -1,5 +1,5 @@
# temporary debian list to add debian software
deb http://deb.debian.org/debian buster main contrib non-free
-deb-src http://deb.debian.org/debian buster main contrib non-free
+#deb-src http://deb.debian.org/debian buster main contrib non-free
deb http://security.debian.org/debian-security/ buster/updates main contrib non-free
-deb-src http://security.debian.org/debian-security/ buster/updates main contrib non-free
+#deb-src http://security.debian.org/debian-security/ buster/updates main contrib non-free
diff --git a/http/debian_12-vyos.list b/http/debian_12-vyos.list
index 46e7c28..2bbf859 100644
--- a/http/debian_12-vyos.list
+++ b/http/debian_12-vyos.list
@@ -1,6 +1,7 @@
# temporary debian list to add debian software
-deb http://deb.debian.org/debian bookworm main contrib non-free
-deb-src http://deb.debian.org/debian bookworm main contrib non-free
-deb http://security.debian.org/debian-security/ bookworm/updates main contrib non-free
-deb-src http://security.debian.org/debian-security/ bookworm/updates main contrib non-free
+deb http://deb.debian.org/debian bookworm contrib main non-free non-free-firmware
+deb http://deb.debian.org/debian bookworm-updates contrib main non-free non-free-firmware
+# deb http://deb.debian.org/debian bookworm-backports contrib main non-free non-free-firmware
+deb http://deb.debian.org/debian-security bookworm-security contrib main non-free non-free-firmware
+
deb http://dev.packages.vyos.net/repositories/current current main
diff --git a/http/debian_12.list b/http/debian_12.list
index 8dc95b8..22f08cd 100644
--- a/http/debian_12.list
+++ b/http/debian_12.list
@@ -1,5 +1,13 @@
# temporary debian list to add debian software
-deb http://deb.debian.org/debian bookworm main contrib non-free
-deb-src http://deb.debian.org/debian bookworm main contrib non-free
-deb http://security.debian.org/debian-security/ bookworm/updates main contrib non-free
-deb-src http://security.debian.org/debian-security/ bookworm/updates main contrib non-free
+deb http://deb.debian.org/debian bookworm contrib main non-free non-free-firmware
+deb http://deb.debian.org/debian bookworm-updates contrib main non-free non-free-firmware
+# deb http://deb.debian.org/debian bookworm-backports contrib main non-free non-free-firmware
+deb http://deb.debian.org/debian-security bookworm-security contrib main non-free non-free-firmware
+
+
+
+# deb http://deb.debian.org/debian bookworm main contrib non-free
+# deb-src http://deb.debian.org/debian bookworm main contrib non-free
+# deb http://security.debian.org/debian-security/ bookworm/updates main contrib non-free
+# deb-src http://security.debian.org/debian-security/ bookworm/updates main contrib non-free
+
diff --git a/vyos-1.3.pkrvars.hcl b/vyos-1.3.pkrvars.hcl
new file mode 100644
index 0000000..081139a
--- /dev/null
+++ b/vyos-1.3.pkrvars.hcl
@@ -0,0 +1,56 @@
+
+# vars:
+# - .env building vars: control building process
+# - vyos.pkrvars.hcl image vars: define image parameters - git default
+# - local.pkrvars.hcl image vars: define image parameters - clone vyos.pkrvars.hcl to override it locally
+
+
+
+ssh_username = "vyos"
+ssh_password = "vyos"
+
+# same as file name without .iso
+vm_name = "vyos-1.3.7-amd64"
+
+# platform = "none" # will not install any specific platform
+# - qemu will install qemu-guest-agent
+platform = "qemu"
+
+# cloud-init values:
+# debian - will install/replace cloud-init packages
+# vyos - will keep cloud-init packages from vyos
+# comment - don't install cloud-init at all
+cloud_init = "debian"
+
+# which kind of datasource should be used
+# nocloud_configdrive => use this as default, will turn on NoCloud, ConfigDrive on cloud-init datasource_list
+# blank - don't set default datasource_list
+cloud_init_datasource = "nocloud_configdrive"
+
+# Set grub_serial=1 to turn grub default=1, ie: use serial console. it is need to adjust on hypervisor
+#
+# for proxmox:
+# qm set 9000 --serial0 socket --vga serial0
+grub_serial = 1
+
+# equuleus: debian 11 (branch 1.3.*)
+# sagitta: debian 12 (branch 1.4.*)
+# circinus: debian 12 (branch 1.5.*)
+# current: debian 12 (branch 1.5.*)
+vyos_release = "equuleus"
+
+# false will start vnc for console
+headless = false
+
+# in MB (10GB x 1024 = 10240, minimum 2048)
+disk_size = 2048
+
+
+
+# todo:
+# - disable/enable ssh
+# - disable/enable dhcp
+# - set interface/gateway
+# - keep vyos/vyos user/password or customize it
+# - customize to install any other agent or package as needed like
+# extra_packages = [] \ No newline at end of file
diff --git a/vyos-1.4.pkrvars.hcl b/vyos-1.4.pkrvars.hcl
new file mode 100644
index 0000000..fd23206
--- /dev/null
+++ b/vyos-1.4.pkrvars.hcl
@@ -0,0 +1,56 @@
+
+# vars:
+# - .env building vars: control building process
+# - vyos.pkrvars.hcl image vars: define image parameters - git default
+# - local.pkrvars.hcl image vars: define image parameters - clone vyos.pkrvars.hcl to override it locally
+
+
+
+ssh_username = "vyos"
+ssh_password = "vyos"
+
+# same as file name without .iso
+vm_name = "vyos-1.4.0-epa3-amd64"
+
+# platform = "none" # will not install any specific platform
+# - qemu will install qemu-guest-agent
+platform = "qemu"
+
+# cloud-init values:
+# debian - will install/replace cloud-init packages
+# vyos - will keep cloud-init packages from vyos
+# comment - don't install cloud-init at all
+cloud_init = "debian"
+
+# which kind of datasource should be used
+# nocloud_configdrive => use this as default, will turn on NoCloud, ConfigDrive on cloud-init datasource_list
+# blank - don't set default datasource_list
+cloud_init_datasource = "nocloud_configdrive"
+
+# Set grub_serial=1 to turn grub default=1, ie: use serial console. it is need to adjust on hypervisor
+#
+# for proxmox:
+# qm set 9000 --serial0 socket --vga serial0
+grub_serial = 1
+
+# equuleus: debian 11 (branch 1.3.*)
+# sagitta: debian 12 (branch 1.4.*)
+# circinus: debian 12 (branch 1.5.*)
+# current: debian 12 (branch 1.5.*)
+vyos_release = "sagitta"
+
+# false will start vnc for console
+headless = false
+
+# in MB (10GB x 1024 = 10240, minimum 2048)
+disk_size = 2048
+
+
+
+# todo:
+# - disable/enable ssh
+# - disable/enable dhcp
+# - set interface/gateway
+# - keep vyos/vyos user/password or customize it
+# - customize to install any other agent or package as needed like
+# extra_packages = [] \ No newline at end of file
diff --git a/vyos-1.5.pkrvars.hcl b/vyos-1.5.pkrvars.hcl
new file mode 100644
index 0000000..e9b6127
--- /dev/null
+++ b/vyos-1.5.pkrvars.hcl
@@ -0,0 +1,56 @@
+
+# vars:
+# - .env building vars: control building process
+# - vyos.pkrvars.hcl image vars: define image parameters - git default
+# - local.pkrvars.hcl image vars: define image parameters - clone vyos.pkrvars.hcl to override it locally
+
+
+
+ssh_username = "vyos"
+ssh_password = "vyos"
+
+# same as file name without .iso
+vm_name = "vyos-1.5-rolling-202405140019-amd64"
+
+# platform = "none" # will not install any specific platform
+# - qemu will install qemu-guest-agent
+platform = "qemu"
+
+# cloud-init values:
+# debian - will install/replace cloud-init packages
+# vyos - will keep cloud-init packages from vyos
+# comment - don't install cloud-init at all
+cloud_init = "debian"
+
+# which kind of datasource should be used
+# nocloud_configdrive => use this as default, will turn on NoCloud, ConfigDrive on cloud-init datasource_list
+# blank - don't set default datasource_list
+cloud_init_datasource = "nocloud_configdrive"
+
+# Set grub_serial=1 to turn grub default=1, ie: use serial console. it is need to adjust on hypervisor
+#
+# for proxmox:
+# qm set 9000 --serial0 socket --vga serial0
+grub_serial = 1
+
+# equuleus: debian 11 (branch 1.3.*)
+# sagitta: debian 12 (branch 1.4.*)
+# circinus: debian 12 (branch 1.5.*)
+# current: debian 12 (branch 1.5.*)
+vyos_release = "circinus"
+
+# false will start vnc for console
+headless = false
+
+# in MB (10GB x 1024 = 10240, minimum 2048)
+disk_size = 2048
+
+
+
+# todo:
+# - disable/enable ssh
+# - disable/enable dhcp
+# - set interface/gateway
+# - keep vyos/vyos user/password or customize it
+# - customize to install any other agent or package as needed like
+# extra_packages = [] \ No newline at end of file
diff --git a/vyos-image1.pkr.hcl b/vyos-image1-1.3.pkr.hcl
index fc45a66..6d2d0ab 100644
--- a/vyos-image1.pkr.hcl
+++ b/vyos-image1-1.3.pkr.hcl
@@ -88,7 +88,7 @@ variable "sleep_before_shutdown" {
# this is actually boot time between grub and user login. Need to be increased if your system in heavy load. A wait time too long will increase build time.
variable "sleep_after_grub" {
- default = "45" # in seconds
+ default = "60" # in seconds
}
# set grub_serial=1 to turn grub default=1, ie: use serial console. it is need to adjust on hypervisor
@@ -125,7 +125,7 @@ source "qemu" "vyos" {
"<enter><wait2s>",
"${var.ssh_password}<enter><wait>",
"${var.ssh_password}<enter><wait>",
- "<enter><wait5s>",
+ "<enter><wait10s>", # wait 10 seconds before reboot (dev purposes)
]
accelerator = "kvm"
@@ -215,4 +215,4 @@ build {
]
}
}
-} \ No newline at end of file
+}
diff --git a/vyos-image1-1.4.pkr.hcl b/vyos-image1-1.4.pkr.hcl
new file mode 100644
index 0000000..d8c0186
--- /dev/null
+++ b/vyos-image1-1.4.pkr.hcl
@@ -0,0 +1,218 @@
+packer {
+ required_plugins {
+ qemu = {
+ version = "~> 1"
+ source = "github.com/hashicorp/qemu"
+ }
+ }
+}
+
+# dont edit those vars below, customize in local.auto.pkrvars.hcl using local.example.pkrvars.hcl
+variable "vm_name" {
+ default = "vyos-1.3.6"
+}
+
+variable "numvcpus" {
+ default = "4"
+}
+
+variable "memsize" {
+ default = "2048"
+}
+
+variable "disk_size" {
+ default = "10240"
+}
+
+variable "iso_checksum" {
+ default = "file:iso/SHA256SUM"
+}
+
+variable "ssh_username" {
+ default = "vyos"
+}
+
+variable "ssh_password" {
+ default = "vyos"
+}
+
+variable "boot_wait" {
+ default = "5s"
+}
+
+# - qemu: will build qcow2 image
+# - none: not supported
+variable "platform" {
+ type = string
+ default = "qemu"
+}
+
+# cloud-init values:
+# debian - will install/replace cloud-init packages
+# vyos - will keep cloud-init packages from vyos
+variable "cloud_init" {
+ type = string
+ default = "vyos"
+}
+
+# equuleus: debian 11 (branch 1.3.*)
+# sagitta: debian 12 (branch 1.4.*)
+# circinus: debian 12 (branch 1.5.*)
+# current: debian 12 (branch 1.5.*)
+variable "vyos_release" {
+ default = "sagitta"
+}
+
+# build will fail if headless is false, only use headless false if you prepared X11/vnc setup
+variable "headless" {
+ default = true
+}
+
+variable "host_port_min" {
+ default = env("HOST_PORT_FIXED") != "" ? env("HOST_PORT_FIXED") : 2222
+}
+variable "host_port_max" {
+ default = env("HOST_PORT_FIXED") != "" ? env("HOST_PORT_FIXED") : 4444
+}
+
+variable "vnc_port_min" {
+ default = env("VNC_PORT_FIXED") != "" ? env("VNC_PORT_FIXED") : 5900
+}
+variable "vnc_port_max" {
+ default = env("VNC_PORT_FIXED") != "" ? env("VNC_PORT_FIXED") : 6000
+}
+
+variable "sleep_before_shutdown" {
+ default = env("SLEEP_BEFORE_SHUTDOWN") != "" ? env("SLEEP_BEFORE_SHUTDOWN") : 0
+}
+
+# this is actually boot time between grub and user login. Need to be increased if your system in heavy load. A wait time too long will increase build time.
+variable "sleep_after_grub" {
+ default = "60" # in seconds
+}
+
+# set grub_serial=1 to turn grub default=1, ie: use serial console. it is need to adjust on hypervisor
+variable "grub_serial" {
+ type = string
+ default = 1
+}
+
+locals {
+ iso_path = "iso/${var.vm_name}.iso"
+ output_dir = "output/vyos-image1/${regex_replace(timestamp(), "[: ]", "-")}"
+}
+
+source "qemu" "vyos" {
+ boot_command = [
+ "<enter>",
+ "<wait${var.sleep_after_grub}s>",
+ "${var.ssh_username}<enter><wait>",
+ "${var.ssh_password}<enter><wait>",
+ "configure<enter><wait>",
+ "set interfaces ethernet eth0 address 'dhcp'<enter><wait>",
+ "set system name-server '8.8.8.8'<enter><wait>",
+ "set service ssh port '22'<enter><wait>",
+ "commit<enter><wait2s>",
+ "save<enter><wait2s>",
+ "exit<enter><wait1s>",
+ "install image<enter><wait3s>",
+ "Yes<enter><wait3s>", # would like to continue
+ "<enter><wait3s>", # name of this image, using default
+ "${var.ssh_password}<enter><wait>",
+ "${var.ssh_password}<enter><wait>",
+ "K<enter><wait3s>", # which console kvm=K or serial=S
+ "<enter><wait2s>", # disk name using default (vda)
+ "Y<enter><wait3s>", # will delete all data, continue=Y
+ "Y<enter><wait3s>", # will use all free space, continue=Y
+ "1<enter><wait3s>", # which file to use as boot, using first one=1
+ "<enter><wait10s>", # wait 10 seconds before reboot (dev purposes)
+ ]
+
+ accelerator = "kvm"
+
+ iso_checksum = var.iso_checksum
+ iso_url = local.iso_path
+
+ boot_wait = var.boot_wait
+
+ http_directory = "http"
+
+ shutdown_command = "sleep ${var.sleep_before_shutdown}; sudo shutdown -P now"
+
+ communicator = "ssh"
+
+ host_port_min = var.host_port_min
+ host_port_max = var.host_port_max
+
+ ssh_username = var.ssh_username
+ ssh_password = var.ssh_password
+
+ ssh_timeout = "30m"
+
+ memory = var.memsize
+ cpus = var.numvcpus
+ disk_size = var.disk_size
+
+ vnc_port_min = var.vnc_port_min
+ vnc_port_max = var.vnc_port_max
+
+ headless = var.headless
+
+ output_directory = "${local.output_dir}"
+
+ net_device = "virtio-net"
+ disk_interface = "virtio"
+
+ qemuargs = [
+ ["-m", "2048"],
+ ["-smp", "4"],
+ ["-cpu", "host"],
+ ["-netdev", "user,id=user.0,", "hostfwd=tcp::{{ .SSHHostPort }}-:22"],
+ ["-device", "virtio-net,netdev=user.0"]
+ ]
+}
+
+build {
+ name = "vyos"
+
+ source "source.qemu.vyos" {
+ name = "vyos_qemu_qcow2"
+ vm_name = "${var.vm_name}-${source.name}.qcow2"
+ format = "qcow2"
+ }
+
+ provisioner "shell-local" {
+ inline = [
+ "mkdir -p iso/",
+ "mkdir -p ${local.output_dir}"
+ ]
+ }
+
+ # checksum
+ post-processors {
+ post-processor "checksum" {
+ checksum_types = ["sha256"]
+ keep_input_artifact = true
+ }
+
+ post-processor "shell-local" {
+ inline = [
+ "mv packer_vyos_qemu_sha256.checksum iso/${var.vm_name}-build1.qcow2.checksum.tmp",
+ "awk '{print $1, \" ${var.vm_name}-build1.qcow2\"}' iso/${var.vm_name}-build1.qcow2.checksum.tmp > iso/${var.vm_name}-build1.qcow2.checksum",
+ "rm -f iso/${var.vm_name}-build1.qcow2.checksum.tmp",
+ "cat iso/*.checksum > iso/SHA256SUM",
+ "echo '${var.vm_name}' > .vm_name"
+ ]
+ }
+ }
+
+ # copy from output to iso/ for vyos-image2.pkr.hcl customize
+ post-processors {
+ post-processor "shell-local" {
+ inline = [
+ "cp '${local.output_dir}/${var.vm_name}-${source.name}.qcow2' iso/${var.vm_name}-build1.qcow2",
+ "rm -rf '${local.output_dir}'"
+ ]
+ }
+ }
+}
diff --git a/vyos-image1-1.5.pkr.hcl b/vyos-image1-1.5.pkr.hcl
new file mode 100644
index 0000000..8b603b4
--- /dev/null
+++ b/vyos-image1-1.5.pkr.hcl
@@ -0,0 +1,218 @@
+packer {
+ required_plugins {
+ qemu = {
+ version = "~> 1"
+ source = "github.com/hashicorp/qemu"
+ }
+ }
+}
+
+# dont edit those vars below, customize in local.auto.pkrvars.hcl using local.example.pkrvars.hcl
+variable "vm_name" {
+ default = "vyos-1.3.6"
+}
+
+variable "numvcpus" {
+ default = "4"
+}
+
+variable "memsize" {
+ default = "2048"
+}
+
+variable "disk_size" {
+ default = "10240"
+}
+
+variable "iso_checksum" {
+ default = "file:iso/SHA256SUM"
+}
+
+variable "ssh_username" {
+ default = "vyos"
+}
+
+variable "ssh_password" {
+ default = "vyos"
+}
+
+variable "boot_wait" {
+ default = "5s"
+}
+
+# - qemu: will build qcow2 image
+# - none: not supported
+variable "platform" {
+ type = string
+ default = "qemu"
+}
+
+# cloud-init values:
+# debian - will install/replace cloud-init packages
+# vyos - will keep cloud-init packages from vyos
+variable "cloud_init" {
+ type = string
+ default = "vyos"
+}
+
+# equuleus: debian 11 (branch 1.3.*)
+# sagitta: debian 12 (branch 1.4.*)
+# circinus: debian 12 (branch 1.5.*)
+# current: debian 12 (branch 1.5.*)
+variable "vyos_release" {
+ default = "circinus"
+}
+
+# build will fail if headless is false, only use headless false if you prepared X11/vnc setup
+variable "headless" {
+ default = true
+}
+
+variable "host_port_min" {
+ default = env("HOST_PORT_FIXED") != "" ? env("HOST_PORT_FIXED") : 2222
+}
+variable "host_port_max" {
+ default = env("HOST_PORT_FIXED") != "" ? env("HOST_PORT_FIXED") : 4444
+}
+
+variable "vnc_port_min" {
+ default = env("VNC_PORT_FIXED") != "" ? env("VNC_PORT_FIXED") : 5900
+}
+variable "vnc_port_max" {
+ default = env("VNC_PORT_FIXED") != "" ? env("VNC_PORT_FIXED") : 6000
+}
+
+variable "sleep_before_shutdown" {
+ default = env("SLEEP_BEFORE_SHUTDOWN") != "" ? env("SLEEP_BEFORE_SHUTDOWN") : 0
+}
+
+# this is actually boot time between grub and user login. Need to be increased if your system in heavy load. A wait time too long will increase build time.
+variable "sleep_after_grub" {
+ default = "60" # in seconds
+}
+
+# set grub_serial=1 to turn grub default=1, ie: use serial console. it is need to adjust on hypervisor
+variable "grub_serial" {
+ type = string
+ default = 1
+}
+
+locals {
+ iso_path = "iso/${var.vm_name}.iso"
+ output_dir = "output/vyos-image1/${regex_replace(timestamp(), "[: ]", "-")}"
+}
+
+source "qemu" "vyos" {
+ boot_command = [
+ "<enter>",
+ "<wait${var.sleep_after_grub}s>",
+ "${var.ssh_username}<enter><wait>",
+ "${var.ssh_password}<enter><wait>",
+ "configure<enter><wait>",
+ "set interfaces ethernet eth0 address 'dhcp'<enter><wait>",
+ "set system name-server '8.8.8.8'<enter><wait>",
+ "set service ssh port '22'<enter><wait>",
+ "commit<enter><wait2s>",
+ "save<enter><wait2s>",
+ "exit<enter><wait1s>",
+ "install image<enter><wait3s>",
+ "Yes<enter><wait3s>", # would like to continue
+ "<enter><wait3s>", # name of this image, using default
+ "${var.ssh_password}<enter><wait>",
+ "${var.ssh_password}<enter><wait>",
+ "K<enter><wait3s>", # which console kvm=K or serial=S
+ "<enter><wait2s>", # disk name using default (vda)
+ "Y<enter><wait3s>", # will delete all data, continue=Y
+ "Y<enter><wait3s>", # will use all free space, continue=Y
+ "1<enter><wait3s>", # which file to use as boot, using first one=1
+ "<enter><wait10s>", # wait 10 seconds before reboot (dev purposes)
+ ]
+
+ accelerator = "kvm"
+
+ iso_checksum = var.iso_checksum
+ iso_url = local.iso_path
+
+ boot_wait = var.boot_wait
+
+ http_directory = "http"
+
+ shutdown_command = "sleep ${var.sleep_before_shutdown}; sudo shutdown -P now"
+
+ communicator = "ssh"
+
+ host_port_min = var.host_port_min
+ host_port_max = var.host_port_max
+
+ ssh_username = var.ssh_username
+ ssh_password = var.ssh_password
+
+ ssh_timeout = "30m"
+
+ memory = var.memsize
+ cpus = var.numvcpus
+ disk_size = var.disk_size
+
+ vnc_port_min = var.vnc_port_min
+ vnc_port_max = var.vnc_port_max
+
+ headless = var.headless
+
+ output_directory = "${local.output_dir}"
+
+ net_device = "virtio-net"
+ disk_interface = "virtio"
+
+ qemuargs = [
+ ["-m", "2048"],
+ ["-smp", "4"],
+ ["-cpu", "host"],
+ ["-netdev", "user,id=user.0,", "hostfwd=tcp::{{ .SSHHostPort }}-:22"],
+ ["-device", "virtio-net,netdev=user.0"]
+ ]
+}
+
+build {
+ name = "vyos"
+
+ source "source.qemu.vyos" {
+ name = "vyos_qemu_qcow2"
+ vm_name = "${var.vm_name}-${source.name}.qcow2"
+ format = "qcow2"
+ }
+
+ provisioner "shell-local" {
+ inline = [
+ "mkdir -p iso/",
+ "mkdir -p ${local.output_dir}"
+ ]
+ }
+
+ # checksum
+ post-processors {
+ post-processor "checksum" {
+ checksum_types = ["sha256"]
+ keep_input_artifact = true
+ }
+
+ post-processor "shell-local" {
+ inline = [
+ "mv packer_vyos_qemu_sha256.checksum iso/${var.vm_name}-build1.qcow2.checksum.tmp",
+ "awk '{print $1, \" ${var.vm_name}-build1.qcow2\"}' iso/${var.vm_name}-build1.qcow2.checksum.tmp > iso/${var.vm_name}-build1.qcow2.checksum",
+ "rm -f iso/${var.vm_name}-build1.qcow2.checksum.tmp",
+ "cat iso/*.checksum > iso/SHA256SUM",
+ "echo '${var.vm_name}' > .vm_name"
+ ]
+ }
+ }
+
+ # copy from output to iso/ for vyos-image2.pkr.hcl customize
+ post-processors {
+ post-processor "shell-local" {
+ inline = [
+ "cp '${local.output_dir}/${var.vm_name}-${source.name}.qcow2' iso/${var.vm_name}-build1.qcow2",
+ "rm -rf '${local.output_dir}'"
+ ]
+ }
+ }
+}
diff --git a/vyos-image2.pkr.hcl b/vyos-image2-1.3.pkr.hcl
index a3b0c95..55d913c 100644
--- a/vyos-image2.pkr.hcl
+++ b/vyos-image2-1.3.pkr.hcl
@@ -122,7 +122,7 @@ source "qemu" "vyos" {
"set service ssh port '22'<enter><wait>",
"commit<enter><wait>",
"save<enter><wait>",
- "exit<enter><wait10s>",
+ "exit<enter><wait10s>", # wait 10 seconds before reboot (dev purposes)
]
accelerator = "kvm"
diff --git a/vyos-image2-1.4.pkr.hcl b/vyos-image2-1.4.pkr.hcl
new file mode 100644
index 0000000..58bc9c5
--- /dev/null
+++ b/vyos-image2-1.4.pkr.hcl
@@ -0,0 +1,261 @@
+packer {
+ required_plugins {
+ qemu = {
+ version = "~> 1"
+ source = "github.com/hashicorp/qemu"
+ }
+ }
+}
+
+
+# dont edit those vars below, customize in local.auto.pkrvars.hcl using local.example.pkrvars.hcl
+variable "vm_name" {
+ default = "vyos-image-1.3.6"
+}
+
+variable "numvcpus" {
+ default = "4"
+}
+
+variable "memsize" {
+ default = "2048"
+}
+
+variable "disk_size" {
+ default = "1024"
+}
+
+variable "iso_checksum" {
+ default = "file:iso/SHA256SUM"
+}
+
+variable "ssh_username" {
+ default = "vyos"
+}
+
+variable "ssh_password" {
+ default = "vyos"
+}
+
+variable "boot_wait" {
+ default = "5s"
+}
+
+# - qemu: will build qcow2 image
+# - none: not supported
+variable "platform" {
+ type = string
+ default = "qemu"
+}
+
+# cloud-init values:
+# debian - will install/replace cloud-init packages
+# vyos - will keep cloud-init packages from vyos
+variable "cloud_init" {
+ type = string
+ default = "vyos"
+}
+
+# equuleus: debian 11 (branch 1.3.*)
+# sagitta: debian 12 (branch 1.4.*)
+# circinus: debian 12 (branch 1.5.*)
+# current: debian 12 (branch 1.5.*)
+variable "vyos_release" {
+ default = "sagitta"
+}
+
+# build will fail if headless is false, only use headless false if you prepared X11/vnc setup
+variable "headless" {
+ default = true
+}
+
+variable "host_port_min" {
+ default = env("HOST_PORT_FIXED") != "" ? env("HOST_PORT_FIXED") : 2222
+}
+variable "host_port_max" {
+ default = env("HOST_PORT_FIXED") != "" ? env("HOST_PORT_FIXED") : 4444
+}
+
+variable "vnc_port_min" {
+ default = env("VNC_PORT_FIXED") != "" ? env("VNC_PORT_FIXED") : 5900
+}
+variable "vnc_port_max" {
+ default = env("VNC_PORT_FIXED") != "" ? env("VNC_PORT_FIXED") : 6000
+}
+
+variable "sleep_before_shutdown" {
+ default = env("SLEEP_BEFORE_SHUTDOWN") != "" ? env("SLEEP_BEFORE_SHUTDOWN") : 0
+}
+
+# this is actually boot time between grub and user login. Need to be increased if your system in heavy load. A wait time too long will increase build time.
+variable "sleep_after_grub" {
+ default = "45" # in seconds
+}
+
+# set grub_serial=1 to turn grub default=1, ie: use serial console. it is need to adjust on hypervisor
+variable "grub_serial" {
+ type = string
+ default = 1
+}
+
+# which kind of datasource should be used
+# nocloud_configdrive => use this as default, will turn on NoCloud, ConfigDrive on cloud-init datasource_list
+# blank - don't set default datasource_list
+variable "cloud_init_datasource" {
+ default = "nocloud_configdrive"
+}
+
+locals {
+ iso_path = "iso/${var.vm_name}-build2.qcow2" # not used at all since qemuargs -drive override it
+ output_dir = "output/vyos-image2/${regex_replace(timestamp(), "[: ]", "-")}"
+}
+
+source "qemu" "vyos" {
+ boot_command = [
+ "<wait2s><enter>",
+ "<wait${var.sleep_after_grub}s>",
+ "${var.ssh_username}<enter><wait>",
+ "${var.ssh_password}<enter><wait>",
+ "configure<enter><wait>",
+ "set interfaces ethernet eth0 address 'dhcp'<enter><wait>",
+ "set system name-server '8.8.8.8'<enter><wait>",
+ "set service ssh port '22'<enter><wait>",
+ "commit<enter><wait>",
+ "save<enter><wait>",
+ "exit<enter><wait10s>", # wait 10 seconds before reboot (dev purposes)
+ ]
+
+ accelerator = "kvm"
+
+ iso_checksum = var.iso_checksum
+ iso_url = local.iso_path # not used at all since qemuargs -drive override it
+
+ boot_wait = var.boot_wait
+
+ http_directory = "http"
+
+ shutdown_command = "sleep ${var.sleep_before_shutdown}; sudo shutdown -P now"
+
+ communicator = "ssh"
+
+ host_port_min = var.host_port_min
+ host_port_max = var.host_port_max
+
+ ssh_username = var.ssh_username
+ ssh_password = var.ssh_password
+
+ ssh_timeout = "30m"
+
+ memory = var.memsize
+ cpus = var.numvcpus
+ disk_size = var.disk_size
+
+ vnc_port_min = var.vnc_port_min
+ vnc_port_max = var.vnc_port_max
+
+ headless = var.headless
+
+ output_directory = "${local.output_dir}"
+
+ net_device = "virtio-net"
+ disk_interface = "virtio"
+
+ qemuargs = [
+ ["-m", "2048"],
+ ["-smp", "4"],
+ ["-cpu", "host"],
+ ["-netdev", "user,id=user.0,", "hostfwd=tcp::{{ .SSHHostPort }}-:22"],
+ ["-device", "virtio-net,netdev=user.0"],
+ #["-drive", "file=iso/${var.vm_name}.qcow2,if=virtio,cache=writeback,discard=ignore,format=qcow2"]
+ #["-drive", "file=iso/${var.vm_name}.qcow2,if=none,id=drive-virtio0,format=qcow2,cache=writeback,aio=io_uring,detect-zeroes=on"]
+ ["-drive", "file=iso/${var.vm_name}-build2.qcow2,if=virtio,cache=writeback,format=qcow2,aio=io_uring,detect-zeroes=on"]
+ ]
+}
+
+build {
+ name = "vyos"
+
+ source "source.qemu.vyos" {
+ name = "vyos_qemu_qcow2"
+ vm_name = "${var.vm_name}-${source.name}.qcow2"
+ format = "qcow2"
+ }
+
+ provisioner "shell-local" {
+ inline = [
+ "mkdir -p ${local.output_dir}"
+ ]
+ }
+
+ # preparing provisioner
+ provisioner "shell" {
+ execute_command = "VYOS_RELEASE='${var.vyos_release}' {{ .Vars }} sudo -E bash '{{ .Path }}'"
+ scripts = [
+ "scripts/vyos/init.sh",
+ ]
+ }
+
+ # configure vyos
+ provisioner "shell" {
+ execute_command = "VYOS_RELEASE='${var.vyos_release}' {{ .Vars }} sudo -E bash '{{ .Path }}'"
+ scripts = [
+ "scripts/vyos/configure.sh",
+ ]
+ }
+
+ # installing apt repos and custom packages
+ provisioner "shell" {
+ execute_command = "VYOS_RELEASE='${var.vyos_release}' CLOUD_INIT='${var.cloud_init}' {{ .Vars }} sudo -E bash '{{ .Path }}'"
+ scripts = [
+ "scripts/vyos/apt-repo-debian.sh",
+ "scripts/vyos/apt-repo-vyos.sh",
+ "scripts/vyos/apt-install.sh",
+ ]
+ }
+
+ # preparing cloud-init
+ provisioner "shell" {
+ execute_command = "VYOS_RELEASE='${var.vyos_release}' CLOUD_INIT='${var.cloud_init}' CLOUD_INIT_DATASOURCE='${var.cloud_init_datasource}' {{ .Vars }} sudo -E bash '{{ .Path }}'"
+ scripts = [
+ "scripts/vyos/cloud-init-debian.sh",
+ "scripts/vyos/cloud-init-vyos.sh",
+ "scripts/vyos/cloud-init-datasource.sh",
+ ]
+ }
+
+ # if PLATFORM=qemu will install qemu packages
+ provisioner "shell" {
+ execute_command = "VYOS_RELEASE='${var.vyos_release}' PLATFORM='${var.platform}' {{ .Vars }} sudo -E bash '{{ .Path }}'"
+ scripts = [
+ "scripts/vyos/platform-qemu.sh"
+ ]
+ }
+
+ # if grub_serial=1 change grub default to serial
+ provisioner "shell" {
+ execute_command = "VYOS_RELEASE='${var.vyos_release}' GRUB_SERIAL='${var.grub_serial}' {{ .Vars }} sudo -E bash '{{ .Path }}'"
+ scripts = [
+ "scripts/vyos/grub-serial.sh"
+ ]
+ }
+
+ # image cleanup
+ provisioner "shell" {
+ execute_command = "VYOS_RELEASE='${var.vyos_release}' {{ .Vars }} sudo -E bash '{{ .Path }}'"
+ scripts = [
+ "scripts/vyos/cleanup.sh",
+ ]
+ }
+
+ # copy qcow2 to final destination
+ post-processors {
+ post-processor "shell-local" {
+ inline = [
+ "cp 'iso/${var.vm_name}-build2.qcow2' iso/${var.vm_name}.img",
+ "cd iso/ && sha256sum ${var.vm_name}.img > ${var.vm_name}.img.checksum && cd ../" ,
+ "cat iso/*.checksum > iso/SHA256SUM",
+ "rm -rf '${local.output_dir}'"
+ ]
+ }
+ }
+} \ No newline at end of file
diff --git a/vyos-image2-1.5.pkr.hcl b/vyos-image2-1.5.pkr.hcl
new file mode 100644
index 0000000..0c6963b
--- /dev/null
+++ b/vyos-image2-1.5.pkr.hcl
@@ -0,0 +1,261 @@
+packer {
+ required_plugins {
+ qemu = {
+ version = "~> 1"
+ source = "github.com/hashicorp/qemu"
+ }
+ }
+}
+
+
+# dont edit those vars below, customize in local.auto.pkrvars.hcl using local.example.pkrvars.hcl
+variable "vm_name" {
+ default = "vyos-image-1.3.6"
+}
+
+variable "numvcpus" {
+ default = "4"
+}
+
+variable "memsize" {
+ default = "2048"
+}
+
+variable "disk_size" {
+ default = "1024"
+}
+
+variable "iso_checksum" {
+ default = "file:iso/SHA256SUM"
+}
+
+variable "ssh_username" {
+ default = "vyos"
+}
+
+variable "ssh_password" {
+ default = "vyos"
+}
+
+variable "boot_wait" {
+ default = "5s"
+}
+
+# - qemu: will build qcow2 image
+# - none: not supported
+variable "platform" {
+ type = string
+ default = "qemu"
+}
+
+# cloud-init values:
+# debian - will install/replace cloud-init packages
+# vyos - will keep cloud-init packages from vyos
+variable "cloud_init" {
+ type = string
+ default = "vyos"
+}
+
+# equuleus: debian 11 (branch 1.3.*)
+# sagitta: debian 12 (branch 1.4.*)
+# circinus: debian 12 (branch 1.5.*)
+# current: debian 12 (branch 1.5.*)
+variable "vyos_release" {
+ default = "circinus"
+}
+
+# build will fail if headless is false, only use headless false if you prepared X11/vnc setup
+variable "headless" {
+ default = true
+}
+
+variable "host_port_min" {
+ default = env("HOST_PORT_FIXED") != "" ? env("HOST_PORT_FIXED") : 2222
+}
+variable "host_port_max" {
+ default = env("HOST_PORT_FIXED") != "" ? env("HOST_PORT_FIXED") : 4444
+}
+
+variable "vnc_port_min" {
+ default = env("VNC_PORT_FIXED") != "" ? env("VNC_PORT_FIXED") : 5900
+}
+variable "vnc_port_max" {
+ default = env("VNC_PORT_FIXED") != "" ? env("VNC_PORT_FIXED") : 6000
+}
+
+variable "sleep_before_shutdown" {
+ default = env("SLEEP_BEFORE_SHUTDOWN") != "" ? env("SLEEP_BEFORE_SHUTDOWN") : 0
+}
+
+# this is actually boot time between grub and user login. Need to be increased if your system in heavy load. A wait time too long will increase build time.
+variable "sleep_after_grub" {
+ default = "45" # in seconds
+}
+
+# set grub_serial=1 to turn grub default=1, ie: use serial console. it is need to adjust on hypervisor
+variable "grub_serial" {
+ type = string
+ default = 1
+}
+
+# which kind of datasource should be used
+# nocloud_configdrive => use this as default, will turn on NoCloud, ConfigDrive on cloud-init datasource_list
+# blank - don't set default datasource_list
+variable "cloud_init_datasource" {
+ default = "nocloud_configdrive"
+}
+
+locals {
+ iso_path = "iso/${var.vm_name}-build2.qcow2" # not used at all since qemuargs -drive override it
+ output_dir = "output/vyos-image2/${regex_replace(timestamp(), "[: ]", "-")}"
+}
+
+source "qemu" "vyos" {
+ boot_command = [
+ "<wait2s><enter>",
+ "<wait${var.sleep_after_grub}s>",
+ "${var.ssh_username}<enter><wait>",
+ "${var.ssh_password}<enter><wait>",
+ "configure<enter><wait>",
+ "set interfaces ethernet eth0 address 'dhcp'<enter><wait>",
+ "set system name-server '8.8.8.8'<enter><wait>",
+ "set service ssh port '22'<enter><wait>",
+ "commit<enter><wait>",
+ "save<enter><wait>",
+ "exit<enter><wait10s>", # wait 10 seconds before reboot (dev purposes)
+ ]
+
+ accelerator = "kvm"
+
+ iso_checksum = var.iso_checksum
+ iso_url = local.iso_path # not used at all since qemuargs -drive override it
+
+ boot_wait = var.boot_wait
+
+ http_directory = "http"
+
+ shutdown_command = "sleep ${var.sleep_before_shutdown}; sudo shutdown -P now"
+
+ communicator = "ssh"
+
+ host_port_min = var.host_port_min
+ host_port_max = var.host_port_max
+
+ ssh_username = var.ssh_username
+ ssh_password = var.ssh_password
+
+ ssh_timeout = "30m"
+
+ memory = var.memsize
+ cpus = var.numvcpus
+ disk_size = var.disk_size
+
+ vnc_port_min = var.vnc_port_min
+ vnc_port_max = var.vnc_port_max
+
+ headless = var.headless
+
+ output_directory = "${local.output_dir}"
+
+ net_device = "virtio-net"
+ disk_interface = "virtio"
+
+ qemuargs = [
+ ["-m", "2048"],
+ ["-smp", "4"],
+ ["-cpu", "host"],
+ ["-netdev", "user,id=user.0,", "hostfwd=tcp::{{ .SSHHostPort }}-:22"],
+ ["-device", "virtio-net,netdev=user.0"],
+ #["-drive", "file=iso/${var.vm_name}.qcow2,if=virtio,cache=writeback,discard=ignore,format=qcow2"]
+ #["-drive", "file=iso/${var.vm_name}.qcow2,if=none,id=drive-virtio0,format=qcow2,cache=writeback,aio=io_uring,detect-zeroes=on"]
+ ["-drive", "file=iso/${var.vm_name}-build2.qcow2,if=virtio,cache=writeback,format=qcow2,aio=io_uring,detect-zeroes=on"]
+ ]
+}
+
+build {
+ name = "vyos"
+
+ source "source.qemu.vyos" {
+ name = "vyos_qemu_qcow2"
+ vm_name = "${var.vm_name}-${source.name}.qcow2"
+ format = "qcow2"
+ }
+
+ provisioner "shell-local" {
+ inline = [
+ "mkdir -p ${local.output_dir}"
+ ]
+ }
+
+ # preparing provisioner
+ provisioner "shell" {
+ execute_command = "VYOS_RELEASE='${var.vyos_release}' {{ .Vars }} sudo -E bash '{{ .Path }}'"
+ scripts = [
+ "scripts/vyos/init.sh",
+ ]
+ }
+
+ # configure vyos
+ provisioner "shell" {
+ execute_command = "VYOS_RELEASE='${var.vyos_release}' {{ .Vars }} sudo -E bash '{{ .Path }}'"
+ scripts = [
+ "scripts/vyos/configure.sh",
+ ]
+ }
+
+ # installing apt repos and custom packages
+ provisioner "shell" {
+ execute_command = "VYOS_RELEASE='${var.vyos_release}' CLOUD_INIT='${var.cloud_init}' {{ .Vars }} sudo -E bash '{{ .Path }}'"
+ scripts = [
+ "scripts/vyos/apt-repo-debian.sh",
+ "scripts/vyos/apt-repo-vyos.sh",
+ "scripts/vyos/apt-install.sh",
+ ]
+ }
+
+ # preparing cloud-init
+ provisioner "shell" {
+ execute_command = "VYOS_RELEASE='${var.vyos_release}' CLOUD_INIT='${var.cloud_init}' CLOUD_INIT_DATASOURCE='${var.cloud_init_datasource}' {{ .Vars }} sudo -E bash '{{ .Path }}'"
+ scripts = [
+ "scripts/vyos/cloud-init-debian.sh",
+ "scripts/vyos/cloud-init-vyos.sh",
+ "scripts/vyos/cloud-init-datasource.sh",
+ ]
+ }
+
+ # if PLATFORM=qemu will install qemu packages
+ provisioner "shell" {
+ execute_command = "VYOS_RELEASE='${var.vyos_release}' PLATFORM='${var.platform}' {{ .Vars }} sudo -E bash '{{ .Path }}'"
+ scripts = [
+ "scripts/vyos/platform-qemu.sh"
+ ]
+ }
+
+ # if grub_serial=1 change grub default to serial
+ provisioner "shell" {
+ execute_command = "VYOS_RELEASE='${var.vyos_release}' GRUB_SERIAL='${var.grub_serial}' {{ .Vars }} sudo -E bash '{{ .Path }}'"
+ scripts = [
+ "scripts/vyos/grub-serial.sh"
+ ]
+ }
+
+ # image cleanup
+ provisioner "shell" {
+ execute_command = "VYOS_RELEASE='${var.vyos_release}' {{ .Vars }} sudo -E bash '{{ .Path }}'"
+ scripts = [
+ "scripts/vyos/cleanup.sh",
+ ]
+ }
+
+ # copy qcow2 to final destination
+ post-processors {
+ post-processor "shell-local" {
+ inline = [
+ "cp 'iso/${var.vm_name}-build2.qcow2' iso/${var.vm_name}.img",
+ "cd iso/ && sha256sum ${var.vm_name}.img > ${var.vm_name}.img.checksum && cd ../" ,
+ "cat iso/*.checksum > iso/SHA256SUM",
+ "rm -rf '${local.output_dir}'"
+ ]
+ }
+ }
+} \ No newline at end of file