Files
computer-playbook/roles/svc-db-openldap/templates/test.env.j2
kevinveenbirkenbachandClaude Opus 5 2ba3a14b98 refactor(svc-db): gate the Tor credential tests on one shared lookup
The three svc-db-* credential tests each hand-rolled the same transport
gate in their test.env.j2:

    (lookup('config', application_id, 'services.tor.enabled') | bool
     and lookup('config', application_id, 'services.<entity>.exposed') | bool)

Three copies of one predicate, each naming its own entity key, and each
free to drift from the onion mapping that actually decides reachability.

Extract it into plugins/lookup/tor_reachable.py, split the same way as
its sibling tor_ports.py: a plain is_reachable() for callers holding the
merged applications view, plus a thin LookupModule resolving it through
lookup('applications'). Because collect_exposed_ports() scans
services.values(), the entity name disappears from the templates
entirely -- they collapse to

    TOR_ENABLED={{ lookup('tor_reachable', application_id) | lower }}

Rework the integration guard accordingly: it now asserts that every
svc-db-* template delegates to the shared lookup, and drives its
base/variant agreement table through the real is_reachable() instead of
re-implementing the predicate. Add unit coverage for the new lookup.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-10 00:50:47 +02:00

8 lines
344 B
Bash

BIND_DN_B64={{ OPENLDAP_BIND_DN | b64encode }}
DB_CONTAINER={{ OPENLDAP_CONTAINER_ADDRESS }}
DB_PASSWORD_B64={{ OPENLDAP_BIND_PW | b64encode }}
DB_PORT={{ OPENLDAP_PORT }}
ONION_HOST={{ lookup('config', 'svc-net-tor', 'services.tor.node') }}
TOR_ENABLED={{ lookup('tor_reachable', application_id) | lower }}
TOR_SOCKS={{ lookup('tor_socks') }}