#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"