From 1fca078455e5519f55e698d0ceb00a2fc7097dba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20Mare=C5=A1?= Date: Fri, 13 Jun 2025 19:35:39 +0200 Subject: [PATCH] feat: add flatcar image MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Vojtěch Mareš --- images/flatcar/image.pkr.hcl | 60 ++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 images/flatcar/image.pkr.hcl diff --git a/images/flatcar/image.pkr.hcl b/images/flatcar/image.pkr.hcl new file mode 100644 index 0000000..e12192b --- /dev/null +++ b/images/flatcar/image.pkr.hcl @@ -0,0 +1,60 @@ +packer { + required_plugins { + hcloud = { + source = "github.com/hetznercloud/hcloud" + version = "~> 1.4.0" + } + } +} + +variable "channel" { + type = string + default = "stable" +} + +variable "hcloud_token" { + type = string + default = env("HCLOUD_TOKEN") + sensitive = true +} + +source "hcloud" "flatcar" { + token = var.hcloud_token + + image = "ubuntu-24.04" + location = "fsn1" + rescue = "linux64" + + snapshot_labels = { + os = "flatcar" + channel = var.channel + } + + ssh_username = "root" +} + +build { + source "hcloud.flatcar" { + name = "x86" + server_type = "cx22" + snapshot_name = "flatcar-${var.channel}-amd64" + } + + source "hcloud.flatcar" { + name = "arm" + server_type = "cax11" + snapshot_name = "flatcar-${var.channel}-arm64" + } + + provisioner "shell" { + inline = [ + # Download script and dependencies + "apt-get -y install gawk", + "curl -fsSLO --retry-delay 1 --retry 60 --retry-connrefused --retry-max-time 60 --connect-timeout 20 https://raw.githubusercontent.com/flatcar/init/flatcar-master/bin/flatcar-install", + "chmod +x flatcar-install", + + # Install flatcar + "./flatcar-install -s -o hetzner -C ${var.channel}", + ] + } +}