Files
rootnode-academy/infra/terraform/main.tf
T
ced4568 cbf81b09e7 feat(proxmox): Proxmox VM template + Terraform/OpenTofu VM creation
Manual, documented bare-metal Proxmox install + cloud-init template build
(deliberately not automated — a fragile one-time step). Terraform/OpenTofu
config creates rn-platform-01/rn-lab-host-01 from that template via the
bpg/proxmox provider, with configurable (not hardcoded) VM sizing.

Validated: tofu fmt, tofu init -backend=false (real provider download),
tofu validate -> Success. No paid state backend required (local state).
2026-08-18 17:12:55 -05:00

103 lines
2.4 KiB
Terraform

# Creates rn-platform-01 and rn-lab-host-01 from a shared cloud-init template. Sizing comes
# from variables.tf's platform_vm/lab_host_vm objects — baseline defaults, override in
# terraform.tfvars once real load data exists (docs/CAPACITY_PLANNING.md). This module does
# NOT decide the host's final ZFS/storage layout; vm_disk_datastore just names whichever
# Proxmox storage the real disk-inspection checklist points at.
resource "proxmox_virtual_environment_vm" "rn_platform_01" {
name = "rn-platform-01"
node_name = var.proxmox_node
clone {
vm_id = data.proxmox_virtual_environment_vms.template.vms[0].vm_id
full = true
}
cpu {
cores = var.platform_vm.cores
type = "host"
}
memory {
dedicated = var.platform_vm.memory
}
disk {
datastore_id = var.vm_disk_datastore
size = var.platform_vm.disk_gb
interface = "scsi0"
}
network_device {
bridge = "vmbr0"
}
initialization {
user_account {
username = "rootnode-deploy"
keys = [var.ssh_public_key]
}
ip_config {
ipv4 {
address = "dhcp" # static assignment is a deploy-time decision once the real network
# plan is finalized — see docs/PRODUCTION_NETWORK_SECURITY.md §5
}
}
}
tags = ["rootnode", "platform"]
}
resource "proxmox_virtual_environment_vm" "rn_lab_host_01" {
name = "rn-lab-host-01"
node_name = var.proxmox_node
clone {
vm_id = data.proxmox_virtual_environment_vms.template.vms[0].vm_id
full = true
}
cpu {
cores = var.lab_host_vm.cores
type = "host"
}
memory {
dedicated = var.lab_host_vm.memory
}
disk {
datastore_id = var.vm_disk_datastore
size = var.lab_host_vm.disk_gb
interface = "scsi0"
}
network_device {
bridge = "vmbr0"
}
initialization {
user_account {
username = "rootnode-deploy"
keys = [var.ssh_public_key]
}
ip_config {
ipv4 {
address = "dhcp"
}
}
}
tags = ["rootnode", "lab-host"]
}
data "proxmox_virtual_environment_vms" "template" {
node_name = var.proxmox_node
tags = ["template"]
filter {
name = "name"
values = [var.vm_template_name]
}
}
output "rn_platform_01_ip" {
value = proxmox_virtual_environment_vm.rn_platform_01.ipv4_addresses
}
output "rn_lab_host_01_ip" {
value = proxmox_virtual_environment_vm.rn_lab_host_01.ipv4_addresses
}