2026-07-20 18:19:45 -07:00
|
|
|
# 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.
|
|
|
|
|
#
|
2026-07-20 23:38:43 -07:00
|
|
|
# Ordering: bmpgen's cloud-init needs VM-A's IP. With a static CIDR it's
|
|
|
|
|
# known at plan time; with DHCP we defer to store.ipv4_addresses (populated
|
|
|
|
|
# only after the store VM boots and its qemu-guest-agent reports). That
|
|
|
|
|
# reference creates an implicit dependency, so bmpgen's snippet upload +
|
|
|
|
|
# VM creation both wait until the store's address is known.
|
2026-07-20 18:19:45 -07:00
|
|
|
|
|
|
|
|
locals {
|
|
|
|
|
bmpgen_hostname = "obmp-bmpgen-test"
|
|
|
|
|
|
2026-07-20 23:38:43 -07:00
|
|
|
# Resolve store's address: static CIDR var wins; otherwise fall back to
|
|
|
|
|
# the store VM's guest-agent-reported IPv4. ipv4_addresses is a list of
|
|
|
|
|
# lists (one per interface); index [1][0] is the first NIC's first non-
|
|
|
|
|
# loopback address. try() keeps plan output tidy when the attribute
|
|
|
|
|
# doesn't exist yet.
|
|
|
|
|
bmpgen_store_addr = (
|
|
|
|
|
var.store_vm_ip_cidr != ""
|
|
|
|
|
? split("/", var.store_vm_ip_cidr)[0]
|
|
|
|
|
: try(proxmox_virtual_environment_vm.store.ipv4_addresses[1][0], "")
|
|
|
|
|
)
|
2026-07-20 18:19:45 -07:00
|
|
|
|
|
|
|
|
bmpgen_user_data = templatefile("${path.module}/cloud-init/bmpgen.cloud-init.yaml.tftpl", {
|
2026-07-20 18:33:39 -07:00
|
|
|
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
|
2026-07-20 18:19:45 -07:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
2026-07-20 18:33:39 -07:00
|
|
|
file_id = proxmox_download_file.ubuntu_noble.id
|
2026-07-20 18:19:45 -07:00
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
}
|