From 6fddbcfb9e4731ef4be543202b8f2e9dd664f2f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20Mare=C5=A1?= Date: Sun, 24 Aug 2025 11:46:08 +0200 Subject: [PATCH] feat: initial commit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Vojtěch Mareš --- .editorconfig | 13 ++++++++++ README.md | 3 +++ flatcar.pkr.hcl | 68 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+) create mode 100644 .editorconfig create mode 100644 README.md create mode 100644 flatcar.pkr.hcl diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..87a0020 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,13 @@ +root = true + +[*] +indent_style = space +indent_size = 2 +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true +end_of_line = lf +max_line_length = null + +[Makefile] +indent_style = tab diff --git a/README.md b/README.md new file mode 100644 index 0000000..6d012a1 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# hcloud-image-flatcar + +Packer built Flatcar Linux image build for Hetzner Cloud. diff --git a/flatcar.pkr.hcl b/flatcar.pkr.hcl new file mode 100644 index 0000000..152b011 --- /dev/null +++ b/flatcar.pkr.hcl @@ -0,0 +1,68 @@ +variable "hcloud_token" { + type = string + default = env("HCLOUD_TOKEN") + sensitive = true +} + +packer { + required_plugins { + hcloud = { + source = "github.com/hetznercloud/hcloud" + version = ">= 1.6.0, < 2.0.0" + } + } +} + +variable "channel" { + type = string + default = "stable" +} + +# variable "arch" { +# type = string +# default = "amd64" +# } + +# variable "server_type" { +# type = string +# default = "cx22" +# } + +# variable "server_location" { +# type = string +# default = "fsn1" +# } + +source "hcloud" "flatcar" { + # token = var.hcloud_token + + image = "debian-11" + location = "fsn1" + rescue = "linux64" + + server_type = var.server_type + + snapshot_name = "flatcar-${var.channel}-${var.arch}" + snapshot_labels = { + os = "flatcar" + channel = var.channel + } + + ssh_username = "root" +} + +build { + sources = ["source.hcloud.flatcar"] + + 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}", + ] + } +}