Files
TerraHome/terraform/main.tf
MichaelFisher1997 a0b07816b9
Some checks failed
Terraform Plan / Terraform Plan (push) Failing after 10s
refactor: simplify homelab bootstrap around static IPs and fresh runs
Make Terraform the source of truth for node IPs, remove guest-agent/SSH discovery from the normal workflow path, simplify the bootstrap controller to a fresh-run flow, and swap the initial CNI to Flannel so cluster readiness is easier to prove before reintroducing more complex reconcile behavior.
2026-03-07 00:52:35 +00:00

136 lines
2.7 KiB
HCL

terraform {
backend "s3" {}
required_providers {
proxmox = {
source = "Telmate/proxmox"
version = "3.0.2-rc07"
}
}
}
locals {
control_plane_ipconfig = [
for ip in var.control_plane_ips : "ip=${ip}/${var.network_prefix_length},gw=${var.network_gateway}"
]
worker_ipconfig = [
for ip in var.worker_ips : "ip=${ip}/${var.network_prefix_length},gw=${var.network_gateway}"
]
}
provider "proxmox" {
pm_api_url = var.pm_api_url
pm_api_token_id = var.pm_api_token_id
pm_api_token_secret = var.pm_api_token_secret
pm_tls_insecure = true
}
resource "proxmox_vm_qemu" "control_planes" {
count = var.control_plane_count
name = "cp-${count.index + 1}"
vmid = var.control_plane_vmid_start + count.index
target_node = var.target_node
clone = var.clone_template
full_clone = true
os_type = "cloud-init"
agent = var.qemu_agent_enabled ? 1 : 0
automatic_reboot = true
cpu {
sockets = 1
cores = var.control_plane_cores
}
memory = var.control_plane_memory_mb
scsihw = "virtio-scsi-pci"
boot = "order=scsi0"
bootdisk = "scsi0"
ipconfig0 = local.control_plane_ipconfig[count.index]
ciuser = "micqdf"
sshkeys = var.SSH_KEY_PUBLIC
disks {
scsi {
scsi0 {
disk {
size = var.control_plane_disk_size
storage = var.storage
}
}
}
ide {
ide2 {
cloudinit {
storage = var.storage
}
}
}
}
network {
id = 0
model = "virtio"
bridge = var.bridge
}
lifecycle {
ignore_changes = all
}
}
resource "proxmox_vm_qemu" "workers" {
count = var.worker_count
name = "wk-${count.index + 1}"
vmid = var.worker_vmid_start + count.index
target_node = var.target_node
clone = var.clone_template
full_clone = true
os_type = "cloud-init"
agent = var.qemu_agent_enabled ? 1 : 0
automatic_reboot = true
cpu {
sockets = 1
cores = var.worker_cores[count.index]
}
memory = var.worker_memory_mb[count.index]
scsihw = "virtio-scsi-pci"
boot = "order=scsi0"
bootdisk = "scsi0"
ipconfig0 = local.worker_ipconfig[count.index]
ciuser = "micqdf"
sshkeys = var.SSH_KEY_PUBLIC
disks {
scsi {
scsi0 {
disk {
size = var.worker_disk_size
storage = var.storage
}
}
}
ide {
ide2 {
cloudinit {
storage = var.storage
}
}
}
}
network {
id = 0
model = "virtio"
bridge = var.bridge
}
lifecycle {
ignore_changes = all
}
}