feat: preflight the sudoers before deploying
Run 11 failed with sudo: a password is required rsync error: error in rsync protocol data stream (code 12) because quantus-node-rpc.xml was added to the deploy and to infra-setup.sh's grants, but infra-setup had not been re-run against the host. The failure landed forty lines into deploy-node, after several files had already been written, and said nothing about the actual cause. Each deploy job now compares the paths infra-setup.sh grants for its role against sudo -n -l on the target, before touching anything. The two cannot drift because the expected list is extracted from infra-setup.sh itself rather than duplicated, so an asset added in future is covered automatically. Verified against the live host: it correctly reported /etc/firewalld/services/quantus-node-rpc.xml as missing before infra-setup was re-run, and reports all 26 paths permitted after.
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user