#!/usr/bin/env bash # # One-time host provisioning for newsfeed's CI-driven deploy (architecture # deployment-gitea-actions.md §2). Run by the operator from a workstation with full sudo # and mesh ssh access — NOT by the CI runner. Idempotent; skips unreachable hosts. # # It provisions, per host: # * the `gitea_ci` deploy user + the runner's authorized_key + systemd-journal group # * a scoped /etc/sudoers.d/newsfeed_gitea_ci drop-in (visudo-verified) # and per role: # * API host (slartibartfast): the `newsfeed` service account, /etc/newsfeed + # /var/lib/newsfeed, SELinux port label for 8081, firewalld service # * WEB host (oolon): /var/www/newsfeed webroot, the internal `newsfeed.internal` TLS # cert (lair provisioner) + step@newsfeed renewal, and the nginx vhost # # Usage: ./script/infra-setup.sh [--dry-run] set -euo pipefail # --- infra truth (edit here if the topology changes) ------------------------------- API_HOST="slartibartfast.kosherinata.internal" # newsfeed-api + newsfeed-worker WEB_HOST="oolon.kosherinata.internal" # nginx: SPA + API reverse proxy API_PORT="8081" CERT_NAME="newsfeed" # dot-free; serves ${CERT_NAME}.internal RUNNER_PUBKEY="${HOME}/.ssh/id_gitea_ci.pub" # runner key distributed to gitea_ci PROVISIONER_PW="${HOME}/.step/secrets/provisioner" ROOT_CA="/etc/pki/ca-trust/source/anchors/root-internal.pem" CA_URL="https://ca.internal" REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" DRY_RUN=0 [[ "${1:-}" == "--dry-run" ]] && DRY_RUN=1 info() { printf '\033[1;34m==>\033[0m %s\n' "$*"; } warn() { printf '\033[1;33mWARN\033[0m %s\n' "$*" >&2; } run_remote() { # run_remote