From aa8a770ea35fce1918643f1d0d9b05eecbe96b43 Mon Sep 17 00:00:00 2001 From: Nick Vigilante Date: Mon, 23 Nov 2026 18:04:39 -0500 Subject: [PATCH] docs: use provisioner key env var in VM and Docker provisioner examples (#32626) ## Summary The VM and Docker examples on the external provisioners page set `CODER_SESSION_TOKEN`, so a reader who follows the page's recommended scoped-key path and pastes a key from `coder provisioner keys create` gets an auth failure. This switches both examples to `CODER_PROVISIONER_DAEMON_KEY`, which matches the Scoped Key and Helm sections on the same page. Fixes #30066 ## Changes - `docs/install/operate/provisioners/index.md`: the VM and Docker examples now set `CODER_PROVISIONER_DAEMON_KEY=`, with one line explaining where the key comes from and that a user token still works through `CODER_SESSION_TOKEN`. ## Testing - Ran a throwaway CLI test (not committed) against `enterprise/cli` with a real provisioner key: - `CODER_SESSION_TOKEN= coder provisioner start` fails with `must provide a pre-shared key or provisioner key when not authenticated as a user`. - `CODER_PROVISIONER_DAEMON_KEY= coder provisioner start` logs `starting provisioner daemon`. - `markdownlint-cli2`, Vale, `make lint/emdash`, `make lint/docs-html`, and `make lint/docs-manifest` pass.
Investigation notes - Provisioner keys and session tokens travel in different headers: `Coder-Provisioner-Daemon-Key` (`codersdk/client.go`) versus `Coder-Session-Token`. `coder provisioner start` only reads a key from `--key` or `CODER_PROVISIONER_DAEMON_KEY` (`enterprise/cli/provisionerdaemonstart.go`). - Without a key or PSK, the CLI treats the session token as a user API key and selects an organization, which returns 401 for a provisioner key. - The two examples date from March 2023 (#6443), before provisioner keys existed (`--key` landed in #14002, July 2024), so they were written for user tokens. User tokens still work, so the examples were outdated rather than broken, but they contradicted the page's recommended path. - No other page under `docs/` pairs `CODER_SESSION_TOKEN` with `coder provisioner start`. `docs/admin/users/organizations.md` already uses `CODER_PROVISIONER_DAEMON_KEY`.
--- _Generated by Coder Agents on behalf of @nickvigilante._ --- docs/install/operate/provisioners/index.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/install/operate/provisioners/index.md b/docs/install/operate/provisioners/index.md index 192643900ff..3128a89157d 100644 --- a/docs/install/operate/provisioners/index.md +++ b/docs/install/operate/provisioners/index.md @@ -307,19 +307,25 @@ Coder provides a Helm chart for running external provisioner daemons, which you ## Example: Running an external provisioner on a VM +Replace `` with a [scoped key](#scoped-key-recommended) from `coder provisioner keys create`. +To authenticate with a [user token](#user-tokens) instead, set `CODER_SESSION_TOKEN` in place of `CODER_PROVISIONER_DAEMON_KEY`. + ```sh curl -fsSL https://coder.com/install.sh | sh export CODER_URL=https://coder.example.com -export CODER_SESSION_TOKEN=your_token +export CODER_PROVISIONER_DAEMON_KEY= coder provisioner start ``` ## Example: Running an external provisioner via Docker +Replace `` with a [scoped key](#scoped-key-recommended) from `coder provisioner keys create`. +To authenticate with a [user token](#user-tokens) instead, set `CODER_SESSION_TOKEN` in place of `CODER_PROVISIONER_DAEMON_KEY`. + ```sh docker run --rm -it \ -e CODER_URL=https://coder.example.com/ \ - -e CODER_SESSION_TOKEN=your_token \ + -e CODER_PROVISIONER_DAEMON_KEY= \ --entrypoint /opt/coder \ ghcr.io/coder/coder:latest \ provisioner start