Homelab/terraform/pve1/main.tf

85 lines
1.7 KiB
Terraform
Raw Normal View History

2025-11-07 09:33:38 +01:00
terraform {
required_version = ">= 1.6.0"
required_providers {
proxmox = {
source = "telmate/proxmox"
version = "3.0.2-rc05"
2025-11-07 09:33:38 +01:00
}
local = {
source = "hashicorp/local"
2025-11-07 09:33:38 +01:00
version = "~> 2.1"
}
}
}
provider "proxmox" {
pm_api_url = var.proxmox_api_url
pm_api_token_id = var.proxmox_token_id
pm_api_token_secret = var.proxmox_token_secret
pm_tls_insecure = var.proxmox_tls_insecure
}
# K3s Server VM on acemagician
2025-11-07 09:33:38 +01:00
resource "proxmox_vm_qemu" "k3s_server_1" {
vmid = 1000
2025-11-07 09:33:38 +01:00
name = "k3s-server-1"
target_node = "acemagician"
2025-11-07 09:33:38 +01:00
# 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
2025-11-07 09:33:38 +01:00
bios = "seabios"
boot = "order=scsi0"
scsihw = "virtio-scsi-single"
onboot = true
2025-11-07 09:33:38 +01:00
# Standard VGA pour compatibilité
vga {
type = "std"
}
# Réseau
2025-11-07 09:33:38 +01:00
network {
id = 0
2025-11-07 09:33:38 +01:00
model = "virtio"
bridge = var.k3s_network_bridge
}
# Disque sur LINSTOR
disk {
slot = "scsi0"
size = var.k3s_server_1_config.disk_size
type = "disk"
storage = var.k3s_server_1_storage_pool
iothread = true
2025-11-07 09:33:38 +01:00
}
# 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"
2025-11-07 09:33:38 +01:00
nameserver = join(" ", var.k3s_dns)
# Pour cloud-init
os_type = "cloud-init"
2025-11-07 09:33:38 +01:00
lifecycle {
ignore_changes = [
network,
iso
]
2025-11-07 09:33:38 +01:00
}
depends_on = [local_file.k3s_server_cloud_init]
}