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>
87 lines
3.3 KiB
Plaintext
87 lines
3.3 KiB
Plaintext
#cloud-config
|
|
# Store VM cloud-init: install docker + git, clone obmp-docker, write a
|
|
# portable .env, run deploy.sh --scope full-stack --auth local --yes.
|
|
#
|
|
# All completion / status writes to /var/lib/cloud/portability-test.done
|
|
# so run-test.sh can poll for readiness without guessing.
|
|
|
|
hostname: ${hostname}
|
|
manage_etc_hosts: true
|
|
|
|
users:
|
|
- name: ${ssh_username}
|
|
groups: [sudo, docker]
|
|
shell: /bin/bash
|
|
sudo: "ALL=(ALL) NOPASSWD:ALL"
|
|
ssh_authorized_keys:
|
|
- ${ssh_public_key}
|
|
|
|
package_update: true
|
|
package_upgrade: false
|
|
|
|
packages:
|
|
- ca-certificates
|
|
- curl
|
|
- git
|
|
- gnupg
|
|
- jq
|
|
- lsb-release
|
|
- qemu-guest-agent
|
|
|
|
runcmd:
|
|
# --- 1. install docker-ce from the official repo (docker.io in Ubuntu
|
|
# noble is old enough to cause compose issues; matches what obmp-docker
|
|
# deploy.sh expects) -----------------------------------------------------
|
|
- install -m 0755 -d /etc/apt/keyrings
|
|
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
|
|
- chmod a+r /etc/apt/keyrings/docker.gpg
|
|
- |
|
|
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" \
|
|
> /etc/apt/sources.list.d/docker.list
|
|
- apt-get update
|
|
- apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
|
|
- systemctl enable --now docker qemu-guest-agent
|
|
- usermod -aG docker ${ssh_username}
|
|
|
|
# --- 2. resolve HOST_IP: static value if provided, else `hostname -I` --
|
|
- |
|
|
set -eu
|
|
if [ -n "${static_ip_addr}" ]; then
|
|
HOST_IP="${static_ip_addr}"
|
|
else
|
|
HOST_IP="$(hostname -I | awk '{print $1}')"
|
|
fi
|
|
echo "$HOST_IP" > /var/lib/cloud/host_ip
|
|
|
|
# --- 3. clone the obmp-docker repo -------------------------------------
|
|
- sudo -u ${ssh_username} git clone ${obmp_repo_url} /home/${ssh_username}/obmp-docker
|
|
- sudo -u ${ssh_username} git -C /home/${ssh_username}/obmp-docker checkout ${obmp_repo_ref}
|
|
|
|
# --- 4. seed .env with test-topology values ----------------------------
|
|
- |
|
|
set -eu
|
|
HOST_IP="$(cat /var/lib/cloud/host_ip)"
|
|
cd /home/${ssh_username}/obmp-docker
|
|
sudo -u ${ssh_username} cp .env.example .env
|
|
sed -i "s|^HOST_IP=.*|HOST_IP=$HOST_IP|" .env
|
|
sed -i "s|^ROUTER_FACING_IP=.*|ROUTER_FACING_IP=$HOST_IP|" .env
|
|
sed -i "s|^ROUTER_FACING_PORT=.*|ROUTER_FACING_PORT=${router_facing_port}|" .env
|
|
sed -i "s|^OBMP_AUTH_MODE=.*|OBMP_AUTH_MODE=local|" .env
|
|
chown ${ssh_username}:${ssh_username} .env
|
|
|
|
# --- 5. run deploy.sh (drops permissions to the ubuntu user) ----------
|
|
- |
|
|
set +e
|
|
cd /home/${ssh_username}/obmp-docker
|
|
sudo -u ${ssh_username} \
|
|
HOME=/home/${ssh_username} \
|
|
./deploy.sh --scope full-stack --auth local --yes \
|
|
> /var/log/obmp-deploy.log 2>&1
|
|
rc=$?
|
|
echo "deploy_exit=$rc" > /var/lib/cloud/portability-test.done
|
|
echo "finished_at=$(date -Is)" >> /var/lib/cloud/portability-test.done
|
|
echo "host_ip=$(cat /var/lib/cloud/host_ip)" >> /var/lib/cloud/portability-test.done
|
|
exit 0
|
|
|
|
final_message: "obmp-store cloud-init done after $UPTIME seconds. Marker: /var/lib/cloud/portability-test.done"
|