feat: add the cli_proxy_api role #56

Closed
aleksei wants to merge 2 commits from feat/cli-proxy-api into main
Owner

Runs CLIProxyAPI as a Compose stack under /opt/cli_proxy_api, replacing the a2 role from the closed #55: that service is gone from ai.lan (stack stopped, /opt/a2 removed).

  • image pinned to eceasy/cli-proxy-api:v8.1.8;
  • the API port (8317) and the OAuth callback listeners (Antigravity 8085, Codex 1455, Grok Build 54545, Claude 51121, 11451) are published, because the callbacks are opened by the browser or CLI that runs the authorisation flow; the API port is one variable used both as the container port in the config and as the host port in the compose file;
  • auths (OAuth credentials), logs and plugins are created up front and mounted, so they survive a container recreation;
  • the config is seeded, not rendered on every run. The service rewrites config.yaml once it starts — it bcrypt-hashes the management key, saves the generated server-id and keeps the panel's edits — so a template task would rotate the salt and the identity on every converge and revert the panel. The role writes the file only when it is absent;
  • the bootstrap reports changed only when Compose creates, recreates or starts a container, so a second run is idempotent;
  • the host passes the client key and the management key through the vault and adds the config, the credentials and the plugins to its restic set, as state.md asks for a role's state.

Deployed with ansible-playbook playbooks/ai.yaml on ai.lan: the container is up on v8.1.8, /v1/models answers 401 without a key and 200 with the client key, the panel answers 200 on /management.html, and /v8/management/config answers 200 with the management key. A second run reports changed=0, and a restic backup now snapshots /opt/cli_proxy_api/config.yaml, auths and plugins next to /opt/bifrost/data.

Runs [CLIProxyAPI](https://github.com/router-for-me/CLIProxyAPI) as a Compose stack under `/opt/cli_proxy_api`, replacing the a2 role from the closed #55: that service is gone from ai.lan (stack stopped, `/opt/a2` removed). - image pinned to `eceasy/cli-proxy-api:v8.1.8`; - the API port (8317) and the OAuth callback listeners (Antigravity 8085, Codex 1455, Grok Build 54545, Claude 51121, 11451) are published, because the callbacks are opened by the browser or CLI that runs the authorisation flow; the API port is one variable used both as the container port in the config and as the host port in the compose file; - `auths` (OAuth credentials), `logs` and `plugins` are created up front and mounted, so they survive a container recreation; - **the config is seeded, not rendered on every run.** The service rewrites `config.yaml` once it starts — it bcrypt-hashes the management key, saves the generated `server-id` and keeps the panel's edits — so a template task would rotate the salt and the identity on every converge and revert the panel. The role writes the file only when it is absent; - the bootstrap reports `changed` only when Compose creates, recreates or starts a container, so a second run is idempotent; - the host passes the client key and the management key through the vault and adds the config, the credentials and the plugins to its restic set, as `state.md` asks for a role's state. Deployed with `ansible-playbook playbooks/ai.yaml` on ai.lan: the container is up on `v8.1.8`, `/v1/models` answers `401` without a key and `200` with the client key, the panel answers `200` on `/management.html`, and `/v8/management/config` answers `200` with the management key. A second run reports `changed=0`, and a restic backup now snapshots `/opt/cli_proxy_api/config.yaml`, `auths` and `plugins` next to `/opt/bifrost/data`.
The role runs CLIProxyAPI as a Compose stack under /opt/cli_proxy_api with a pinned image, a rendered compose file and the API port plus the OAuth callback listeners published, since those callbacks are opened by the browser or CLI that runs the authorisation flow.

The service rewrites its config once it starts: it hashes the management key, saves the generated server identity and keeps the panel's edits. The role therefore seeds config.yaml instead of rendering it on every run, which would rotate the bcrypt salt and the identity and revert the panel.
The host hands the role its client key and management key through the vault and backs the configuration, the OAuth credentials and the plugins up with restic, the way state.md asks for a role's state.
aleksei closed this pull request 2026-11-29 09:15:42 +00:00

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
zoo/infra!56
No description provided.