mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-08 19:56:53 +00:00
An inventory group web-app-cst-<name> with applications.<id>.custom: true and
a pinned source {url, version, path} is pulled into roles/ before the play,
read raw (Jinja, Ansible tags and credential URLs refused), placed through a
staging directory under an exclusive lock, and owned by a marker that names
its own directory, so a pull or roles-clean never replaces or removes a
directory it did not place and a failed pull leaves roles/ as it was.
Directory inventories, host lists and non-UTF-8 files behave as Ansible
reads them; generated test deploys pass --skip-pull. make roles-pull,
roles-clean and roles list, INFINITO_EXTRA_MOUNTS for local sources, the
web-app-cst category, the reserved prefix lint and a central
repository_files() that also yields the gitignored custom roles let every
lint scan them like in-tree roles. Supersedes the uncommitted 045 External
Roles draft and reuses its fetch, sync and mount design.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
48 lines
1.5 KiB
Python
48 lines
1.5 KiB
Python
"""Mount extra host directories read-only into the infinito container."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
from utils.cache.yaml import dump_yaml
|
|
|
|
OVERRIDE = "build/compose/extra-mounts.override.yml"
|
|
|
|
|
|
def parse_mounts(raw: str) -> list[Path]:
|
|
"""Return the directories of a comma-separated ``INFINITO_EXTRA_MOUNTS`` value.
|
|
|
|
Args:
|
|
raw: comma-separated absolute host directories.
|
|
|
|
Raises:
|
|
SystemExit: an entry is not an existing absolute directory.
|
|
"""
|
|
directories: list[Path] = []
|
|
for item in filter(None, (part.strip() for part in raw.split(","))):
|
|
directory = Path(item)
|
|
if not directory.is_absolute() or not directory.is_dir():
|
|
raise SystemExit(
|
|
f"INFINITO_EXTRA_MOUNTS: {item} is not an existing absolute directory"
|
|
)
|
|
directories.append(directory)
|
|
return directories
|
|
|
|
|
|
def write_mounts_override(repo_root: Path, directories: list[Path]) -> str:
|
|
"""Write the compose override that mounts ``directories`` into the container.
|
|
|
|
Args:
|
|
repo_root: repository root the compose files are relative to.
|
|
directories: host directories, each mounted read-only at its own path.
|
|
|
|
Returns:
|
|
The override path relative to ``repo_root``.
|
|
"""
|
|
volumes = [
|
|
{"type": "bind", "source": str(path), "target": str(path), "read_only": True}
|
|
for path in directories
|
|
]
|
|
dump_yaml(repo_root / OVERRIDE, {"services": {"infinito": {"volumes": volumes}}})
|
|
return OVERRIDE
|