feat(colmena): passwordless activation via sudoers rules scoped to colmena's exact commands
Colmena connects with BatchMode=yes and no TTY (src/nix/host/ssh.rs),
so a sudo password prompt can never be answered - non-root deploys
REQUIRE NOPASSWD. New extraServices.colmenaDeploy (enabled on all
five hosts) grants m3tam3re passwordless sudo for exactly the two
invocations colmena performs (verified against colmena 0.5/0.6
profile.rs + host/{ssh,local}.rs, default NixFlags are empty):
- /run/current-system/sw/bin/nix-env --profile /nix/var/nix/profiles/system --set /nix/store/*
(system profile switch, goals switch/boot)
- /nix/store/*/bin/switch-to-configuration <boot|switch|test|dry-activate>
(activation, exact single argument)
Everything else keeps requiring the sudo password; extraRules sort
after the wheel rules, so last-match-wins keeps the exception scoped.
Also enables passwordless 'colmena apply-local' on the desktops, which
uses the same activation path.
Residual risk (documented in the module): anyone holding the deploy
user's SSH key can activate arbitrary store closures - that is the
deploy capability itself, inherent to NixOS remote activation.
One-time bootstrap per server (rules arrive WITH a deploy, and the
first deploy cannot answer a password prompt):
nixos-rebuild switch --flake .#m3-atlas --target-host m3tam3re@m3-atlas --use-remote-sudo
This commit is contained in:
1 parent
db0bfbc707
commit
0576b3c60b
9 files changed
+67
-2
No files matched your search
@@ -304,7 +304,7 @@ This provides the familiar shell/editor/CLI setup but with work git credentials
|
||||
| **Enter dev shell** | `nix develop` | Includes alejandra, nixd, agenix, statix, deadnix |
|
||||
| **Build host** | `sudo nixos-rebuild switch --flake .#m3-ares` | Replace hostname as needed |
|
||||
| **Dry run build** | `sudo nixos-rebuild dry-run --flake .#m3-ares` | Validate without applying |
|
||||
| **Deploy servers** | `nix develop -c colmena apply --on @server` | Colmena: all hosts tagged `server` via SSH |
|
||||
| **Deploy servers** | `nix develop -c colmena apply --on @server` | Colmena: all `server` hosts via SSH; activation is passwordless (scoped sudoers, see extraServices/colmena-deploy.nix) |
|
||||
| **Deploy one host** | `nix develop -c colmena apply --on m3-atlas` | Colmena: single remote host |
|
||||
| **Deploy this host** | `nix develop -c colmena apply-local` | Colmena: local desktop (uses sudo to activate) |
|
||||
| **Preview deploy** | `nix develop -c colmena build --on m3-atlas` | Colmena: build closure without switching |
|
||||
|
||||
Reference in new issue
Block a user