Skip to content

Commit 2cd7e39

Browse files
authored
Allow the caller to set the ANSIBLE_COLLECTIONS_PATH (#388)
* Allow the caller to set the ANSIBLE_COLLECTIONS_PATH * Remove comment
1 parent 119b302 commit 2cd7e39

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/ansible_compat/runtime.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,11 +374,13 @@ def run( # ruff: disable=PLR0913
374374
tee: bool = False,
375375
env: dict[str, str] | None = None,
376376
cwd: Path | None = None,
377+
set_acp: bool = True,
377378
) -> CompletedProcess:
378379
"""Execute a command inside an Ansible environment.
379380
380381
:param retry: Retry network operations on failures.
381382
:param tee: Also pass captured stdout/stderr to system while running.
383+
:param set_acp: Set the ANSIBLE_COLLECTIONS_PATH
382384
"""
383385
if tee:
384386
run_func: Callable[..., CompletedProcess] = subprocess_tee.run
@@ -392,8 +394,7 @@ def run( # ruff: disable=PLR0913
392394
# https://github.com/ansible/ansible-lint/issues/3522
393395
env["ANSIBLE_VERBOSE_TO_STDERR"] = "True"
394396

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

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

0 commit comments

Comments
 (0)