diff --git a/plugins/lookup/addon_env_flags.py b/plugins/lookup/addon_env_flags.py index 99e3fe363e..ba9bb4d05c 100644 --- a/plugins/lookup/addon_env_flags.py +++ b/plugins/lookup/addon_env_flags.py @@ -83,10 +83,12 @@ class LookupModule(LookupBase): addon (sorted by env key, newline-joined), where the env-key derivation matches addon-gating.js exactly. - A flag is ``true`` only when the addon is both ``enabled`` AND - ``required``. Optional addons (``required: false``) are intentionally - skipped by the spec suite — they are a variant axis, not a guaranteed - surface — so their gate flag is ``false`` even when enabled. + A flag is ``true`` when the addon is ``enabled`` and, where it declares + ``bridges``, at least one bridged partner is deployed in this round. + ``required`` does not enter the gate: it says whether a failed install + aborts the play, not whether the addon runs, and ANDing it here made the + spec of every optional addon unreachable in every variant, because no + variant pins ``required`` while variants do pin addon ``enabled``. """ def run(self, terms, variables: dict[str, Any] | None = None, **kwargs): @@ -127,9 +129,7 @@ class LookupModule(LookupBase): spec = ( addons.get(addon_id) if isinstance(addons.get(addon_id), dict) else {} ) - active = _is_enabled(spec.get("enabled", False)) and _is_enabled( - spec.get("required", False) - ) + active = _is_enabled(spec.get("enabled", False)) if active and deployed_roles is not None: bridges = spec.get("bridges") if isinstance(bridges, list) and bridges: diff --git a/tests/lint/ansible/roles/test_addon_bridges_resolve.py b/tests/lint/ansible/roles/test_addon_bridges_resolve.py index c261b0f00b..6e930e570f 100644 --- a/tests/lint/ansible/roles/test_addon_bridges_resolve.py +++ b/tests/lint/ansible/roles/test_addon_bridges_resolve.py @@ -3,7 +3,7 @@ Rationale ========= ``plugins/lookup/addon_env_flags.py`` turns an addon's ``bridges:`` list into -its Playwright gate flag: a required addon is announced as enabled only when a +its Playwright gate flag: an enabled addon is announced only when a bridged partner is part of the run. A bridge therefore names a **service** — ``sso``, ``ldap``, ``coturn``, ``talk`` — and the lookup maps that service to the role carrying it. diff --git a/tests/unit/python/plugins/lookup/test_addon_env_flags.py b/tests/unit/python/plugins/lookup/test_addon_env_flags.py index 4e1ca6b573..273d88ae24 100644 --- a/tests/unit/python/plugins/lookup/test_addon_env_flags.py +++ b/tests/unit/python/plugins/lookup/test_addon_env_flags.py @@ -74,16 +74,16 @@ class TestAddonEnvFlagsLookup(unittest.TestCase): self.assertEqual(f["COLLECTIVES_ADDON_ENABLED"], "true") self.assertEqual(f["CONTACTS_ADDON_ENABLED"], "true") - def test_required_false_skipped_even_if_enabled(self): - self.assertEqual(self._flags()["OPTIONAL_ON_ADDON_ENABLED"], "false") + def test_required_false_still_gates_on_enabled(self): + self.assertEqual(self._flags()["OPTIONAL_ON_ADDON_ENABLED"], "true") def test_disabled_is_false(self): f = self._flags() self.assertEqual(f["REQUIRED_OFF_ADDON_ENABLED"], "false") self.assertEqual(f["OFF_OPTIONAL_ADDON_ENABLED"], "false") - def test_missing_required_defaults_false(self): - self.assertEqual(self._flags()["NO_REQUIRED_ADDON_ENABLED"], "false") + def test_missing_required_does_not_gate(self): + self.assertEqual(self._flags()["NO_REQUIRED_ADDON_ENABLED"], "true") def test_string_flags_coerced(self): self.assertEqual(self._flags()["STR_FLAGS_ADDON_ENABLED"], "true") @@ -124,7 +124,7 @@ class TestNoAddons(unittest.TestCase): class TestBridgeDeploymentGating(unittest.TestCase): """A bridged addon's flag is true only when one of its partner roles is in the round's deployed closure (the inventory groups). When the set cannot be - resolved the gating is skipped (flag falls back to enabled AND required).""" + resolved the gating is skipped (flag falls back to enabled).""" def setUp(self): self.lookup = LookupModule()