fix(awooop): resolve ansible runtime path in container
This commit is contained in:
@@ -707,13 +707,17 @@ def _execution_backend_summary(records: list[dict[str, Any]]) -> dict[str, Any]:
|
||||
return summary
|
||||
|
||||
|
||||
def _ansible_runtime_readiness() -> dict[str, Any]:
|
||||
repo_root = Path(__file__).resolve().parents[4]
|
||||
playbook_roots = [
|
||||
def _ansible_playbook_roots(module_path: Path | None = None) -> list[Path]:
|
||||
resolved_module_path = (module_path or Path(__file__)).resolve()
|
||||
return [
|
||||
Path("/app/infra/ansible"),
|
||||
Path.cwd() / "infra" / "ansible",
|
||||
repo_root / "infra" / "ansible",
|
||||
*(parent / "infra" / "ansible" for parent in resolved_module_path.parents),
|
||||
]
|
||||
|
||||
|
||||
def _ansible_runtime_readiness() -> dict[str, Any]:
|
||||
playbook_roots = _ansible_playbook_roots()
|
||||
playbook_root = next((path for path in playbook_roots if path.exists()), None)
|
||||
playbook_paths = (
|
||||
sorted((playbook_root / "playbooks").glob("*.yml"))
|
||||
|
||||
@@ -2,6 +2,7 @@ from __future__ import annotations
|
||||
|
||||
import inspect
|
||||
from datetime import UTC, datetime, timedelta
|
||||
from pathlib import Path
|
||||
from types import SimpleNamespace
|
||||
|
||||
from src.services.awooop_ansible_audit_service import (
|
||||
@@ -9,6 +10,7 @@ from src.services.awooop_ansible_audit_service import (
|
||||
build_ansible_truth,
|
||||
)
|
||||
from src.services.awooop_truth_chain_service import (
|
||||
_ansible_playbook_roots,
|
||||
_ansible_runtime_readiness,
|
||||
_automation_quality_score_bucket,
|
||||
_clean_row,
|
||||
@@ -706,6 +708,13 @@ def test_ansible_runtime_readiness_reports_check_mode_blockers() -> None:
|
||||
assert isinstance(readiness["blockers"], list)
|
||||
|
||||
|
||||
def test_ansible_playbook_roots_supports_flat_container_module_path() -> None:
|
||||
roots = _ansible_playbook_roots(Path("/app/src/services/awooop_truth_chain_service.py"))
|
||||
|
||||
assert Path("/app/infra/ansible") in roots
|
||||
assert Path("/app/src/infra/ansible") in roots
|
||||
|
||||
|
||||
def test_reconciliation_marks_consistent_resolved_execution() -> None:
|
||||
reconciliation = build_incident_reconciliation(
|
||||
incident={"incident_id": "INC-2", "status": "RESOLVED"},
|
||||
|
||||
Reference in New Issue
Block a user