Files
terraform/proxmox/archlinux/resources_proxmox.tf
T

167 lines
3.5 KiB
Terraform
Raw Normal View History

2026-09-08 02:51:19 -04:00
resource "proxmox_download_file" "arch_qcow" {
2026-09-08 00:15:03 -04:00
for_each = data.proxmox_virtual_environment_node.hvc01
2026-09-08 02:51:19 -04:00
checksum = local.arch_qcow_hash
checksum_algorithm = "sha256"
2026-09-08 00:15:03 -04:00
content_type = "import"
datastore_id = "local"
2026-09-08 02:51:19 -04:00
file_name = "archlinux_cloudimg_amd64.qcow2"
2026-09-08 00:15:03 -04:00
node_name = each.value.id
overwrite = true
2026-09-08 02:51:19 -04:00
overwrite_unmanaged = true
upload_timeout = 300
url = "https://${var.arch_mirror}/images/latest/Arch-Linux-x86_64-cloudimg.qcow2"
verify = true
}
2026-09-08 12:31:12 -04:00
resource "proxmox_virtual_environment_pool" "this" {
2026-09-08 02:51:19 -04:00
comment = "Container hosts and download client"
pool_id = "archlinux"
}
2026-09-08 12:31:12 -04:00
resource "proxmox_virtual_environment_vm" "this" {
for_each = var.vm_guests
2026-09-08 14:16:43 -04:00
acpi = true
2026-09-08 02:51:19 -04:00
agent {
enabled = true
timeout = "10m"
trim = false
type = "virtio"
wait_for_ip {
disabled = false
ipv4 = true
ipv6 = true
}
2026-09-08 00:15:03 -04:00
}
2026-09-08 02:51:19 -04:00
audio_device {
enabled = false
}
bios = "ovmf"
cpu {
cores = 1
flags = ["+aes"]
hotplugged = 0
limit = 0
numa = false
sockets = 1
type = "x86-64-v2"
units = 100
}
description = "Arch Linux container host"
disk {
aio = "io_uring"
backup = true
cache = "none"
datastore_id = "local-lvm"
discard = "ignore"
file_format = "raw"
file_id = proxmox_download_file.arch_qcow[each.value.host].id
interface = "virtio0"
iothread = false
replicate = true
size = 64
}
2026-09-08 12:31:12 -04:00
dynamic "disk" {
for_each = each.value.role == "container_host" ? [1] : []
content {
aio = "io_uring"
backup = true
cache = "none"
datastore_id = "local-lvm"
discard = "ignore"
file_format = "raw"
interface = "virtio1"
iothread = false
replicate = true
size = 128
}
}
2026-09-08 02:51:19 -04:00
efi_disk {
datastore_id = "local-lvm"
file_format = "raw"
type = "4m"
pre_enrolled_keys = false
}
tpm_state {
datastore_id = "local-lvm"
version = "v2.0"
}
hotplug = "network,disk,usb"
initialization {
datastore_id = "local-lvm"
interface = "sata0"
file_format = "raw"
dns {
domain = var.local_domain
servers = concat(var.ipv4_nameservers, var.ipv6_nameservers)
}
ip_config {
ipv4 {
address = "${data.dns_a_record_set.guests[each.key].addrs[0]}/${var.ipv4_subnet_mask}"
gateway = var.ipv4_gateway
}
ipv6 {
address = "${data.dns_aaaa_record_set.guests[each.key].addrs[0]}/64"
gateway = var.ipv6_gateway
}
}
user_account {
2026-09-08 12:31:12 -04:00
keys = [
local.arch_public_key
]
password = random_password.this[each.key].result
username = var.arch_username
2026-09-08 02:51:19 -04:00
}
}
keyboard_layout = "en-us"
machine = "q35"
memory {
dedicated = 2048
floating = 2048
shared = 0
}
migrate = true
name = each.key
network_device {
bridge = "vmbr0"
disconnected = false
firewall = false
model = "virtio"
mtu = 1
}
node_name = each.value.host
on_boot = true
operating_system {
type = "l26"
}
2026-09-08 12:31:12 -04:00
pool_id = proxmox_virtual_environment_pool.this.pool_id
2026-09-08 02:51:19 -04:00
protection = false
reboot = false
reboot_after_update = true
started = true
startup{
order = 1
up_delay = 20
}
tablet_device = false
stop_on_destroy = true
purge_on_destroy = true
delete_unreferenced_disks_on_destroy = true
vga {
type = "qxl"
}
watchdog {
enabled = false
action = "reset"
model = "i6300esb"
}
2026-09-08 16:57:19 -04:00
lifecycle {
ignore_changes = [
initialization["user_account"],
audio_device["device"],
audio_device["driver"]
]
}
2026-09-08 02:51:19 -04:00
}