packer-images/builds/incus.pkr.hcl
Ben Vincent 8e42e3c6b9
Some checks failed
Deploy / build (push) Failing after 42s
neoloc/build_incus_images (#11)
Reviewed-on: https://git.query.consul/unkin/packer-images/pulls/11
2025-04-24 01:12:25 +10:00

61 lines
1.8 KiB
HCL

build {
name = local.build_name
sources = [
"source.incus.os"
]
# pre-file-copy scripts
provisioner "shell" {
inline = var.scripts_pre_file_copy
}
# Deploy files from the image directory -> root of machine
provisioner "file" {
source = var.deploy_files_from_image ? "./files/" : ""
destination = "/"
}
# Deploy files from the common directory -> root of machine
provisioner "file" {
source = var.deploy_files_from_common ? "../../../../files/${var.os_name}/${var.os_image}/" : ""
destination = "/"
}
# post-file-copy scripts
provisioner "shell" {
inline = var.scripts_post_file_copy
}
# pre-packages scripts
provisioner "shell" {
inline = var.scripts_pre_packages
}
# manage dnf/packages
provisioner "shell" {
inline = [
"dnf install -y ${join(" ", var.packages)}"
]
}
# post-packages scripts
provisioner "shell" {
inline = var.scripts_post_packages
}
# final scripts
provisioner "shell" {
inline = var.scripts_final
}
post-processor "shell-local" {
inline = [
"incus image alias delete $(incus remote get-default):${local.incus_base_name}/latest || true",
"incus image alias delete $(incus remote get-default):${local.incus_base_name}/${var.date} || true",
"incus image info $(incus remote get-default):${local.incus_output_image} | grep Fingerprint | awk '{print $2}'",
"incus image alias create $(incus remote get-default):${local.incus_base_name}/latest $(incus image info $(incus remote get-default):${local.incus_output_image} | grep Fingerprint | awk '{print $2}')",
"incus image alias create $(incus remote get-default):${local.incus_base_name}/${var.date} $(incus image info $(incus remote get-default):${local.incus_output_image} | grep Fingerprint | awk '{print $2}')"
]
}
}