Terraform (bpg/proxmox) provisions two Ubuntu 24.04 cloud-init VMs on a Proxmox host, one running obmp-docker's `deploy.sh --scope full-stack` and the other running GoBGP as a BMP-source stand-in. `scripts/run-test.sh` runs the six assertions from docs/design.md (containers healthy, BMP peer up, ip_rib/bgp_peers non-zero, Grafana healthcheck). Layout: terraform/ provider + VM + cloud-init snippet resources terraform/cloud-init/ user-data templates (store + bmpgen) scripts/ run-test.sh, teardown.sh docs/design.md topology, assertion set, and rationale Cred handling: terraform.tfvars is gitignored; endpoint + api_token can also come from PROXMOX_VE_ENDPOINT / PROXMOX_VE_API_TOKEN env vars. Not validated locally: `terraform init && terraform validate` -- the terraform binary is not on the authoring host. YAML + shell + HCL brace balance verified. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
90 lines
2.6 KiB
HCL
90 lines
2.6 KiB
HCL
# VM B -- GoBGP standing in for a real BGP router. Cloud-init installs
|
|
# docker and runs a gobgp container configured to BMP-report to VM A.
|
|
#
|
|
# `depends_on` on the store VM's cloud-init snippet, not the store VM
|
|
# itself -- we don't want to wait for the store's cloud-init to finish
|
|
# before launching B (cloud-init on B will retry the BMP session until A
|
|
# is ready).
|
|
|
|
locals {
|
|
bmpgen_hostname = "obmp-bmpgen-test"
|
|
|
|
# If DHCP, we don't know VM-A's address at plan time and cloud-init on
|
|
# VM-B will need it. We handle both cases in the template:
|
|
# - static: pass store_ip_addr directly
|
|
# - DHCP: cloud-init on B does an ARP scan + hostname lookup at boot
|
|
# (kept out-of-scope here; DHCP + this test is best-effort)
|
|
bmpgen_store_addr = var.store_vm_ip_cidr != "" ? split("/", var.store_vm_ip_cidr)[0] : ""
|
|
|
|
bmpgen_user_data = templatefile("${path.module}/cloud-init/bmpgen.cloud-init.yaml.tftpl", {
|
|
hostname = local.bmpgen_hostname
|
|
ssh_username = var.ssh_username
|
|
ssh_public_key = trimspace(file(var.ssh_public_key_path))
|
|
store_ip_addr = local.bmpgen_store_addr
|
|
router_facing_port = var.router_facing_port
|
|
local_asn = var.test_local_asn
|
|
})
|
|
}
|
|
|
|
resource "proxmox_virtual_environment_file" "bmpgen_cloud_init" {
|
|
content_type = "snippets"
|
|
datastore_id = var.snippet_storage
|
|
node_name = var.pve_node
|
|
|
|
source_raw {
|
|
file_name = "obmp-bmpgen-user-data.yaml"
|
|
data = local.bmpgen_user_data
|
|
}
|
|
}
|
|
|
|
resource "proxmox_virtual_environment_vm" "bmpgen" {
|
|
name = local.bmpgen_hostname
|
|
description = "OpenBMP portability-test BMPGEN VM (managed by terraform)"
|
|
tags = ["obmp", "portability-test", "bmpgen"]
|
|
node_name = var.pve_node
|
|
vm_id = var.bmpgen_vm_id
|
|
|
|
agent { enabled = true }
|
|
cpu {
|
|
cores = 2
|
|
type = "host"
|
|
}
|
|
memory {
|
|
dedicated = 2048
|
|
}
|
|
|
|
disk {
|
|
datastore_id = var.vm_storage_pool
|
|
file_id = proxmox_virtual_environment_download_file.ubuntu_noble.id
|
|
interface = "scsi0"
|
|
size = 16
|
|
ssd = true
|
|
discard = "on"
|
|
}
|
|
|
|
network_device {
|
|
bridge = var.vm_bridge
|
|
model = "virtio"
|
|
vlan_id = var.vm_vlan_tag != 0 ? var.vm_vlan_tag : null
|
|
}
|
|
|
|
operating_system { type = "l26" }
|
|
|
|
initialization {
|
|
datastore_id = var.vm_storage_pool
|
|
|
|
ip_config {
|
|
ipv4 {
|
|
address = var.bmpgen_vm_ip_cidr != "" ? var.bmpgen_vm_ip_cidr : "dhcp"
|
|
gateway = var.bmpgen_vm_ip_cidr != "" ? var.vm_gateway : null
|
|
}
|
|
}
|
|
|
|
dns {
|
|
servers = var.vm_dns_servers
|
|
}
|
|
|
|
user_data_file_id = proxmox_virtual_environment_file.bmpgen_cloud_init.id
|
|
}
|
|
}
|