From 0a410366ed865068d9dcfa385384388fdefb6c53 Mon Sep 17 00:00:00 2001 From: Max Pfeiffer Date: Sat, 9 Nov 2024 18:00:12 +0100 Subject: [PATCH] Fixed handling of install images The default image was missing the qemu guest agent. --- README.md | 2 ++ proxmox/iso_images.tf | 2 +- proxmox/locals.tf | 4 +++- proxmox/talos_linux.tf | 6 ++++-- ...nd_hostname.yaml.tftmpl => machine_config_patches.tftpl} | 1 + proxmox/variables.tf | 5 +++++ 6 files changed, 16 insertions(+), 4 deletions(-) rename proxmox/templates/{machine_disk_and_hostname.yaml.tftmpl => machine_config_patches.tftpl} (74%) diff --git a/README.md b/README.md index 1377d4f..813bee2 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,8 @@ tofu apply ``` ## Information Sources +* [Talos Linux documentation](https://www.talos.dev/v1.8/) +* [Talos Linux Image Factory](https://factory.talos.dev/) * Terraform providers/modules * [terraform-provider-proxmox](https://github.com/Telmate/terraform-provider-proxmox) * [terraform-provider-talos](https://github.com/siderolabs/terraform-provider-talos) diff --git a/proxmox/iso_images.tf b/proxmox/iso_images.tf index 67d47ad..78e8a3a 100644 --- a/proxmox/iso_images.tf +++ b/proxmox/iso_images.tf @@ -1,5 +1,5 @@ resource "proxmox_storage_iso" "talos_linux_iso_image" { - url = "https://factory.talos.dev/image/ce4c980550dd2ab1b17bbf2b08801c7eb59418eafe8f279833297925d67c7515/v1.8.2/nocloud-amd64.iso" + url = local.talos_linux_iso_image_url filename = local.talos_linux_iso_image_filename storage = "local" pve_node = var.proxmox_target_node diff --git a/proxmox/locals.tf b/proxmox/locals.tf index fd5037f..d20b9b9 100644 --- a/proxmox/locals.tf +++ b/proxmox/locals.tf @@ -2,7 +2,9 @@ locals { repo_root = "${dirname(abspath(path.root))}" # Talos Linux - talos_linux_iso_image_filename = "talos-linux-qemu-guest-agent-amd64.iso" + talos_linux_iso_image_url = "https://factory.talos.dev/image/ce4c980550dd2ab1b17bbf2b08801c7eb59418eafe8f279833297925d67c7515/v1.8.2/nocloud-amd64.iso" + talos_linux_iso_image_filename = "talos-linux-v1.8.2-qemu-guest-agent-amd64.iso" + talos_linux_image_reference = "factory.talos.dev/installer/ce4c980550dd2ab1b17bbf2b08801c7eb59418eafe8f279833297925d67c7515:v1.8.2" # K8s control plane k8s_control_plane_ip_address = "192.168.1.150" diff --git a/proxmox/talos_linux.tf b/proxmox/talos_linux.tf index 378a016..00d2b6b 100644 --- a/proxmox/talos_linux.tf +++ b/proxmox/talos_linux.tf @@ -27,9 +27,10 @@ resource "talos_machine_configuration_apply" "controlplane" { for_each = var.node_data.controlplanes node = each.key config_patches = [ - templatefile("${path.module}/templates/machine_disk_and_hostname.yaml.tftmpl", { + templatefile("${path.module}/templates/machine_config_patches.tftpl", { hostname = each.value.hostname == null ? format("%s-cp-%s", var.cluster_name, index(keys(var.node_data.controlplanes), each.key)) : each.value.hostname install_disk = each.value.install_disk + install_image = each.value.install_image }), file("${path.module}/files/cp-scheduling.yaml"), ] @@ -42,9 +43,10 @@ resource "talos_machine_configuration_apply" "worker" { for_each = var.node_data.workers node = each.key config_patches = [ - templatefile("${path.module}/templates/machine_disk_and_hostname.yaml.tftmpl", { + templatefile("${path.module}/templates/machine_config_patches.tftpl", { hostname = each.value.hostname == null ? format("%s-worker-%s", var.cluster_name, index(keys(var.node_data.workers), each.key)) : each.value.hostname install_disk = each.value.install_disk + install_image = each.value.install_image }) ] } diff --git a/proxmox/templates/machine_disk_and_hostname.yaml.tftmpl b/proxmox/templates/machine_config_patches.tftpl similarity index 74% rename from proxmox/templates/machine_disk_and_hostname.yaml.tftmpl rename to proxmox/templates/machine_config_patches.tftpl index 383faf8..1bb5e41 100644 --- a/proxmox/templates/machine_disk_and_hostname.yaml.tftmpl +++ b/proxmox/templates/machine_config_patches.tftpl @@ -1,5 +1,6 @@ machine: install: disk: ${install_disk} + image: ${install_image} network: hostname: ${hostname} \ No newline at end of file diff --git a/proxmox/variables.tf b/proxmox/variables.tf index 361476b..906bf3b 100644 --- a/proxmox/variables.tf +++ b/proxmox/variables.tf @@ -31,10 +31,12 @@ variable "node_data" { type = object({ controlplanes = map(object({ install_disk = string + install_image = string hostname = optional(string) })) workers = map(object({ install_disk = string + install_image = string hostname = optional(string) })) }) @@ -42,14 +44,17 @@ variable "node_data" { controlplanes = { "192.168.1.150" = { install_disk = "/dev/vda" + install_image = "factory.talos.dev/installer/ce4c980550dd2ab1b17bbf2b08801c7eb59418eafe8f279833297925d67c7515:v1.8.2" }, } workers = { "192.168.1.151" = { install_disk = "/dev/vda" + install_image = "factory.talos.dev/installer/ce4c980550dd2ab1b17bbf2b08801c7eb59418eafe8f279833297925d67c7515:v1.8.2" }, "192.168.1.152" = { install_disk = "/dev/vda" + install_image = "factory.talos.dev/installer/ce4c980550dd2ab1b17bbf2b08801c7eb59418eafe8f279833297925d67c7515:v1.8.2" } } }