default the host's swarmctl to the gateway; login takes a callback port
This commit is contained in:
parent
ef817ed5a0
commit
58236e1b7f
1 changed files with 183 additions and 67 deletions
|
|
@ -2,8 +2,9 @@
|
|||
|
||||
Swarm-level operator CLI. Runs as **root on the host running
|
||||
`swarm-controller`**, and acts on that host directly; or, for the verbs
|
||||
that talk to the controller, from anywhere as your own SSO account (see
|
||||
[Remote use](#remote-use-swarmctl-login)).
|
||||
that talk to the controller, through the gateway as your own SSO account, on the
|
||||
host or anywhere else (see
|
||||
[Reaching the controller](#reaching-the-controller-swarmctl-login)).
|
||||
|
||||
Distinct from `hivectl`, which drives one hive's `hive-c0re` over its
|
||||
admin socket. This crate doesn't link `swarm-controller`, for the same
|
||||
|
|
@ -52,18 +53,18 @@ rather than defaulted — a default would be an address we _hope_ points at
|
|||
something, and one that resolves cleanly to the wrong place is worse than
|
||||
an error.
|
||||
|
||||
| variable | what |
|
||||
| ----------------------------------- | -------------------------------------------------------------------- |
|
||||
| `SWARMCTL_AUTHELIA_BIN` | the **configured** authelia; argon2 params must match the verifier's |
|
||||
| `SWARMCTL_AUTHELIA_USERS_FILE` | host-side path of the users database |
|
||||
| `SWARMCTL_AUTHELIA_MACHINE` | container name, for `systemctl -M` |
|
||||
| `SWARMCTL_AUTHELIA_UNIT` | authelia's unit inside that container |
|
||||
| `SWARMCTL_BAO_BOOTSTRAP_TOKEN_FILE` | where `bao grant-bootstrap` places the 24h grant token |
|
||||
| `SWARMCTL_BAO_BOOTSTRAP_POLICY` | the `bao-bootstrap` policy file `bao grant-bootstrap` writes |
|
||||
| `SWARM_CONTROLLER_SOCKET` | the controller's unix socket, for `agent` and `forge` verbs |
|
||||
| `SWARMCTL_LOGIN_DEFAULT_SWARM` | `https://<swarm domain>` of this host's swarm, for `login` only |
|
||||
| `SWARMCTL_SWARM` | the swarm's domain, bare or `https://`: reach the controller there |
|
||||
| `SWARMCTL_CA_FILE` | a PEM CA to trust beside the system roots, for `SWARMCTL_SWARM` |
|
||||
| variable | what |
|
||||
| ----------------------------------- | --------------------------------------------------------------------------------------------------------------- |
|
||||
| `SWARMCTL_AUTHELIA_BIN` | the **configured** authelia; argon2 params must match the verifier's |
|
||||
| `SWARMCTL_AUTHELIA_USERS_FILE` | host-side path of the users database |
|
||||
| `SWARMCTL_AUTHELIA_MACHINE` | container name, for `systemctl -M` |
|
||||
| `SWARMCTL_AUTHELIA_UNIT` | authelia's unit inside that container |
|
||||
| `SWARMCTL_BAO_BOOTSTRAP_TOKEN_FILE` | where `bao grant-bootstrap` places the 24h grant token |
|
||||
| `SWARMCTL_BAO_BOOTSTRAP_POLICY` | the `bao-bootstrap` policy file `bao grant-bootstrap` writes |
|
||||
| `SWARM_CONTROLLER_SOCKET` | the controller's unix socket, used when no swarm is named |
|
||||
| `SWARMCTL_LOGIN_DEFAULT_SWARM` | `https://<swarm domain>` of this host's swarm, for `login` |
|
||||
| `SWARMCTL_SWARM` | the swarm's domain, bare or `https://`: reach the controller there; the module defaults it to this host's swarm |
|
||||
| `SWARMCTL_CA_FILE` | a PEM CA to trust beside the system roots, for `SWARMCTL_SWARM` |
|
||||
|
||||
Every verb and flag: [`docs/2-handbook/swarm/swarmctl-cli.md`](../docs/2-handbook/swarm/swarmctl-cli.md).
|
||||
The sections below cover why each verb behaves as it does.
|
||||
|
|
@ -270,15 +271,15 @@ Read-only, and it needs no token. Where each step is read from:
|
|||
|
||||
A check that cannot run gives `unknown` with the reason and the rest still
|
||||
print: `bao` is only on `PATH` on the host running swarm-bao, the users file is
|
||||
only on the authelia host, and the controller socket only on its host (or
|
||||
`--swarm`). The exit code is 0 when every step it can see has finished and 1
|
||||
only on the authelia host, and the controller socket only on its host (or `--swarm`; on a controller host the
|
||||
default swarm needs `swarmctl login` first). The exit code is 0 when every step it can see has finished and 1
|
||||
otherwise, counting an `unknown` from a failed check; step 10, another agent,
|
||||
is optional and does not count.
|
||||
|
||||
## Remote use: `swarmctl login`
|
||||
## Reaching the controller: `swarmctl login`
|
||||
|
||||
The `agent`, `schedule` and `forge` verbs, and the agent checks and steps of `setup`, also work from any machine, as
|
||||
your own SSO account, through the swarm domain's gateway:
|
||||
The `agent`, `schedule` and `forge` verbs, and the agent checks and steps of `setup`, go
|
||||
through the swarm domain's gateway as your own SSO account, from any machine:
|
||||
|
||||
```console
|
||||
$ export SWARMCTL_SWARM=https://swarm.example.com
|
||||
|
|
@ -289,17 +290,28 @@ logged in to https://swarm.example.com/; login kept in ~/.local/state/swarmctl/s
|
|||
$ swarmctl schedule list
|
||||
```
|
||||
|
||||
`--swarm` (before or after the verb) names the swarm, else `SWARMCTL_SWARM`;
|
||||
either takes the bare domain too. With neither, `login` alone falls back to
|
||||
`SWARMCTL_LOGIN_DEFAULT_SWARM`, which the swarm-controller module sets to its
|
||||
host's own swarm. It's not `SWARMCTL_SWARM` there because that would send
|
||||
the host's other verbs through the gateway instead of the socket.
|
||||
`--swarm` (before or after the verb) names the swarm, else `SWARMCTL_SWARM`; either takes the
|
||||
bare domain too. On a swarm-controller host the module's wrapper sets `SWARMCTL_SWARM` and
|
||||
`SWARMCTL_LOGIN_DEFAULT_SWARM` to the host's own swarm, so the host's `swarmctl` uses the gateway
|
||||
too and needs one `swarmctl login`. The gateway names the sender from the SSO session, and the
|
||||
controller's socket serves nginx alone. Both are defaults, so a value you set wins. An empty
|
||||
`SWARMCTL_SWARM` (or `--swarm ""`) puts the verbs back on `SWARM_CONTROLLER_SOCKET` as root. That
|
||||
route sends no `Remote-User`, so the routes that name the sender answer 401. Nothing in setup needs it:
|
||||
`swarmctl login` needs only authelia and your SSO account, both there by step 2.
|
||||
|
||||
`login` opens the swarm's SSO login in a browser and receives the result on
|
||||
a loopback port, so run it on the machine whose browser you use. swarmctl
|
||||
keeps the login, mode 0600, under `$XDG_STATE_HOME/swarmctl/` (default
|
||||
`~/.local/state`) and refreshes it as it's used, and once more if the gateway
|
||||
refuses it. When it can't be refreshed, any verb says to run `swarmctl login`
|
||||
`login` opens the swarm's SSO login in a browser and receives the result on a loopback port, so
|
||||
run it on the machine whose browser you use. It prints the port. On a host with no browser, forward
|
||||
a port from the machine that has one, then give the login that port:
|
||||
|
||||
```console
|
||||
workstation$ ssh -L 8765:127.0.0.1:8765 swarm-host
|
||||
swarm-host$ swarmctl login --callback-port 8765
|
||||
```
|
||||
|
||||
Open the printed URL in the workstation's browser. The registered redirect matches a loopback
|
||||
address on any port, so any free port works. swarmctl keeps the login, mode 0600, under
|
||||
`$XDG_STATE_HOME/swarmctl/` (default `~/.local/state`) and refreshes it as it's used, and once
|
||||
more if the gateway refuses it. When it can't be refreshed, any verb says to run `swarmctl login`
|
||||
again. To log out, delete the file.
|
||||
|
||||
A swarm whose gateway serves a certificate from the swarm's own CA needs
|
||||
|
|
|
|||
Loading…
Reference in a new issue