summaryrefslogtreecommitdiff
path: root/vyos-image2.pkr.hcl
diff options
context:
space:
mode:
authorRoberto Berto <463349+robertoberto@users.noreply.github.com>2024-05-15 03:31:01 +0000
committerRoberto Berto <463349+robertoberto@users.noreply.github.com>2024-05-15 03:31:01 +0000
commitb1b9151865275b52647e784c9a8f201e3f090a30 (patch)
tree3561c1523eb6dec0b2a6104a66451adec0a1fc8c /vyos-image2.pkr.hcl
parent769d3a05284392068a3ae56542af64e786fda74e (diff)
downloadpacker-vyos-b1b9151865275b52647e784c9a8f201e3f090a30.tar.gz
packer-vyos-b1b9151865275b52647e784c9a8f201e3f090a30.zip
Improvements for v0.1
- Makefile now clone build1 to build2 to stop break build1 image if build2 fail - Fix README.md github md syntax - grub-serial.sh: bool should be integer and fixed grub default sed - Improved build workflow between build1 to build2 - qmeuargs not create sparse files +detect-zeroes=on -discard=ignore
Diffstat (limited to 'vyos-image2.pkr.hcl')
-rw-r--r--vyos-image2.pkr.hcl31
1 files changed, 17 insertions, 14 deletions
diff --git a/vyos-image2.pkr.hcl b/vyos-image2.pkr.hcl
index 539c518..a3b0c95 100644
--- a/vyos-image2.pkr.hcl
+++ b/vyos-image2.pkr.hcl
@@ -22,7 +22,7 @@ variable "memsize" {
}
variable "disk_size" {
- default = "10240"
+ default = "1024"
}
variable "iso_checksum" {
@@ -94,8 +94,8 @@ variable "sleep_after_grub" {
# set grub_serial=1 to turn grub default=1, ie: use serial console. it is need to adjust on hypervisor
variable "grub_serial" {
- type = bool
- default = true
+ type = string
+ default = 1
}
# which kind of datasource should be used
@@ -106,14 +106,13 @@ variable "cloud_init_datasource" {
}
locals {
- iso_path = "iso/${var.vm_name}.vhd"
- #iso_path = "iso/vyos-1.3.6.qcow2"
+ 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 = [
- "<enter>",
+ "<wait2s><enter>",
"<wait${var.sleep_after_grub}s>",
"${var.ssh_username}<enter><wait>",
"${var.ssh_password}<enter><wait>",
@@ -123,14 +122,13 @@ source "qemu" "vyos" {
"set service ssh port '22'<enter><wait>",
"commit<enter><wait>",
"save<enter><wait>",
- "exit<enter><wait>",
+ "exit<enter><wait10s>",
]
accelerator = "kvm"
iso_checksum = var.iso_checksum
- #iso_url = fileexists(local.iso_path) ? local.iso_path : var.iso_url
- iso_url = local.iso_path
+ iso_url = local.iso_path # not used at all since qemuargs -drive override it
boot_wait = var.boot_wait
@@ -168,7 +166,9 @@ source "qemu" "vyos" {
["-cpu", "host"],
["-netdev", "user,id=user.0,", "hostfwd=tcp::{{ .SSHHostPort }}-:22"],
["-device", "virtio-net,netdev=user.0"],
- ["-drive", "file=iso/vyos-1.3.6.qcow2,if=virtio,cache=writeback,discard=ignore,format=qcow2"]
+ #["-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"]
]
}
@@ -231,7 +231,7 @@ build {
]
}
- # if grub_serial=1 will install change grub to serial
+ # 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 = [
@@ -239,7 +239,7 @@ build {
]
}
- # cleanup
+ # image cleanup
provisioner "shell" {
execute_command = "VYOS_RELEASE='${var.vyos_release}' {{ .Vars }} sudo -E bash '{{ .Path }}'"
scripts = [
@@ -247,11 +247,14 @@ build {
]
}
+ # copy qcow2 to final destination
post-processors {
post-processor "shell-local" {
inline = [
- #"cp '${local.output_dir}/${var.vm_name}-${source.name}.qcow2' /mnt/pve/svm_privateos_ic1a_main/template/iso/"
- "cp 'iso/vyos-1.3.6.qcow2' /mnt/pve/svm_privateos_ic1a_main/template/iso/"
+ "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}'"
]
}
}