From c32aa4982ca50db4e7e44855f897b4ec7c363d9a Mon Sep 17 00:00:00 2001 From: michael Date: Tue, 8 Sep 2026 02:51:19 -0400 Subject: [PATCH] Archlinux on pve working --- proxmox/archlinux/data_dns.tf | 8 +- proxmox/archlinux/resources_proxmox.tf | 173 +++++++++++++++++-- proxmox/archlinux/variables.tf | 11 +- proxmox/archlinux/vars_archlinux.auto.tfvars | 2 +- proxmox/archlinux/vars_network.auto.tfvars | 4 +- proxmox/archlinux/vars_vms.auto.tfvars | 25 ++- 6 files changed, 184 insertions(+), 39 deletions(-) diff --git a/proxmox/archlinux/data_dns.tf b/proxmox/archlinux/data_dns.tf index defc015..84dda4e 100644 --- a/proxmox/archlinux/data_dns.tf +++ b/proxmox/archlinux/data_dns.tf @@ -1,9 +1,9 @@ data "dns_a_record_set" "guests" { - for_each = toset([ for guest in var.vm_guests: guest.name ]) - host = "${each.value}.${var.local_domain}" + for_each = var.vm_guests + host = "${each.key}.${var.local_domain}" } data "dns_aaaa_record_set" "guests" { - for_each = toset([ for guest in var.vm_guests: guest.name ]) - host = "${each.value}.${var.local_domain}" + for_each = var.vm_guests + host = "${each.key}.${var.local_domain}" } diff --git a/proxmox/archlinux/resources_proxmox.tf b/proxmox/archlinux/resources_proxmox.tf index a509650..c5eae48 100644 --- a/proxmox/archlinux/resources_proxmox.tf +++ b/proxmox/archlinux/resources_proxmox.tf @@ -1,16 +1,169 @@ -resource "proxmox_virtual_environment_file" "arch_qcow" { +resource "proxmox_download_file" "arch_qcow" { for_each = data.proxmox_virtual_environment_node.hvc01 + checksum = local.arch_qcow_hash + checksum_algorithm = "sha256" content_type = "import" datastore_id = "local" + file_name = "archlinux_cloudimg_amd64.qcow2" node_name = each.value.id overwrite = true - source_file { - checksum = local.arch_qcow_hash - file_name = "archlinux_cloudimg_amd64.qcow2" - insecure = false - min_tls = "1.2" - path = "https://${var.arch_mirror}/images/latest/Arch-Linux-x86_64-cloudimg.qcow2" + overwrite_unmanaged = true + upload_timeout = 300 + url = "https://${var.arch_mirror}/images/latest/Arch-Linux-x86_64-cloudimg.qcow2" + verify = true +} + +resource "proxmox_virtual_environment_pool" "archlinux" { + comment = "Container hosts and download client" + pool_id = "archlinux" +} + +resource "proxmox_virtual_environment_vm" "container_hosts" { + for_each = { for key, value in var.vm_guests: key => value if value.role == "container_host" } + acpi = false + agent { + enabled = true + timeout = "10m" + trim = false + type = "virtio" + wait_for_ip { + disabled = false + ipv4 = true + ipv6 = true + } } - timeout_upload = 300 - upload_mode = "stream" -} \ No newline at end of file + audio_device { + enabled = false + } + bios = "ovmf" + cpu { + # architecture = "x86_64" + 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" + # path_in_datastore = "${each.key}_root.qcow2" + discard = "ignore" + file_format = "raw" + file_id = proxmox_download_file.arch_qcow[each.value.host].id + interface = "virtio0" + iothread = false + replicate = true + size = 64 + } + disk { + aio = "io_uring" + backup = true + cache = "none" + datastore_id = "local-lvm" + # path_in_datastore = "${each.key}_root.qcow2" + discard = "ignore" + file_format = "raw" + interface = "virtio1" + iothread = false + replicate = true + size = 128 + } + 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 { + keys = [] + password = "" # FIX + username = "" # FIX + } + } + 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" + } + pool_id = proxmox_virtual_environment_pool.archlinux.pool_id + 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" + } +} + +# resource "proxmox_virtual_environment_vm" "download_clients" { +# for_each = { for key, value in var.vm_guests: key => value if value.role == "download_client" } +# acpi = false +# agent { +# enabled = true +# timeout = "10m" +# trim = false +# type = "virtio" +# } +# node_name = each.value.host +# } \ No newline at end of file diff --git a/proxmox/archlinux/variables.tf b/proxmox/archlinux/variables.tf index 717a0c7..de0b5f3 100644 --- a/proxmox/archlinux/variables.tf +++ b/proxmox/archlinux/variables.tf @@ -1,6 +1,5 @@ variable "vm_guests" { - type = list(object({ - name = string + type = map(object({ host = string role = string })) @@ -32,15 +31,11 @@ variable "search_domains" { } variable "ipv4_nameservers" { - type = list(object({ - address = string - })) + type = list(string) } variable "ipv6_nameservers" { - type = list(object({ - address = string - })) + type = list(string) } variable "local_domain" { diff --git a/proxmox/archlinux/vars_archlinux.auto.tfvars b/proxmox/archlinux/vars_archlinux.auto.tfvars index 6b8b6ab..93ac122 100644 --- a/proxmox/archlinux/vars_archlinux.auto.tfvars +++ b/proxmox/archlinux/vars_archlinux.auto.tfvars @@ -1 +1 @@ -arch_mirror = "mirrors.mit.edu/archlinux" \ No newline at end of file +arch_mirror = "mirrors.kernel.org/archlinux" \ No newline at end of file diff --git a/proxmox/archlinux/vars_network.auto.tfvars b/proxmox/archlinux/vars_network.auto.tfvars index 167ef50..dc1e809 100644 --- a/proxmox/archlinux/vars_network.auto.tfvars +++ b/proxmox/archlinux/vars_network.auto.tfvars @@ -2,10 +2,10 @@ ipv4_gateway = "10.96.10.254" ipv4_subnet_mask = 24 ipv6_gateway = "2600:4040:593d:8b10:6662:66ff:fe21:e9c4" ipv4_nameservers = [ - {address = "10.96.10.254"} + "10.96.10.254" ] ipv6_nameservers = [ - {address = "2600:4040:593d:8b10:6662:66ff:fe21:e9c4"} + "2600:4040:593d:8b10:6662:66ff:fe21:e9c4" ] local_domain = "balsillie.house" search_domains = [ diff --git a/proxmox/archlinux/vars_vms.auto.tfvars b/proxmox/archlinux/vars_vms.auto.tfvars index 22029ce..3c7596b 100644 --- a/proxmox/archlinux/vars_vms.auto.tfvars +++ b/proxmox/archlinux/vars_vms.auto.tfvars @@ -1,17 +1,14 @@ -vm_guests = [ - { +vm_guests = { + ch01 ={ host = "hv02" - name = "ch01" role = "container_host" - }, - { - host = "hv03" - name = "ch02" - role = "container_host" - }, - { - host = "hv03" - name = "dl01" - role = "download" } -] \ No newline at end of file + ch02 ={ + host = "hv03" + role = "container_host" + } + dl01 ={ + host = "hv03" + role = "download_client" + } +} \ No newline at end of file