cli.build.graph package¶
Module contents¶
Compatibility wrapper.
- This package was migrated from a flat module (graph.py) to a package layout:
graph/__main__.py contains the original implementation.
We re-export the public API so existing imports keep working.
- class cli.build.graph.Any(*args, **kwargs)¶
Bases:
objectSpecial type indicating an unconstrained type.
Any is assignable to every type.
Any assumed to have all methods and attributes.
All values are assignable to Any.
Note that all the above statements are true from the point of view of static type checkers. At runtime, Any cannot be used with instance checks.
- class cli.build.graph.RoleDependencyResolver(roles_dir: str)¶
Bases:
object- get_role_dependencies(role_name: str, *, resolve_include_role: bool = True, resolve_import_role: bool = True, resolve_dependencies: bool = True, resolve_run_after: bool = False) set[str]¶
- resolve_transitively(start_roles: Iterable[str], *, resolve_include_role: bool = True, resolve_import_role: bool = True, resolve_dependencies: bool = True, resolve_run_after: bool = False, max_depth: int | None = None) set[str]¶
- cli.build.graph.build_mappings(start_role: str, roles_dir: str, max_depth: int) Dict[str, Any]¶
Build all 12 graph variants (6 dep types × 2 directions). Accelerated version:
One-time scan of all metadata
One-time scan of all include_role/import_role
One-time scan of include_tasks/import_tasks
Build reverse-index tables
Then generate all graphs purely from memory
- cli.build.graph.build_single_graph(start_role: str, dep_type: str, direction: str, roles_dir: str, max_depth: int, caches: Dict[str, Any]) Dict[str, Any]¶
Build a graph (nodes + links) for one role, one dep_type, one direction. Uses only precomputed in-memory caches, no filesystem access.
- caches structure:
caches[“meta”][role] -> meta information caches[“deps”][dep_type][role] -> outgoing targets caches[“rev”][dep_type][target] -> set of source roles
- cli.build.graph.find_role_meta(roles_dir: str, role: str) str¶
Return path to meta/main.yml of a role or raise FileNotFoundError.
- cli.build.graph.find_role_tasks(roles_dir: str, role: str) str¶
Return path to tasks/main.yml of a role or raise FileNotFoundError.
- cli.build.graph.load_meta(path: str) Dict[str, Any]¶
Load metadata from meta/main.yml. Returns a dict with:
galaxy_info
run_after
dependencies
- cli.build.graph.load_tasks(path: str, dep_type: str) List[str]¶
Parse include_tasks/import_tasks from tasks/main.yml. Only accepts simple, non-Jinja names.
- cli.build.graph.load_yaml(path, *, default_if_missing: Any = <object object>) dict[str, Any]¶
Load a YAML file as a dict, memoised by absolute path.
default_if_missing controls the missing-file behaviour: - Default (_MISSING): raise FileNotFoundError for callers that
want to fail loud (resolution code).
Pass a value (typically {}): return that value when the file does not exist, matching the behaviour expected by cli.administration.inventory.provision.yaml_io.load_yaml.
Raises TypeError when the YAML root is not a mapping; use load_yaml_any for files whose root is a list or scalar.
- cli.build.graph.load_yaml_any(path, *, default_if_missing: Any = <object object>) Any¶
Memoised YAML load that accepts any root shape (dict, list, scalar). Use this for files where the root is not a mapping (e.g. Ansible task lists, the root list in meta/variants.yml).
Empty files surface as {} (matching yaml.safe_load(…) or {} semantics that most call sites already rely on).
- cli.build.graph.main()¶