#!/bin/bash # ============================================================================== # SINGLE-COMMAND BOOTSTRAP: IP, DOCKER, ANSIBLE # Target: Ubuntu / Debian # ============================================================================== set -euo pipefail # --- 1. SET STATIC IP (Netplan) --- echo "[⚙] Configuring Static IP to 10.0.0.200..." # Find the active physical interface (e.g., eth0, enp3s0) INTERFACE=$(ip -o link show | awk -F': ' '$2 != "lo" {print $2}' | head -n1) sudo mkdir -p /etc/netplan sudo cat < /etc/netplan/01-netcfg.yaml network: version: 2 renderer: networkd ethernets: $INTERFACE: addresses: - 10.0.0.200/24 nameservers: addresses: [10.0.0.2, 8.8.8.8] routes: - to: default via: 10.0.0.1 EOF echo "[✓] Netplan config created. Applying in background..." # We apply in background so the script doesn't hang if SSH drops sudo netplan apply & # --- 2. INSTALL DOCKER --- echo "[⚙] Installing Docker..." sudo apt-get update -qq sudo apt-get install -y ca-certificates curl gnupg lsb-release sudo mkdir -p /etc/apt/keyrings curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg --yes echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | \ sudo tee /etc/apt/sources.list.d/docker.list > /dev/null sudo apt-get update -qq sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin # Allow current user to run docker without sudo sudo usermod -aG docker $USER echo "[✓] Docker installed." # --- 3. INSTALL ANSIBLE --- echo "[⚙] Installing Ansible..." sudo apt-get install -y software-properties-common sudo add-apt-repository --yes --update ppa:ansible/ansible sudo apt-get install -y ansible echo "[✓] Ansible installed." echo "==========================================" echo "BOOTSTRAP COMPLETE" echo "IP: 10.0.0.200 (You may need to reconnect)" echo "Docker & Ansible: Ready" echo "=========================================="