hetzner-alpine-k8s/alpine-on-hetzner/alpine.pkr.hcl
Knut Ahlers 9c14dc02e5
Move git module to included files
in order to be able to modify the code

Signed-off-by: Knut Ahlers <knut@ahlers.me>
2023-05-06 12:56:29 +02:00

67 lines
1.7 KiB
HCL

# Please see default.json for default values for these
variable "apk_tools_url" {}
variable "apk_tools_arch" {}
variable "apk_tools_version" {}
variable "apk_tools_checksum" {}
variable "alpine_version" {}
variable "alpine_mirror" {}
variable "alpine_repositories" {}
variable "boot_size" {}
variable "root_size" {}
variable "hostname" {}
variable "packages" {}
variable "services" {}
variable "nameservers" {}
variable "extlinux_modules" {}
variable "kernel_features" {}
variable "kernel_modules" {}
variable "default_kernel_opts" {}
variable "sysctl" {}
variable "chroot_commands" {}
locals {
timestamp = formatdate("DD-MM-YY.hh-mm-ss", 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
snapshot_labels = {
"alpine.pius.dev/timestamp" = local.timestamp
"alpine.pius.dev/alpine-version" = var.alpine_version
"alpine.pius.dev/snapshot-id" = local.snapshot_id
}
}
provisioner "ansible" {
playbook_file = "playbook.yml"
extra_arguments = ["--extra-vars", "@config.json"]
}
post-processor "manifest" {
output = "/manifests/${build.PackerRunUUID}.json"
strip_path = true
custom_data = merge({
"alpine.pius.dev/alpine-version": var.alpine_version,
"alpine.pius.dev/packer-run-id": build.PackerRunUUID,
"alpine.pius.dev/snapshot-id": local.snapshot_id
}, zipmap(
formatlist("alpine.pius.dev/%s-version", keys(var.packages)),
values(var.packages)
))
}
}