mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-13 14:16:46 +00:00
- add cli.meta.applications.resolution.combined to resolve run_after + app-only dependencies - add optional --tree output for combined resolution - add cli.meta.applications.resolution.dependencies (app-only) resolver - move run_after resolver to cli.meta.applications.resolution.run_after - update test deploy dependency resolver to use combined module - add unit tests for combined/dependencies/run_after resolvers - minor cleanup: remove stray header comment, fix newline in vars, tidy YAML formatting https://chatgpt.com/share/696ca531-9644-800f-98c0-bae58c0aff41
39 lines
1.2 KiB
Python
39 lines
1.2 KiB
Python
from __future__ import annotations
|
|
|
|
from .compose import Compose
|
|
|
|
|
|
def resolve_run_after(compose: Compose, role_name: str) -> list[str]:
|
|
"""
|
|
Calls resolver inside the infinito container:
|
|
python -m cli.meta.applications.resolution.combined <role_name>
|
|
"""
|
|
cmd = ["python3", "-m", "cli.meta.applications.resolution.combined", role_name]
|
|
r = compose.exec(cmd, check=False, workdir="/opt/src/infinito", capture=True)
|
|
|
|
if r.returncode != 0:
|
|
raise RuntimeError(
|
|
f"resolution.combined failed for {role_name} (rc={r.returncode})\n"
|
|
f"STDOUT:\n{r.stdout}\nSTDERR:\n{r.stderr}"
|
|
)
|
|
|
|
txt = (r.stdout or "").strip()
|
|
if not txt:
|
|
return []
|
|
return [t for t in txt.split() if t.strip()]
|
|
|
|
|
|
def apps_with_deps(app_id: str, deps_role_names: list[str]) -> list[str]:
|
|
"""
|
|
The resolver returns role folder names. In your current inventory groups,
|
|
group names == application_ids (folder names). So we can include them directly.
|
|
"""
|
|
# ensure prerequisites first + app_id last
|
|
out: list[str] = []
|
|
for d in deps_role_names:
|
|
if d != app_id and d not in out:
|
|
out.append(d)
|
|
if app_id not in out:
|
|
out.append(app_id)
|
|
return out
|