Skip to content

deploy: state the backend port once and derive every other statement from it #21400

Open
1 of 6 issues completed

Description

@mrveiss

Found while fixing #21343. The backend's listen port (the same literal) is stated independently in several places in the deploy tree, none deriving from another:

  • inventory/group_vars/infrastructure.yml infrastructure.ports.backend
  • playbooks/vars/backend-env.yml backend_port (what the backend unit and env are rendered from; the updater now reads this)
  • inventory/production.yml backend_port
  • the dynamic inventory script's AUTOBOT_BACKEND_PORT default
  • roles/backend/defaults/main.yml, roles/monitoring/defaults/main.yml

The updater's generated inventory defines none of them, so a task that reads backend_port before vars/backend-env.yml is loaded fails on templating.

Acceptance criteria

  • One declaration of the port, sourced from the SSOT config; every other statement derives from it
  • The generated inventory's global vars carry it, so no play depends on include order
  • A repo test fails if a second literal is added

Parent: #21343

Activity

  1. mrveiss commented on Nov 12, 2026

    @mrveiss
    OwnerAuthor

    Open decision (from #21435): where static inventories take the backend ports from.

    inventory.yml, inventory/hosts.yml, hosts-router.yml and slm-nodes.yml define neither backend_port nor backend_nginx_port. The registry inventory, the dynamic generator, production.yml and — with #21435 — SLM-driven one-host deploys carry both from the single config source.

    Two sites render a plain-http proxy upstream that falls back to 8443, the TLS port, when backend_port is undefined: roles/frontend/templates/nginx-frontend.conf.j2 (the upstream) and roles/frontend/tasks/main.yml (its display line). That is the behaviour on main and is kept so those inventories do not abort: wrong, but working. The three TLS probes (key rotation, enforcement toggle, remote backend deploy) and the health-check probes fall back to 8443 as on main, which is correct for a TLS URL.

    Decision needed: should the static inventories declare the ports (and where, without adding a second literal), derive them from the single config source at load, or be retired — and once that is settled, should the frontend upstream use the plain-port variable with no fallback? Until decided, all fallbacks stay as on main and a test pins them.

    #21435 does not close this issue: the criteria on a single declaration and on a test that fails on a second literal remain open.

  2. added
    needs-decisionBlocked on an owner decision; options and a recommendation are on the issue
    on Nov 12, 2026
  3. 10 remaining items

  4. mrveiss commented on Nov 13, 2026

    @mrveiss
    OwnerAuthor

    Finding from review of the updater batch (#21435): the static production inventory is inconsistent for frontend hosts, and it is unchanged by that PR.

    What the inventory says: all.vars sets backend_port: 8001 and backend_protocol: "https" and defines no backend_nginx_port. Only the backend host's own group sets backend_port: 8001, backend_nginx_port: 8443 (commented "nginx external TLS port") and backend_protocol: "http" (commented "uvicorn binds plain HTTP on localhost").

    Render for a frontend host (nginx upstream port and proxy scheme), plain jinja2 over the two expressions:

    main branch (scheme-matched port)
    frontend host 8001 over https 8001 over https
    backend host 8001 over http 8001 over http

    So the frontend upstream sends TLS to the plain listener on the static inventory both before and after the batch; the registry and bare-host paths now render the TLS port. Fixing it means either adding backend_nginx_port to all.vars (value 8443, which changes the rendered port from 8001 to 8443) or changing backend_protocol/backend_port there. Which is right depends on whether the TLS listener is reachable from frontend hosts, which the inventory comments assert but nothing in the repository proves. This is the open question on where static inventories take their ports from; leaving it for that decision.

  5. github-actions commented on Nov 14, 2026

    @github-actions
    Contributor

    Landed in #21435, merge 5b3508e8db

  6. mrveiss commented on Nov 14, 2026

    @mrveiss
    OwnerAuthor

    Closure pass against origin/main at 5b3508e8db (#21435). Nothing ticked: #21435 delivered the scheme-matched port and SSOT ports for generated and bare-host inventories, and says it does not close this issue.

    Criterion Verdict Evidence
    One declaration of the port, sourced from the SSOT config; every other statement derives from it unchecked git grep -nE "backend_port:\s*[0-9]+" origin/main -- autobot-slm-backend/ansible still returns literals in inventory/production.yml:39,109, playbooks/vars/backend-env.yml:23, roles/backend/defaults/main.yml:32, roles/monitoring/defaults/main.yml:131, roles/backend_services/tasks/main.yml:156, and 8443 in three playbooks; inventory/dynamic/generate_inventory.py:50 has its own default.
    The generated inventory's global vars carry it, so no play depends on include order unchecked tests/test_bare_inventory_carries_ssot_ports_21400.py covers bare single-host commands; the updater's generated inventory in services/inventory_builder.py has no backend_port reference.
    A repo test fails if a second literal is added unchecked No such test found; tests/test_port_fallbacks_kept_as_on_main_21400.py pins the existing fallbacks instead.

    The open decision on static inventories (comments above) is still pending.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: deploy-lifecycleWave 1 · cluster O — Deploy, provision & lifecycledeploymentinfrastructureneeds-decisionBlocked on an owner decision; options and a recommendation are on the issuephase:M1.4Wizard and SLM: choose a mode, apply it, default models work

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions