Skip to content

Commit

Permalink
Disable Ansible debug mode for sub-commands (#284)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea committed May 25, 2023
1 parent afd22be commit c6aa776
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/ansible_compat/runtime.py
Expand Up @@ -327,6 +327,10 @@ def run( # ruff: disable=PLR0913
run_func: Callable[..., CompletedProcess] = subprocess_tee.run
else:
run_func = subprocess.run
env = self.environ if env is None else env.copy()
# Presence of ansible debug variable or config option will prevent us
# from parsing its JSON output due to extra debug messages on stdout.
env["ANSIBLE_DEBUG"] = "0"

for _ in range(self.max_retries + 1 if retry else 1):
result = run_func(
Expand All @@ -335,12 +339,12 @@ def run( # ruff: disable=PLR0913
check=False,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
env=env or self.environ,
env=env,
cwd=str(cwd) if cwd else None,
)
if result.returncode == 0:
break
_logger.debug("Environment: %s", env or self.environ)
_logger.debug("Environment: %s", env)
if retry:
_logger.warning(
"Retrying execution failure %s of: %s",
Expand Down

0 comments on commit c6aa776

Please sign in to comment.