fix(ansible): auto-detect WSL2 and set correct ai_stack_host per deployment (#3503)#3516
fix(ansible): auto-detect WSL2 and set correct ai_stack_host per deployment (#3503)#3516mrveiss merged 2 commits intoDev_new_guifrom
Conversation
…3503) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…#3503) Detect WSL2 at deploy time by reading /proc/version on each target host. When the host is WSL2 and backend_ai_stack_host has not been overridden from the default 127.0.0.1, set it to 10.255.255.254 (the WSL2 mirrored networking loopback IP). This ensures every re-provisioning produces a correct AUTOBOT_AI_STACK_HOST in the env file without any manual override. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
✅ SSOT Configuration Compliance: Passing🎉 No hardcoded values detected that have SSOT config equivalents! |
mrveiss
left a comment
There was a problem hiding this comment.
Code review complete. No issues found in the PR changes.
Review findings
Variables and defaults: backend_ai_stack_host and backend_ai_stack_port are both defined in roles/backend/defaults/main.yml (the same bug caught in PR #3513 — missing defaults — does not apply here). The template uses them without | default() guards, which is consistent with every other role-variable usage in backend.env.j2 and safe given the defaults.
WSL2 detection logic: The /proc/version slurp + b64decode | lower | search('microsoft') chain is correct and idiomatic Ansible. failed_when: false ensures graceful degradation on non-Linux hosts. The backend_ai_stack_host == '127.0.0.1' guard correctly preserves any explicit operator override.
Task ordering: The WSL2 detection tasks (lines 35–50 of tasks/main.yml) execute before the env template deployment task (line 64), so the overridden value is in scope when backend.env.j2 is rendered.
CI failure: The code-quality check fails on 20 Python files that this PR did not touch (analytics_code_generation_test.py, hooks.py, standardized_agent.py, etc.). This is pre-existing Black formatting drift on the base branch, not introduced by this PR. The PR changes only Ansible YAML files.
Conclusion: Fix is complete and correct. Merging.
Summary
backendAnsible role by reading/proc/versionon each target host at deploy timemicrosoft) andbackend_ai_stack_hostis still the default127.0.0.1, overrides it to10.255.255.254(WSL2 mirrored networking loopback IP)when: backend_ai_stack_host == '127.0.0.1'guard preserves any explicit operator override (e.g. pointing at a remote AI stack VM)AUTOBOT_AI_STACK_HOSTin the env file without any manual interventionCloses #3503
Test plan
AUTOBOT_AI_STACK_HOST=10.255.255.254in/etc/autobot/autobot-backend.envAUTOBOT_AI_STACK_HOST=127.0.0.1(unchanged)backend_ai_stack_hostexplicitly set in inventory — verify override is not clobbered🤖 Generated with Claude Code