mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-06 10:59:59 +00:00
Resolve every 3+-file same-prefix group flagged by the new prefix lint
by moving the files into a subfolder named after the shared prefix and
dropping the prefix from the file names, updating all references:
- utils/env/handlers/infinito_*.py -> infinito/ (dir/, package_cache/
nested a second level); registry imports and the four handler-dir
globs switched to iter_project_files
- utils/install/lint/ansible_*.py -> ansible/ (aliased imports)
- roles/sys-svc-compose/files/swarm_*.{py,sh} -> files/swarm/
- web-app-erpnext/web-app-zammad files/scripts/apply_*.{py,rb} -> apply/
- web-app-odoo files/sql/{select,update}-* and sql/oidc/{grant,insert,
select,update}-* -> matching subfolders
- web-app-keycloak tasks/update/05_ldap*.yml -> 05_ldap/ (internal
includes made role_path-absolute)
- plugins/filter/get_*.py -> plugins/filter/get/ (filter names are the
filters() dict keys, so Jinja usage is unaffected; ansible discovers
the one-level-deep subdir)
Ansible lookup dirs, addon dirs and .github/workflows keep their flat
layout (the filename is the public id / GitHub only discovers flat).
Unit tests mirror the new source layout.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
54 lines
1.8 KiB
Python
54 lines
1.8 KiB
Python
"""Inventory resolution: one helper-script call yields INFINITO_INVENTORY_DIR,
|
|
INFINITO_INVENTORY_FILE and INFINITO_INVENTORY_HOST_VARS_FILE. Kept
|
|
together because the latter two are derived path-joins on the first."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
from typing import TYPE_CHECKING
|
|
|
|
from utils.env.runtime import run_helper
|
|
|
|
if TYPE_CHECKING:
|
|
from utils.env.builder import BuildContext, EnvBuilder
|
|
|
|
INVENTORY_DIR_KEY = "INFINITO_INVENTORY_DIR"
|
|
INVENTORY_FILE_KEY = "INFINITO_INVENTORY_FILE"
|
|
HOST_VARS_FILE_KEY = "INFINITO_INVENTORY_HOST_VARS_FILE"
|
|
|
|
INVENTORY_DIR_COMMENT = (
|
|
"Inventory root resolved by scripts/inventory/resolve.sh based on "
|
|
"RUNNING_ON_* flags."
|
|
)
|
|
INVENTORY_FILE_COMMENT = "Generated devices file inside INFINITO_INVENTORY_DIR."
|
|
HOST_VARS_FILE_COMMENT = (
|
|
"Generated host_vars/localhost.yml inside INFINITO_INVENTORY_DIR."
|
|
)
|
|
|
|
|
|
def apply(eb: EnvBuilder, ctx: BuildContext) -> None:
|
|
inventory_dir = os.environ.get(
|
|
"INFINITO_INVENTORY_DIR", ""
|
|
).strip() # nocheck: handler-bootstrap-read
|
|
if not inventory_dir:
|
|
inventory_dir = run_helper(
|
|
["bash", "scripts/inventory/resolve.sh"],
|
|
cwd=ctx.repo_root,
|
|
extra_env={
|
|
"INFINITO_RUNNING_ON_ACT": eb.get("INFINITO_RUNNING_ON_ACT"),
|
|
"INFINITO_RUNNING_ON_GITHUB": eb.get("INFINITO_RUNNING_ON_GITHUB"),
|
|
},
|
|
)
|
|
if inventory_dir:
|
|
eb.set(INVENTORY_DIR_KEY, inventory_dir, comment=INVENTORY_DIR_COMMENT)
|
|
eb.set(
|
|
INVENTORY_FILE_KEY,
|
|
f"{inventory_dir}/devices.yml",
|
|
comment=INVENTORY_FILE_COMMENT,
|
|
)
|
|
eb.set(
|
|
HOST_VARS_FILE_KEY,
|
|
f"{inventory_dir}/host_vars/localhost.yml",
|
|
comment=HOST_VARS_FILE_COMMENT,
|
|
)
|