From 408a11129981d7192520a2de2664a4b6acde8e3a Mon Sep 17 00:00:00 2001 From: Stefan Le Breton Date: Sat, 23 Nov 2024 22:15:15 +0100 Subject: [PATCH] packer build parameters --- packer/talos_image.pkr.hcl | 54 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 packer/talos_image.pkr.hcl diff --git a/packer/talos_image.pkr.hcl b/packer/talos_image.pkr.hcl new file mode 100644 index 0000000..f5918a5 --- /dev/null +++ b/packer/talos_image.pkr.hcl @@ -0,0 +1,54 @@ +packer { + required_plugins { + hcloud = { + version = ">= 1.2" + source = "github.com/hetznercloud/hcloud" + } + } +} + +variable "version" { + type = string +} + +variable "schematic_id" { + type = string +} + +variable "cluster_name" { + type = string +} + +locals { + image = "https://factory.talos.dev/image/${var.schematic_id}/${var.version}/hcloud-amd64.raw.xz" +} + +# smallest possible for building +source "hcloud" "talos" { + rescue = "linux64" + image = "debian-11" + location = "fsn1" + server_type = "cx22" + ssh_username = "root" + + snapshot_name = "talos system disk ${var.version} ${var.cluster_name}" + snapshot_labels = { + type = "infra", + os = "talos", + version = "${var.version}", + cluster = "${var.cluster_name}" + #schematic = "${var.talos_schematic_id}" + } +} + +build { + sources = ["source.hcloud.talos"] + + provisioner "shell" { + inline = [ + "apt-get install -y wget xz-utils", + "wget -O /tmp/talos.raw.xz ${local.image}", + "xz -d -c /tmp/talos.raw.xz | dd of=/dev/sda && sync", + ] + } +}