feat(terraform): add Proxmox VM and Unifi DHCP modules (Phase 2)
This commit is contained in:
12
terraform/unifi/dhcp/main.tf
Normal file
12
terraform/unifi/dhcp/main.tf
Normal file
@@ -0,0 +1,12 @@
|
||||
# ─── DHCP Static Reservation ─────────────────────────────────────────────────
|
||||
# Creates a fixed IP assignment on the UDM Pro for the newly provisioned VM.
|
||||
# Triggered by n8n after Proxmox VM creation returns the MAC address.
|
||||
|
||||
resource "unifi_user" "vm" {
|
||||
name = var.hostname
|
||||
mac = lower(var.mac_address)
|
||||
fixed_ip = var.ip_address
|
||||
network_id = var.network_id
|
||||
|
||||
note = "Managed by mk-labs pipeline"
|
||||
}
|
||||
4
terraform/unifi/dhcp/outputs.tf
Normal file
4
terraform/unifi/dhcp/outputs.tf
Normal file
@@ -0,0 +1,4 @@
|
||||
output "reservation_id" {
|
||||
description = "Unifi user/client ID for the DHCP reservation."
|
||||
value = unifi_user.vm.id
|
||||
}
|
||||
19
terraform/unifi/dhcp/providers.tf
Normal file
19
terraform/unifi/dhcp/providers.tf
Normal file
@@ -0,0 +1,19 @@
|
||||
terraform {
|
||||
required_version = ">= 1.5.0"
|
||||
|
||||
required_providers {
|
||||
unifi = {
|
||||
source = "paultyng/unifi"
|
||||
version = ">= 0.41.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "unifi" {
|
||||
username = var.unifi_username
|
||||
password = var.unifi_password
|
||||
api_url = var.unifi_api_url
|
||||
|
||||
# Set to true if using a self-signed certificate
|
||||
allow_insecure = true
|
||||
}
|
||||
12
terraform/unifi/dhcp/terraform.tfvars.example
Normal file
12
terraform/unifi/dhcp/terraform.tfvars.example
Normal file
@@ -0,0 +1,12 @@
|
||||
# Copy this file to terraform.tfvars and fill in the values.
|
||||
# terraform.tfvars is in .gitignore — never commit secrets.
|
||||
|
||||
unifi_username = "admin"
|
||||
unifi_password = "your-password-here"
|
||||
unifi_api_url = "https://10.1.0.1:443"
|
||||
|
||||
# These values come from n8n via -var flags at runtime:
|
||||
# hostname = "test-vm"
|
||||
# mac_address = "AA:BB:CC:DD:EE:FF"
|
||||
# ip_address = "10.1.71.100"
|
||||
# network_id = "your-server-trusted-network-id"
|
||||
41
terraform/unifi/dhcp/variables.tf
Normal file
41
terraform/unifi/dhcp/variables.tf
Normal file
@@ -0,0 +1,41 @@
|
||||
# ─── Provider Authentication ─────────────────────────────────────────────────
|
||||
|
||||
variable "unifi_username" {
|
||||
type = string
|
||||
description = "Unifi controller username."
|
||||
sensitive = true
|
||||
}
|
||||
|
||||
variable "unifi_password" {
|
||||
type = string
|
||||
description = "Unifi controller password."
|
||||
sensitive = true
|
||||
}
|
||||
|
||||
variable "unifi_api_url" {
|
||||
type = string
|
||||
description = "Unifi controller API URL (e.g., https://10.1.0.1:443)."
|
||||
}
|
||||
|
||||
# ─── DHCP Reservation ───────────────────────────────────────────────────────
|
||||
|
||||
variable "hostname" {
|
||||
type = string
|
||||
description = "Hostname for the DHCP reservation. Used as the client name."
|
||||
}
|
||||
|
||||
variable "mac_address" {
|
||||
type = string
|
||||
description = "MAC address of the VM network interface (from Terraform Proxmox output)."
|
||||
}
|
||||
|
||||
variable "ip_address" {
|
||||
type = string
|
||||
description = "Fixed IP address for the DHCP reservation (without CIDR, e.g., 10.1.71.100)."
|
||||
}
|
||||
|
||||
variable "network_id" {
|
||||
type = string
|
||||
description = "Unifi network ID for the DHCP reservation."
|
||||
default = ""
|
||||
}
|
||||
Reference in New Issue
Block a user