packer build parameters

This commit is contained in:
Stefan Le Breton 2024-11-23 22:15:15 +01:00
parent 196b06dc01
commit 408a111299

View file

@ -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",
]
}
}