hac/packer/alma/alma-9.pkr.hcl

116 lines
2.8 KiB
HCL
Raw Normal View History

2024-03-20 13:45:58 +01:00
packer {
required_plugins {
name = {
version = "~> 1"
source = "github.com/hashicorp/proxmox"
}
ansible = {
version = "~> 1"
source = "github.com/hashicorp/ansible"
}
}
}
2024-03-22 23:47:35 +01:00
variable "proxmox_user" {
2024-03-20 13:45:58 +01:00
type = string
default = "packer"
}
2024-03-22 23:47:35 +01:00
variable "proxmox_token" {
type = string
default = null
2024-03-20 13:45:58 +01:00
}
2024-03-22 23:47:35 +01:00
variable "proxmox_url" {
type = string
default = null
2024-03-20 13:45:58 +01:00
}
2024-03-22 23:47:35 +01:00
variable "grub_password_crypt" {
2024-03-20 13:45:58 +01:00
type = string
default = null
}
2024-03-22 23:47:35 +01:00
variable "ssh_password_crypt" {
type = string
default = null
}
variable "ssh_password" {
2024-03-20 13:45:58 +01:00
type = string
2024-03-22 23:47:35 +01:00
default = null
2024-03-20 13:45:58 +01:00
}
2024-03-22 23:47:35 +01:00
source "proxmox-iso" "alma-9" {
2024-03-20 13:45:58 +01:00
http_content = {
2024-03-22 23:47:35 +01:00
"/ks.cfg" = templatefile("http/ks.cfg", { grub_password = var.grub_password_crypt, password_crypt = var.ssh_password_crypt })
2024-03-20 13:45:58 +01:00
}
boot_command = [
2024-03-22 23:47:35 +01:00
"e<wait><down><down><end>",
" inst.ks=http://{{.HTTPIP}}:{{.HTTPPort}}/ks.cfg",
2024-03-20 13:45:58 +01:00
"<leftCtrlOn>x<leftCtrlOff>",
]
boot_wait = "10s"
disks {
disk_size = "10G"
storage_pool = "lab"
type = "virtio"
}
scsi_controller = "virtio-scsi-single"
bios = "ovmf"
efi_config {
efi_storage_pool = "lab"
efi_type = "4m"
pre_enrolled_keys = true
}
insecure_skip_tls_verify = true
2024-03-22 23:47:35 +01:00
iso_checksum = "af5377a1d16bbe599ea91a8761ad645f2f54687075802bdc0c0703ee610182e9"
iso_url = "https://repo.almalinux.org/almalinux/9.3/isos/x86_64/AlmaLinux-9.3-x86_64-boot.iso"
2024-03-20 13:45:58 +01:00
iso_storage_pool = "local"
iso_download_pve = true
unmount_iso = true
network_adapters {
bridge = "vmbr20"
model = "virtio"
}
memory = 8192
cores = 4
2024-03-22 23:47:35 +01:00
cpu_type = "host"
vm_id = 9001
2024-03-20 13:45:58 +01:00
node = "sorm"
username = "${var.proxmox_user}"
token = "${var.proxmox_token}"
proxmox_url = "${var.proxmox_url}/api2/json"
2024-03-22 23:47:35 +01:00
ssh_username = "root"
ssh_password = "${var.ssh_password}"
2024-03-20 13:45:58 +01:00
ssh_timeout = "15m"
2024-03-22 23:47:35 +01:00
template_description = "Alma Linux 9 build by packer on ${timestamp()}"
template_name = "alma-9-r4"
2024-03-20 13:45:58 +01:00
cloud_init = true
cloud_init_storage_pool = "local-lvm"
}
build {
2024-03-22 23:47:35 +01:00
sources = ["source.proxmox-iso.alma-9"]
2024-03-20 13:45:58 +01:00
provisioner "ansible" {
2024-03-22 23:47:35 +01:00
ansible_env_vars = ["ANSIBLE_CONFIG=../../ansible/ansible.cfg", "ANSIBLE_HOST_KEY_CHECKING=False", "ANSIBLE_BECOME_PASS=${var.ssh_password}"]
2024-03-20 13:45:58 +01:00
extra_arguments = [ "--scp-extra-args", "'-O'", "-vv", "--extra-vars", "ansible_become_password=${var.ssh_password}" ]
command = "ansible-playbook"
2024-03-22 23:47:35 +01:00
roles_path = "../../ansible/roles"
playbook_file = "../../ansible/packer.yml"
2024-03-20 13:45:58 +01:00
}
}