# Root module: wires the network + storage-pool layer for VR1 (Stage 1-2 of
# docs/dc-dc-deployment-workflow.md). See opentofu/README.md for full scope,
# what is deliberately deferred, and why.
provider "libvirt" {
uri = var.libvirt_uri
}
# ---- The provider "maas" CONFIG block is deliberately DEFERRED to Stage 3
# (DOCFIX-179, decided on the first real `tofu plan`). No module instantiated in
# Stage 1-2 uses the maas provider (modules/maas-vm-host is a Stage-3 module,
# commented out below), yet a configured provider "maas" block here forced
# `tofu plan` to demand maas_api_url AND the SENSITIVE maas_api_key for a plan
# that creates ZERO MAAS resources -- which would bake a fake key into
# plan/state (the DOCFIX-175 plaintext-secret surface). maas stays in
# versions.tf's required_providers (version pinned, lock-file complete); Stage 3
# re-adds this provider block + its two variables when it actually instantiates
# modules/maas-vm-host. modules/netem-link is likewise not instantiated yet
# (needs a real bridge/SSH target + netem params). See gap register items
# 2/4/11 and opentofu/README.md. ----
# ---- DC1: inherits the DC0 six-plane v4 layout unchanged (D-101) ----
module "dc1_planes" {
source = "./modules/dc-planes"
dc_name = "dc1"
domain_suffix = var.domain_suffix
mtu = var.underlay_mtu
planes = var.dc1_planes
}
module "dc1_storage" {
source = "./modules/dc-storage-pool"
dc_name = "dc1"
target_path = var.dc1_pool_path
}
# ---- DC2: PLANES deferred (operator ruling 2026-07-10, Option B) -- wait for
# NetBox to assign D-101's supernet/ULA/GUA before wiring dc2_planes. Do NOT
# fill in guessed CIDRs to make it "work" sooner. When NetBox assigns it, add a
# `dc2_planes` variable (same shape as `dc1_planes`) and uncomment this block.
# The storage pool + mesh legs are NOT address-dependent, so they ARE wired now.
#
# module "dc2_planes" {
# source = "./modules/dc-planes"
# dc_name = "dc2"
# domain_suffix = var.domain_suffix
# mtu = var.underlay_mtu
# planes = var.dc2_planes
# }
module "dc2_storage" {
source = "./modules/dc-storage-pool"
dc_name = "dc2"
target_path = var.dc2_pool_path
}
# ---- Office1 headend: its own storage pool for MAAS-region/NetBox/GitBucket
# service-VM disks (D-103). Office1 does not get a dc-planes module -- the
# six-plane template is per-OpenStack-DC, not per-headend. ----
module "office1_storage" {
source = "./modules/dc-storage-pool"
dc_name = "office1"
target_path = var.office1_pool_path
}
# ---- Office1-local network (closes tooling gap register item #12): the
# shared L2 segment the three Office1 service VMs (MAAS-region, NetBox,
# GitBucket), the vcloud host's own management interface, and Office1's own
# OPNsense edge's LAN side (gap #16) all attach to. See
# modules/office1-network/main.tf's header for the design decision (a new
# module, not a reused host bridge) and opentofu/README.md for the full
# writeup. Instantiated for real here (unlike office1_opnsense below): it
# needs no value beyond domain_suffix/underlay_mtu, both already real,
# required inputs elsewhere in this file -- the same reasoning that already
# lets the three mesh-link legs be instantiated today. ----
module "office1_network" {
source = "./modules/office1-network"
domain_suffix = var.domain_suffix
mtu = var.underlay_mtu
}
# ---- Office1's own OPNsense edge (closes tooling gap register item #16 --
# decision: YES, Office1 gets a fourth modules/opnsense-edge call alongside
# DC1/DC2, and Stage 2's runbook (runbooks/dc-dc-phase1-office1-standup.md)
# owns creating it -- see that runbook's new Step 4b and its "Open questions"
# section for the full reasoning). NOT instantiated below -- commented out on
# purpose, mirroring the identical NOT-YET-REAL status of module
# "dc1_opnsense"/"dc2_opnsense" (see runbooks/dc-dc-phase2-tofu-dc-substrate.md
# Step 5's own template, which is ALSO still all placeholders, nothing
# committed here either). Every value below needs to be real before this is
# uncommented -- do not fill in invented specs to wire it in sooner:
#
# Office1's own OPNsense simulated-ISP edge (gap #16 CLOSED). gap #17 resolved
# for Office1 via the `office1-wan` NAT network (created via virsh 2026-07-12 --
# a documented D-103 debt to formalize into an OpenTofu module later, same class
# as the retained `wan`). LAN = the Office1-local segment; WAN = office1-wan (its
# own simulated ISP -> internet). Config is the DOCFIX-185 real-ISP-router config
# (no egress-airgap), rendered to office1-opnsense-config.iso.
module "office1_opnsense" {
source = "./modules/opnsense-edge"
vm_name = "office1-opnsense"
memory_mib = 2048
vcpu = 2
pool_name = module.office1_storage.pool_name
base_volume_path = "/var/lib/libvirt/vr1/office1/opnsense-26.1-nano.qcow2"
# No disk_size_bytes: the disk is a direct copy of the prepped nano, so its size comes
# from scripts/opnsense-prep-image.sh's GROW (default +8G -> 11 GiB). The old
# `disk_size_bytes = 16 GiB` here was SILENTLY IGNORED -- measured: the live volume is
# 11 GiB. Removed in DOCFIX-189.
lan_network_name = module.office1_network.network_name
wan_network_name = "office1-wan"
}
# ---- The D-100 dark-fiber mesh triangle: DC1<->DC2, DC1<->Office1,
# DC2<->Office1 -- mesh, not star. All three legs created now even though DC2
# itself is not yet wired above: the LINK is independent of whether DC2's
# plane networks exist yet, and Phase 0's gate wants "virtual networks present
# and isolated as designed" before Phase 2 needs them. ----
module "mesh_dc1_dc2" {
source = "./modules/mesh-link"
link_name = "dc1-dc2"
mtu = var.underlay_mtu
}
module "mesh_dc1_office1" {
source = "./modules/mesh-link"
link_name = "dc1-office1"
mtu = var.underlay_mtu
}
module "mesh_dc2_office1" {
source = "./modules/mesh-link"
link_name = "dc2-office1"
mtu = var.underlay_mtu
}