From 70f29227f03e619b82fa07009cbb63bd900b09aa Mon Sep 17 00:00:00 2001 From: Tellsanguis Date: Thu, 27 Nov 2025 13:09:18 +0100 Subject: [PATCH] feat(terraform): Create VMs from scratch with Ubuntu 24.04 cloud image MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changements majeurs: - Supprime le clonage de template (clone/full_clone) - Utilise l'image cloud Ubuntu 24.04 LTS directement - Ajoute os_type = cloud-init pour support natif - Configure Standard VGA pour compatibilité - CPU type host pour meilleures performances - BIOS seabios explicite Avantages: - Proxmox crée automatiquement les ressources LINSTOR - Plus besoin de script Python de pré-provisioning - Pas de dépendance sur template pré-existant - Configuration via cloud-init uniquement Pré-requis: - Télécharger ubuntu-24.04-server-cloudimg-amd64.img sur chaque nœud - Placer dans /var/lib/vz/template/iso/ --- terraform/pve1/main.tf | 24 +++++++++++++++++++++--- terraform/pve2/main.tf | 24 +++++++++++++++++++++--- terraform/pve3/main.tf | 24 +++++++++++++++++++++--- 3 files changed, 63 insertions(+), 9 deletions(-) diff --git a/terraform/pve1/main.tf b/terraform/pve1/main.tf index 285e8a8..d2eac1b 100644 --- a/terraform/pve1/main.tf +++ b/terraform/pve1/main.tf @@ -25,27 +25,38 @@ resource "proxmox_vm_qemu" "k3s_server_1" { vmid = 1000 name = "k3s-server-1" target_node = "acemagician" - clone = var.ubuntu_template - full_clone = true + # Création from scratch avec ISO Ubuntu 24.04 + iso = "local:iso/ubuntu-24.04-server-cloudimg-amd64.img" + + # Configuration matérielle cpu { cores = var.k3s_server_1_config.cores sockets = 1 + type = "host" } memory = var.k3s_server_1_config.memory agent = 1 + bios = "seabios" boot = "order=scsi0" scsihw = "virtio-scsi-single" onboot = true + # Standard VGA pour compatibilité + vga { + type = "std" + } + + # Réseau network { id = 0 model = "virtio" bridge = var.k3s_network_bridge } + # Disque sur LINSTOR disk { slot = "scsi0" size = var.k3s_server_1_config.disk_size @@ -54,12 +65,19 @@ resource "proxmox_vm_qemu" "k3s_server_1" { iothread = true } + # Cloud-init configuration ipconfig0 = "ip=${var.k3s_server_1_config.ip},gw=${var.k3s_gateway}" cicustom = "user=${var.snippets_storage}:snippets/cloud-init-k3s-server-1.yaml" nameserver = join(" ", var.k3s_dns) + # Pour cloud-init + os_type = "cloud-init" + lifecycle { - ignore_changes = [network] + ignore_changes = [ + network, + iso + ] } depends_on = [local_file.k3s_server_cloud_init] diff --git a/terraform/pve2/main.tf b/terraform/pve2/main.tf index c0b4afe..c83550a 100644 --- a/terraform/pve2/main.tf +++ b/terraform/pve2/main.tf @@ -25,27 +25,38 @@ resource "proxmox_vm_qemu" "k3s_server_2" { vmid = 1001 name = "k3s-server-2" target_node = "elitedesk" - clone = var.ubuntu_template - full_clone = true + # Création from scratch avec ISO Ubuntu 24.04 + iso = "local:iso/ubuntu-24.04-server-cloudimg-amd64.img" + + # Configuration matérielle cpu { cores = var.k3s_server_2_config.cores sockets = 1 + type = "host" } memory = var.k3s_server_2_config.memory agent = 1 + bios = "seabios" boot = "order=scsi0" scsihw = "virtio-scsi-single" onboot = true + # Standard VGA pour compatibilité + vga { + type = "std" + } + + # Réseau network { id = 0 model = "virtio" bridge = var.k3s_network_bridge } + # Disque sur LINSTOR disk { slot = "scsi0" size = var.k3s_server_2_config.disk_size @@ -54,12 +65,19 @@ resource "proxmox_vm_qemu" "k3s_server_2" { iothread = true } + # Cloud-init configuration ipconfig0 = "ip=${var.k3s_server_2_config.ip},gw=${var.k3s_gateway}" cicustom = "user=${var.snippets_storage}:snippets/cloud-init-k3s-server-2.yaml" nameserver = join(" ", var.k3s_dns) + # Pour cloud-init + os_type = "cloud-init" + lifecycle { - ignore_changes = [network] + ignore_changes = [ + network, + iso + ] } depends_on = [local_file.k3s_server_cloud_init] diff --git a/terraform/pve3/main.tf b/terraform/pve3/main.tf index a1ab8f5..e5a5671 100644 --- a/terraform/pve3/main.tf +++ b/terraform/pve3/main.tf @@ -25,27 +25,38 @@ resource "proxmox_vm_qemu" "etcd_witness" { vmid = 1002 name = "etcd-witness" target_node = "thinkpad" - clone = var.ubuntu_template - full_clone = true + # Création from scratch avec ISO Ubuntu 24.04 + iso = "local:iso/ubuntu-24.04-server-cloudimg-amd64.img" + + # Configuration matérielle cpu { cores = var.etcd_witness_config.cores sockets = 1 + type = "host" } memory = var.etcd_witness_config.memory agent = 1 + bios = "seabios" boot = "order=scsi0" scsihw = "virtio-scsi-single" onboot = true + # Standard VGA pour compatibilité + vga { + type = "std" + } + + # Réseau network { id = 0 model = "virtio" bridge = var.k3s_network_bridge } + # Disque sur local-lvm disk { slot = "scsi0" size = var.etcd_witness_config.disk_size @@ -54,12 +65,19 @@ resource "proxmox_vm_qemu" "etcd_witness" { iothread = true } + # Cloud-init configuration ipconfig0 = "ip=${var.etcd_witness_config.ip},gw=${var.k3s_gateway}" cicustom = "user=${var.snippets_storage}:snippets/cloud-init-etcd-witness.yaml" nameserver = join(" ", var.k3s_dns) + # Pour cloud-init + os_type = "cloud-init" + lifecycle { - ignore_changes = [network] + ignore_changes = [ + network, + iso + ] } depends_on = [local_file.etcd_witness_cloud_init]