Added terraform for lightning-lane

This commit is contained in:
2026-03-07 21:18:36 -06:00
parent 7d7129632f
commit a349ce13f8
5 changed files with 178 additions and 0 deletions

10
terraform/proxmox/hosts/.gitignore vendored Normal file
View File

@@ -0,0 +1,10 @@
# Terraform state files contain sensitive data — never commit
states/
# Terraform working directories
.terraform/
.terraform.lock.hcl
# Crash logs
crash.log
crash.*.log

View File

@@ -0,0 +1,29 @@
# ─── Host Provisioning ───────────────────────────────────────────────────────
# Root module that calls the shared VM module.
# Per-host values come from tfvars files.
# Sensitive values come from CLI arguments.
#
# Usage:
# terraform apply \
# -var-file="tfvars/lightning-lane.tfvars" \
# -state="states/lightning-lane.tfstate" \
# -var="proxmox_api_url=https://main-street-usa.local.mk-labs.cloud:8006" \
# -var="proxmox_api_token=terraform@pve!automation=<token>"
module "vm" {
source = "../vm"
proxmox_api_url = var.proxmox_api_url
proxmox_api_token = var.proxmox_api_token
hostname = var.hostname
vm_id = var.vm_id
ip_address = var.ip_address
target_node = var.target_node
clone_node = var.clone_node
template_name = var.template_name
datastore = var.datastore
bridge = var.bridge
dns_servers = var.dns_servers
search_domain = var.search_domain
}

View File

@@ -0,0 +1,21 @@
# ─── Outputs ─────────────────────────────────────────────────────────────────
output "vm_id" {
description = "Proxmox VM ID"
value = module.vm.vm_id
}
output "hostname" {
description = "VM hostname"
value = var.hostname
}
output "ip_address" {
description = "VM IP address"
value = var.ip_address
}
output "target_node" {
description = "Proxmox node the VM is placed on"
value = var.target_node
}

View File

@@ -0,0 +1,24 @@
# ─── Provider Configuration ──────────────────────────────────────────────────
# Shared provider for all host deployments.
# Sensitive values are passed via CLI at apply time.
terraform {
required_version = ">= 1.5"
required_providers {
proxmox = {
source = "bpg/proxmox"
version = ">= 0.78.0"
}
}
}
provider "proxmox" {
endpoint = var.proxmox_api_url
api_token = var.proxmox_api_token
insecure = true
ssh {
agent = false
}
}

View File

@@ -0,0 +1,94 @@
# ─── Provider Authentication ─────────────────────────────────────────────────
# Passed via CLI — never stored in tfvars.
variable "proxmox_api_url" {
type = string
description = "Proxmox API endpoint URL (e.g., https://main-street-usa.local.mk-labs.cloud:8006)"
}
variable "proxmox_api_token" {
type = string
description = "Proxmox API token in format: user@realm!token-name=token-secret"
sensitive = true
}
# ─── VM Identity ─────────────────────────────────────────────────────────────
variable "vm_id" {
type = number
description = "Proxmox VM ID. Convention: {third_octet}{fourth_octet:03d} (e.g., 10.1.71.35 → 71035)."
}
variable "hostname" {
type = string
description = "VM hostname. Used as the Proxmox VM name and cloud-init hostname."
}
variable "ip_address" {
type = string
description = "Primary IP address for the VM (without CIDR, e.g., 10.1.71.35)."
}
variable "dns_servers" {
type = list(string)
description = "DNS servers for the VM."
default = ["10.1.71.1"]
}
variable "search_domain" {
type = string
description = "DNS search domain for the VM."
default = "local.mk-labs.cloud"
}
# ─── Proxmox Placement ──────────────────────────────────────────────────────
variable "clone_node" {
type = string
description = "Proxmox node where templates live."
default = "fantasyland"
}
variable "target_node" {
type = string
description = "Proxmox node for final VM placement."
}
variable "datastore" {
type = string
description = "Proxmox storage pool for VM disks."
default = "liberty-tree"
}
# ─── Template Selection ─────────────────────────────────────────────────────
variable "template_name" {
type = string
description = "Name of the Proxmox VM template to clone."
validation {
condition = contains([
"ubuntu-24.04-small",
"ubuntu-24.04-medium",
"ubuntu-24.04-large",
"ubuntu-24.04-large-plus",
"ubuntu-24.04-xlarge",
"ubuntu-24.04-xlarge-plus",
], var.template_name)
error_message = "template_name must be a valid Ubuntu 24.04 template."
}
}
# ─── Network ─────────────────────────────────────────────────────────────────
variable "vlan_id" {
type = number
description = "VLAN tag for the VM network interface."
default = 71
}
variable "bridge" {
type = string
description = "Proxmox network bridge for the VM."
default = "vmbr0"
}