TFVars wrote vmid_base and hostpci, which only the Proxmox environment understands. A second backend would have had to declare and ignore them. The variables the runner writes are now listed in provision.Contract and say what the cluster is, not how Proxmox builds it: devices replaces hostpci, and the Proxmox environment derives vmid_base from cluster_id itself (still overridable, which `hpcod provision -vmid-base` now does). A test holds every terraform/envs/*/variables.tf to the contract and TFVars to nothing outside it. Checked by planning the Proxmox environment offline for the same cluster before and after: the planned resources and outputs are byte-identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
102 lines
2.9 KiB
Terraform
102 lines
2.9 KiB
Terraform
# One tenant on the lab Proxmox, for exercising the module end to end.
|
|
#
|
|
# Sizing is deliberately small: hv01 is already carrying 22 other guests, so a
|
|
# test tenant should not be the thing that pushes it over.
|
|
|
|
terraform {
|
|
required_version = ">= 1.6"
|
|
required_providers {
|
|
proxmox = {
|
|
source = "bpg/proxmox"
|
|
version = ">= 0.66"
|
|
}
|
|
}
|
|
}
|
|
|
|
provider "proxmox" {
|
|
endpoint = var.pve_endpoint
|
|
api_token = var.pve_token
|
|
insecure = var.pve_insecure
|
|
|
|
# Creating a Linux bridge goes through the node's network API, which the
|
|
# provider drives over SSH rather than the REST API. The provider uses a Go
|
|
# SSH client, so it ignores ProxyJump in ~/.ssh/config - when Proxmox is only
|
|
# reachable through a jump host, tunnel port 22 and override the node address.
|
|
ssh {
|
|
agent = false
|
|
username = var.pve_ssh_user
|
|
private_key = file(var.pve_ssh_private_key)
|
|
|
|
dynamic "node" {
|
|
for_each = var.pve_ssh_override == null ? [] : [var.pve_ssh_override]
|
|
content {
|
|
name = var.node_name
|
|
address = node.value.address
|
|
port = node.value.port
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
locals {
|
|
# Allocated from cluster_id rather than Proxmox's nextid, which races when
|
|
# two clusters are created at once. cluster_id is unique among live
|
|
# clusters, and each one takes ten VMIDs.
|
|
vmid_base = coalesce(var.vmid_base, 9000 + 10 * var.cluster_id)
|
|
}
|
|
|
|
module "tenant" {
|
|
source = "../../modules/tenant"
|
|
|
|
cluster_id = var.cluster_id
|
|
sdn_zone = var.sdn_zone
|
|
sdn_zone_type = var.sdn_zone_type
|
|
apps = var.apps
|
|
tenant_id = var.tenant_id
|
|
snippet_datastore_id = var.snippet_datastore_id
|
|
tenant_name = var.tenant_name
|
|
node_name = var.node_name
|
|
|
|
# Where the planner put each guest, and which cards it gave them. Without
|
|
# these the module falls back to one hypervisor and no passthrough, which
|
|
# is the decision being thrown away rather than carried out.
|
|
head_host = var.head_host
|
|
compute_hosts = var.compute_hosts
|
|
hostpci = var.devices
|
|
|
|
control_plane_cert = var.control_plane_cert
|
|
|
|
image_file_id = var.image_file_id
|
|
head_template_vmid = var.head_template_vmid
|
|
datastore_id = var.datastore_id
|
|
|
|
mgmt_bridge = var.mgmt_bridge
|
|
mgmt_ip_cidr = var.mgmt_ip_cidr
|
|
mgmt_gateway = var.mgmt_gateway
|
|
|
|
vmid_base = local.vmid_base
|
|
|
|
head = var.head
|
|
compute = var.compute
|
|
|
|
ssh_public_keys = var.ssh_public_keys
|
|
ci_user = var.ci_user
|
|
|
|
# Compute nodes PXE boot from the head node, so they stay powered off until
|
|
# Warewulf has been configured on it. Phase 4 turns them on.
|
|
started = var.started
|
|
}
|
|
|
|
output "tenant" {
|
|
value = {
|
|
bridge = module.tenant.bridge
|
|
subnet = module.tenant.subnet
|
|
head = module.tenant.head
|
|
compute = module.tenant.compute
|
|
}
|
|
}
|
|
|
|
output "ansible_inventory" {
|
|
value = module.tenant.ansible_inventory
|
|
}
|