84 lines
2.3 KiB
HCL
84 lines
2.3 KiB
HCL
packer {
|
|
required_plugins {
|
|
hcloud = {
|
|
source = "github.com/hetznercloud/hcloud"
|
|
version = ">= 1.6.0"
|
|
}
|
|
}
|
|
}
|
|
|
|
variable "hcloud_location" {
|
|
type = string
|
|
default = "hel1"
|
|
}
|
|
|
|
variable "forgejo_runner_version" {
|
|
type = string
|
|
default = "6.3.1"
|
|
}
|
|
|
|
source "hcloud" "base-arm64" {
|
|
image = "ubuntu-24.04"
|
|
location = var.hcloud_location
|
|
server_type = "cax11"
|
|
ssh_username = "root"
|
|
snapshot_name = "forgejo-runner-${var.forgejo_runner_version}"
|
|
snapshot_labels = {
|
|
name = "forgejo_runner"
|
|
base = "ubuntu-24.04",
|
|
arch = "arm64"
|
|
runner_version = var.forgejo_runner_version
|
|
}
|
|
|
|
user_data = templatefile("configs/cloud-init.yaml", {
|
|
arch = "arm64"
|
|
unattended_upgrades_config = base64gzip(file("configs/50unattended-upgrades"))
|
|
forgejo_runner_service = base64gzip(file("configs/forgejo-runner.service"))
|
|
forgejo_runner_version = var.forgejo_runner_version
|
|
forgejo_runner_config = base64gzip(templatefile("configs/runner-config.yaml", {
|
|
arch = "arm64"
|
|
}))
|
|
})
|
|
}
|
|
|
|
source "hcloud" "base-amd64" {
|
|
image = "ubuntu-24.04"
|
|
location = var.hcloud_location
|
|
server_type = "cx22"
|
|
ssh_keys = ["Yubikey", "Default Management"]
|
|
ssh_username = "root"
|
|
snapshot_name = "forgejo-runner-${var.forgejo_runner_version}"
|
|
snapshot_labels = {
|
|
name = "forgejo_runner"
|
|
base = "ubuntu-24.04",
|
|
version = "v1.0.0",
|
|
arch = "amd64"
|
|
runner_version = var.forgejo_runner_version
|
|
}
|
|
|
|
user_data = templatefile("configs/cloud-init.yaml", {
|
|
arch = "amd64"
|
|
unattended_upgrades_config = base64gzip(file("configs/50unattended-upgrades"))
|
|
forgejo_runner_service = base64gzip(file("configs/forgejo-runner.service"))
|
|
forgejo_runner_version = var.forgejo_runner_version
|
|
forgejo_runner_config = base64gzip(templatefile("configs/runner-config.yaml", {
|
|
arch = "amd64"
|
|
}))
|
|
})
|
|
}
|
|
|
|
build {
|
|
sources = ["source.hcloud.base-arm64", "source.hcloud.base-amd64"]
|
|
|
|
provisioner "shell" {
|
|
inline = ["cloud-init status --wait --long"]
|
|
valid_exit_codes = [0, 2]
|
|
}
|
|
|
|
provisioner "shell" {
|
|
scripts = [
|
|
"scripts/upgrade.sh",
|
|
"scripts/cleanup.sh",
|
|
]
|
|
}
|
|
}
|