Skip to content

Commit

Permalink
Allow the caller to set the ANSIBLE_COLLECTIONS_PATH (#388)
Browse files Browse the repository at this point in the history
* Allow the caller to set the ANSIBLE_COLLECTIONS_PATH

* Remove comment
  • Loading branch information
cidrblock authored Jun 5, 2024
1 parent 119b302 commit 2cd7e39
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/ansible_compat/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,11 +374,13 @@ def run( # ruff: disable=PLR0913
tee: bool = False,
env: dict[str, str] | None = None,
cwd: Path | None = None,
set_acp: bool = True,
) -> CompletedProcess:
"""Execute a command inside an Ansible environment.
:param retry: Retry network operations on failures.
:param tee: Also pass captured stdout/stderr to system while running.
:param set_acp: Set the ANSIBLE_COLLECTIONS_PATH
"""
if tee:
run_func: Callable[..., CompletedProcess] = subprocess_tee.run
Expand All @@ -392,8 +394,7 @@ def run( # ruff: disable=PLR0913
# https://github.com/ansible/ansible-lint/issues/3522
env["ANSIBLE_VERBOSE_TO_STDERR"] = "True"

# Assume the caller has a proper env, if not use a sane default
if "ANSIBLE_COLLECTIONS_PATH" not in env:
if set_acp:
env["ANSIBLE_COLLECTIONS_PATH"] = ":".join(self.config.collections_paths)

for _ in range(self.max_retries + 1 if retry else 1):
Expand Down

0 comments on commit 2cd7e39

Please sign in to comment.