fix(api): include repo ansible roles path
This commit is contained in:
@@ -256,6 +256,19 @@ def _resolve_playbook_path(playbook_root: Path, playbook_path: str) -> Path:
|
||||
return resolved
|
||||
|
||||
|
||||
def _ansible_command_env(playbook_root: Path) -> dict[str, str]:
|
||||
roles_path = str((playbook_root / "roles").resolve())
|
||||
existing_roles_path = os.environ.get("ANSIBLE_ROLES_PATH")
|
||||
if existing_roles_path:
|
||||
roles_path = os.pathsep.join([roles_path, existing_roles_path])
|
||||
return {
|
||||
**os.environ,
|
||||
"ANSIBLE_HOST_KEY_CHECKING": "true",
|
||||
"ANSIBLE_RETRY_FILES_ENABLED": "false",
|
||||
"ANSIBLE_ROLES_PATH": roles_path,
|
||||
}
|
||||
|
||||
|
||||
def build_ansible_check_mode_command(
|
||||
*,
|
||||
playbook_path: str,
|
||||
@@ -296,11 +309,7 @@ def build_ansible_check_mode_command(
|
||||
"--extra-vars",
|
||||
json.dumps(extra_vars, ensure_ascii=False, separators=(",", ":")),
|
||||
]
|
||||
env = {
|
||||
**os.environ,
|
||||
"ANSIBLE_HOST_KEY_CHECKING": "true",
|
||||
"ANSIBLE_RETRY_FILES_ENABLED": "false",
|
||||
}
|
||||
env = _ansible_command_env(root)
|
||||
return AnsibleCommandSpec(
|
||||
command=command,
|
||||
cwd=root,
|
||||
@@ -351,11 +360,7 @@ def build_ansible_apply_command(
|
||||
"--extra-vars",
|
||||
json.dumps(extra_vars, ensure_ascii=False, separators=(",", ":")),
|
||||
]
|
||||
env = {
|
||||
**os.environ,
|
||||
"ANSIBLE_HOST_KEY_CHECKING": "true",
|
||||
"ANSIBLE_RETRY_FILES_ENABLED": "false",
|
||||
}
|
||||
env = _ansible_command_env(root)
|
||||
return AnsibleCommandSpec(
|
||||
command=command,
|
||||
cwd=root,
|
||||
|
||||
Reference in New Issue
Block a user