mirror of
https://github.com/Luzifer/hetzner-alpine-k8s.git
synced 2024-11-09 23:00:07 +00:00
Knut Ahlers
7ba01f01a1
- 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>
50 lines
1.1 KiB
HCL
50 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"
|
|
}
|
|
}
|