Files
homelab-iac/modules/foundry/main.tf

86 lines
2.1 KiB
HCL

/**
* # Foundry Module
*
* Creates a Proxmox LXC container running Foundry Virtual Tabletop.
* Supports configurable resources, networking, and static or DHCP addressing.
*/
terraform {
required_providers {
proxmox = {
source = "bpg/proxmox"
}
}
}
resource "proxmox_virtual_environment_container" "foundry" {
node_name = var.node_name
vm_id = var.container_id > 0 ? var.container_id : null
description = "Foundry VTT - managed by OpenTofu"
tags = var.tags
unprivileged = var.unprivileged
start_on_boot = var.start_on_boot
started = var.start_on_create
# ── OS Template ────────────────────────────────────────────
operating_system {
template_file_id = var.template
type = "ubuntu"
}
# ── Features ───────────────────────────────────────────────
# nesting is required for systemd >= 257 (Ubuntu 25.04+)
features {
nesting = true
}
# ── Resources ──────────────────────────────────────────────
cpu {
cores = var.cores
}
memory {
dedicated = var.memory
swap = var.swap
}
disk {
datastore_id = var.datastore_id
size = var.disk_size
}
# ── Networking ─────────────────────────────────────────────
network_interface {
name = "eth0"
bridge = var.bridge
vlan_id = var.vlan_tag
}
initialization {
hostname = var.hostname
ip_config {
ipv4 {
address = var.ip_address
gateway = var.gateway != "" ? var.gateway : null
}
}
dns {
domain = var.dns_domain
servers = [var.dns_server]
}
user_account {
keys = [var.ssh_pubkey]
}
}
# Ignore template changes so we don't recreate on minor template updates
lifecycle {
ignore_changes = [operating_system]
}
}