Skip to content

fix(ansible): write SLM_AUTH_TOKEN to autobot-backend.env — stops WS 403 storm (#7689) - #7707

Merged
mrveiss merged 1 commit into
Dev_new_guifrom
issue-7689
May 15, 2026
Merged

mrveiss merged 1 commit into
Dev_new_guifrom
issue-7689

Conversation

@mrveiss

@mrveiss mrveiss commented May 15, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes the root cause of 4400+ WebSocket 403 errors/day (GH#7689 / MVA-312).

Root cause chain:
SLM_AUTH_TOKEN unset in /etc/autobot/autobot-backend.env → SLMClient(auth_token=None) → no Authorization header on WS connection → SERVICE_AUTH_ENFORCEMENT_MODE=true on SLM → HTTP 403 → 60s reconnect loop → 4400+ 403s/day.

Changes:

  • slm_manager/defaults/main.yml — add slm_auth_token: "" (auto-generated when empty)
  • slm_manager/tasks/main.yml — generate slm_auth_token on fresh installs; idempotent lineinfile to inject SLM_AUTH_TOKEN into existing slm-secrets.env on upgrade (handles already-deployed machines)
  • slm_manager/templates/slm-secrets.env.j2 — persist SLM_AUTH_TOKEN so it survives redeployments
  • backend/tasks/main.yml — shell + set_fact to read the token from /etc/autobot/slm-secrets.env on the target host before the env template renders; fails-safe to empty string if file absent
  • backend/templates/backend.env.j2 — emit SLM_AUTH_TOKEN= line in the SLM connection section
  • backend/defaults/main.yml — document backend_slm_auth_tok default

Test plan

  • Fresh deploy: slm_manager role generates SLM_AUTH_TOKEN and writes to slm-secrets.env; backend role reads it and writes to autobot-backend.env; SLMClient connects with Authorization: Bearer <token>; WS 403 errors stop
  • Upgrade deploy (existing slm-secrets.env): lineinfile idempotently adds SLM_AUTH_TOKEN only when absent; subsequent backend deploy picks it up
  • Re-run deploy: lineinfile skips (token already present); autobot-backend.env unchanged → no spurious restart
  • Confirm WS 403 error rate drops to 0 after next Ansible playbook run + service restart

Closes #7689

🤖 Generated with Claude Code

…ager role (#7689)

Root cause: SLM_AUTH_TOKEN was never written to /etc/autobot/autobot-backend.env,
causing SLMClient to connect with no Authorization header, triggering 4400+
WebSocket 403 errors/day from the 60s reconnect loop.

Changes:
- slm_manager/defaults: add slm_auth_token default (empty = auto-generate)
- slm_manager/tasks: generate slm_auth_token on fresh install; idempotent
  lineinfile to add SLM_AUTH_TOKEN to existing slm-secrets.env on upgrade
- slm_manager/templates/slm-secrets.env.j2: persist SLM_AUTH_TOKEN in the
  secrets file so it survives redeployments unchanged
- backend/tasks: shell + set_fact to read SLM_AUTH_TOKEN from slm-secrets.env
  on the target host before the env template renders (fails-safe to empty string)
- backend/templates/backend.env.j2: emit SLM_AUTH_TOKEN= line in SLM section
- backend/defaults: document backend_slm_auth_tok default

Co-Authored-By: Paperclip <noreply@paperclip.ing>
@github-actions

Copy link
Copy Markdown
Contributor

✅ SSOT Configuration Compliance: Passing

🎉 No hardcoded values detected that have SSOT config equivalents!

@mrveiss
mrveiss merged commit 57e0afc into Dev_new_gui May 15, 2026
5 checks passed
@mrveiss
mrveiss deleted the issue-7689 branch May 15, 2026 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant