1
1
mirror of https://gitlab.archlinux.org/archlinux/infrastructure.git synced 2025-01-18 08:06:16 +01:00
infrastructure/packer/archlinux.pkr.hcl
2024-11-19 11:34:37 +01:00

56 lines
1.3 KiB
HCL

# https://www.packer.io/docs/templates/hcl_templates/blocks/packer
packer {
required_plugins {
ansible = {
source = "github.com/hashicorp/ansible"
version = ">= 1.1.2"
}
hcloud = {
source = "github.com/hashicorp/hcloud"
version = ">= 1.6.0"
}
}
}
# https://www.packer.io/docs/templates/hcl_templates/variables#type-constraints
variable "hetzner_cloud_api_key" {
type = string
sensitive = true
}
variable "install_ec2_public_keys_service" {
type = bool
default = false
}
# https://www.packer.io/docs/templates/hcl_templates/blocks/source
source "hcloud" "rescue" {
image = "ubuntu-24.04"
location = "fsn1"
rescue = "linux64"
server_type = "cx22"
snapshot_labels = {
custom_image = "archlinux"
}
snapshot_name = "archlinux-${timestamp()}"
ssh_username = "root"
token = var.hetzner_cloud_api_key
}
# https://www.packer.io/docs/templates/hcl_templates/blocks/build
build {
sources = ["source.hcloud.rescue"]
provisioner "ansible" {
host_alias = "packer-base-image"
inventory_directory = "."
playbook_file = "playbooks/tasks/install_arch.yml"
extra_arguments = [
"--extra-vars", jsonencode({
install_ec2_public_keys_service : var.install_ec2_public_keys_service
})
]
use_proxy = false
}
}