Files
computer-playbook/plugins/lookup/compose_volumes.py
T
kevinveenbirkenbachandClaude Fable 5 aedb26eacc fix(bigbluebutton): pull prebuilt images and align with house patterns
The freeswitch build fetched libopusenc from launchpad.net, whose
librarian backend rate-limits CI (429s across 11 attempts); three more
build-time fetches carried the same risk. The maintainer publishes an
alangecker/* image for every buildable service, so compose_mods drops
build: wherever the service carries an image and compose pulls instead;
a guard task fails loudly if a future upstream service still builds.

Pin ref to the v3.0.23 release branch (the packaging repo has no tags)
and clone it without submodules via the new compose_repository_recursive
toggle: submodules only feed build contexts and DEV_MODE mounts, and
generate-compose falls back to the committed repos/tags file.

Declare the pulled images in meta/services.yml (updater-managed SPOT,
mirror pre-pull) and the named data volumes in meta/volumes.yml; the
override renders both through the standard container_image /
container_volumes / compose_volumes lookups with the service_name
pattern. Compose merges volumes by target, so the override's named
volumes verifiably replace the clone-local bind mounts (docker compose
config proven). This also heals a split-brain mount: apps-akka,
periodic and prometheus-exporter previously kept bind mounts while
their peers used the named volumes.

Teach container_image and compose_volumes to honour compose_mode_force
(the SPOT the other mode-aware lookups already read): bbb deploys as a
node-local compose stack in swarm, so it must get hub image refs and
plain local volumes there, not registry-prefixed refs and NFS
driver_opts. The unpinned-engine-volume lint learns the same two safe
conditions. Read the embedded Collabora port from web-svc-collabora's
services SPOT instead of hardcoding 9980.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-08 02:37:27 +02:00

90 lines
3.2 KiB
Python

"""Lookup `compose_volumes`: render the top-level `volumes:` block for
a given application_id. Auto-wires the `applications` registry,
DEPLOYMENT_MODE, and `storage` mapping from the templating context.
"""
from __future__ import annotations
import contextlib
from typing import Any
from ansible.errors import AnsibleError
from ansible.plugins.loader import lookup_loader
from ansible.plugins.lookup import LookupBase
from plugins.filter.compose_volumes import compose_volumes as _render_compose_volumes
from utils.templating.ansible import _trust_as_template
class LookupModule(LookupBase):
def run(
self,
terms: list[Any] | None,
variables: dict[str, Any] | None = None,
**kwargs: Any,
) -> list[str]:
if not terms or len(terms) != 1:
raise AnsibleError(
"compose_volumes lookup requires exactly one term: the application_id"
)
application_id = str(terms[0]).strip()
if not application_id:
raise AnsibleError(
"compose_volumes lookup: application_id must be non-empty"
)
vars_ = variables or getattr(self._templar, "available_variables", {}) or {}
templar = getattr(self, "_templar", None)
applications = lookup_loader.get(
"applications", loader=self._loader, templar=getattr(self, "_templar", None)
).run([], variables=vars_)[0]
deployment_mode = kwargs.get("deployment_mode")
if deployment_mode is None:
mode_force = vars_.get("compose_mode_force", "")
if templar is not None:
with contextlib.suppress(Exception):
mode_force = templar.template(mode_force)
deployment_mode = mode_force or vars_.get("DEPLOYMENT_MODE", "compose")
storage = kwargs.get("storage")
if storage is None:
storage = vars_.get("storage")
dir_var_lib = kwargs.get("dir_var_lib")
if dir_var_lib is None:
dir_var_lib = vars_["DIR_VAR_LIB"]
if templar is not None:
with contextlib.suppress(Exception):
deployment_mode = templar.template(deployment_mode)
with contextlib.suppress(Exception):
storage = templar.template(storage)
with contextlib.suppress(Exception):
dir_var_lib = templar.template(dir_var_lib)
render_jinja = None
if templar is not None:
def render_jinja(expr: str) -> Any:
if not isinstance(expr, str):
return expr
return templar.template(
_trust_as_template(expr),
fail_on_undefined=False,
)
rendered = _render_compose_volumes(
applications,
application_id,
extra_volumes=kwargs.get("extra_volumes"),
extra_configs=kwargs.get("extra_configs"),
extra_secrets=kwargs.get("extra_secrets"),
deployment_mode=str(deployment_mode).strip(),
storage=storage,
dir_var_lib=str(dir_var_lib).strip(),
render_jinja=render_jinja,
)
return [rendered]