diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml index a12537f..a6b3041 100644 --- a/.gitea/workflows/deploy.yaml +++ b/.gitea/workflows/deploy.yaml @@ -197,6 +197,29 @@ jobs: ssh -i ~/.ssh/id_gitea_ci -o StrictHostKeyChecking=accept-new \ gitea_ci@${{ matrix.host }} hostname -f + - name: preflight — sudoers covers this deploy + run: | + set -euo pipefail + SSHOPTS="-i $HOME/.ssh/id_gitea_ci -o StrictHostKeyChecking=accept-new" + # Every path infra-setup.sh grants for this role must already be + # permitted on the host. Adding an asset here without re-running + # infra-setup produces a bare "sudo: a password is required" forty + # lines into the deploy, after some files have already landed. Compare + # up front instead, from infra-setup.sh itself so the two cannot drift. + sed -n "/quantus-node_gitea_ci.tmp/,/^SUDO$/p" script/infra-setup.sh \ + | grep '^gitea_ci ALL=' | grep -oE '(/etc|/usr|/var)/[^ ]*' | sort -u > expected-paths.txt + ssh $SSHOPTS gitea_ci@${{ matrix.host }} 'sudo -n -l' \ + | grep -oE '(/etc|/usr|/var)/[^ ]*' | sort -u > permitted-paths.txt + comm -23 expected-paths.txt permitted-paths.txt > missing-paths.txt + if [ -s missing-paths.txt ]; then + echo "the node sudoers on ${{ matrix.host }} is out of date." >&2 + echo "not permitted, but this deploy needs them:" >&2 + sed 's/^/ /' missing-paths.txt >&2 + echo "" >&2 + echo "run: ./script/infra-setup.sh --pubkey ~/.ssh/id_gitea_ci.pub" >&2 + exit 1 + fi + echo "sudoers covers all $(wc -l < expected-paths.txt) paths this deploy needs" - name: render node config if: ${{ github.event.inputs.mode != 'validate' }} env: @@ -569,6 +592,29 @@ jobs: ssh -i ~/.ssh/id_gitea_ci -o StrictHostKeyChecking=accept-new \ gitea_ci@${{ matrix.host }} hostname -f + - name: preflight — sudoers covers this deploy + run: | + set -euo pipefail + SSHOPTS="-i $HOME/.ssh/id_gitea_ci -o StrictHostKeyChecking=accept-new" + # Every path infra-setup.sh grants for this role must already be + # permitted on the host. Adding an asset here without re-running + # infra-setup produces a bare "sudo: a password is required" forty + # lines into the deploy, after some files have already landed. Compare + # up front instead, from infra-setup.sh itself so the two cannot drift. + sed -n "/quantus-miner_gitea_ci.tmp/,/^SUDO$/p" script/infra-setup.sh \ + | grep '^gitea_ci ALL=' | grep -oE '(/etc|/usr|/var)/[^ ]*' | sort -u > expected-paths.txt + ssh $SSHOPTS gitea_ci@${{ matrix.host }} 'sudo -n -l' \ + | grep -oE '(/etc|/usr|/var)/[^ ]*' | sort -u > permitted-paths.txt + comm -23 expected-paths.txt permitted-paths.txt > missing-paths.txt + if [ -s missing-paths.txt ]; then + echo "the miner sudoers on ${{ matrix.host }} is out of date." >&2 + echo "not permitted, but this deploy needs them:" >&2 + sed 's/^/ /' missing-paths.txt >&2 + echo "" >&2 + echo "run: ./script/infra-setup.sh --pubkey ~/.ssh/id_gitea_ci.pub" >&2 + exit 1 + fi + echo "sudoers covers all $(wc -l < expected-paths.txt) paths this deploy needs" - name: deploy miner if: ${{ github.event.inputs.mode != 'validate' }} env: @@ -756,6 +802,29 @@ jobs: ssh -i ~/.ssh/id_gitea_ci -o StrictHostKeyChecking=accept-new \ gitea_ci@${{ env.METRICS_HOST }} hostname -f + - name: preflight — sudoers covers this deploy + run: | + set -euo pipefail + SSHOPTS="-i $HOME/.ssh/id_gitea_ci -o StrictHostKeyChecking=accept-new" + # Every path infra-setup.sh grants for this role must already be + # permitted on the host. Adding an asset here without re-running + # infra-setup produces a bare "sudo: a password is required" forty + # lines into the deploy, after some files have already landed. Compare + # up front instead, from infra-setup.sh itself so the two cannot drift. + sed -n "/quantus-metrics_gitea_ci.tmp/,/^SUDO$/p" script/infra-setup.sh \ + | grep '^gitea_ci ALL=' | grep -oE '(/etc|/usr|/var)/[^ ]*' | sort -u > expected-paths.txt + ssh $SSHOPTS gitea_ci@${{ env.METRICS_HOST }} 'sudo -n -l' \ + | grep -oE '(/etc|/usr|/var)/[^ ]*' | sort -u > permitted-paths.txt + comm -23 expected-paths.txt permitted-paths.txt > missing-paths.txt + if [ -s missing-paths.txt ]; then + echo "the metrics sudoers on ${{ env.METRICS_HOST }} is out of date." >&2 + echo "not permitted, but this deploy needs them:" >&2 + sed 's/^/ /' missing-paths.txt >&2 + echo "" >&2 + echo "run: ./script/infra-setup.sh --pubkey ~/.ssh/id_gitea_ci.pub" >&2 + exit 1 + fi + echo "sudoers covers all $(wc -l < expected-paths.txt) paths this deploy needs" - name: deploy scrape config and dashboard if: ${{ github.event.inputs.mode != 'validate' }} env: diff --git a/CLAUDE.md b/CLAUDE.md index c86f009..b978b82 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -61,6 +61,20 @@ pre-existing `gitea_ci` on the fleet has bash — `infra-setup.sh` repairs one t does not, because a host provisioned with nologin can never be deployed to and the failure looks like an auth problem rather than a shell one. +## Adding an asset means re-running infra-setup + +Any new file the deploy rsyncs needs a matching line in the role's sudoers block +in `script/infra-setup.sh`, and that script must then be re-run against the +hosts. Without it the deploy fails partway through with a bare + + sudo: a password is required + rsync error: error in rsync protocol data stream (code 12) + +after some files have already landed. Each deploy job now preflights this: +it extracts the granted paths from `infra-setup.sh` itself and compares them to +`sudo -n -l` on the target, so the two cannot drift and the error names the +missing paths instead of making you read an rsync exit code. + ## Exposing the JSON-RPC `--rpc-methods safe` is mandatory whenever `--rpc-external` is set. Do not rely diff --git a/readme.md b/readme.md index 02d7665..afd46fd 100644 --- a/readme.md +++ b/readme.md @@ -248,6 +248,10 @@ One-time, from a workstation with sudo ssh to the targets: ./script/infra-setup.sh --pubkey ~/.ssh/id_gitea_ci.pub ``` +Re-run it whenever the deploy gains a new file to ship — each job preflights the +target's sudoers against the grants in `infra-setup.sh` and fails up front, +naming the missing paths, rather than dying partway through an rsync. + Then set each node's `inner_hash` in the `deploy-node` matrix. Derive one per host, offline, from a **dedicated mining wallet** — see `doc/wormhole-rewards.md` §6 for why that matters more than being careful.