mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-11 13:17:07 +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>
41 lines
1.2 KiB
Python
41 lines
1.2 KiB
Python
"""Custom-role naming SPOT.
|
|
|
|
A custom role is the inventory group ``web-app-cst-<name>``. Its
|
|
``applications.<group>`` block marks it with ``custom: true`` and names
|
|
the repository it comes from under ``source``. The pull places it as
|
|
``roles/<group>``, which ``.gitignore`` keeps out of every core commit.
|
|
|
|
Keep this module free of imports beyond the standard library: the
|
|
project-tree scan helpers in :mod:`utils.cache` read it.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
PREFIX: str = "web-app-cst-"
|
|
ROLES_GLOB: str = f"roles/{PREFIX}*"
|
|
CUSTOM_KEY: str = "custom"
|
|
SOURCE_KEY: str = "source"
|
|
|
|
|
|
class CustomRoleError(Exception):
|
|
"""A custom-role declaration, fetch or placement that stops the run."""
|
|
|
|
|
|
def is_custom(name: str) -> bool:
|
|
"""Whether *name* carries the reserved custom-role prefix.
|
|
|
|
Args:
|
|
name: a role directory, inventory group or application_id.
|
|
"""
|
|
return name.startswith(PREFIX)
|
|
|
|
|
|
def is_custom_path(rel_path: str) -> bool:
|
|
"""Whether a repository-relative POSIX path lies in a placed custom role.
|
|
|
|
Args:
|
|
rel_path: path relative to the repository root, ``/``-separated.
|
|
"""
|
|
parts = rel_path.split("/")
|
|
return len(parts) > 1 and parts[0] == "roles" and is_custom(parts[1])
|