hetzner-alpine-k8s/alpine.pkr.hcl
Knut Ahlers 7ba01f01a1
Simplify config, upgrade to K8s 1.30.0
- sever connection to upstream
- remove Docker setup
- use local packer binary to build
- add support for writing arbitrary files
- cleanup repo

Signed-off-by: Knut Ahlers <knut@ahlers.me>
2024-04-21 15:52:40 +02:00

51 lines
1.1 KiB
HCL

# Please see default.json for default values for these
variable "hostname" {}
packer {
required_plugins {
ansible = {
version = "~> 1"
source = "github.com/hashicorp/ansible"
}
hcloud = {
source = "github.com/hetznercloud/hcloud"
version = "~> 1"
}
}
}
locals {
timestamp = formatdate("YYYYMMDD-hhmmss", timestamp())
snapshot_id = sha1(uuidv4())
}
source "hcloud" "alpine" {
location = "fsn1"
server_type = "cx11"
image = "ubuntu-20.04"
rescue = "linux64"
ssh_username = "root"
}
build {
name = "alpine"
source "source.hcloud.alpine" {
snapshot_name = "${var.hostname}-${local.timestamp}"
snapshot_labels = {
"alpine.pius.dev/timestamp" = local.timestamp
"alpine.pius.dev/snapshot-id" = local.snapshot_id
}
}
provisioner "ansible" {
extra_arguments = [
"--scp-extra-args", "'-O'", # Required for OpenSSH >=9 (https://github.com/hashicorp/packer-plugin-ansible/issues/110)
"--extra-vars", "@config.json",
]
playbook_file = "playbook.yml"
user = "root"
}
}