cli: Add check=True to catch Ansible failures

From [1]:
If check is true, and the process exits with a non-zero
exit code, a CalledProcessError exception will be raised.
Attributes of that exception hold the arguments, the exit
code, and stdout and stderr if they were captured.

[1]: https://docs.python.org/3/library/subprocess.html

Closes-Bug: #2089173

Change-Id: I8cf38c2f7db1493e7303e94c212251fbeafaced3
This commit is contained in:
Michal Nasiadka 2024-11-20 16:48:04 +01:00
parent 5a9e268453
commit 4f62dd4661

View File

@ -173,6 +173,6 @@ def run_command(executable: str,
if quiet: if quiet:
kwargs["stdout"] = subprocess.DEVNULL kwargs["stdout"] = subprocess.DEVNULL
kwargs["stderr"] = subprocess.DEVNULL kwargs["stderr"] = subprocess.DEVNULL
subprocess.run(full_cmd, shell=False, **kwargs) # nosec subprocess.run(full_cmd, check=True, shell=False, **kwargs) # nosec
else: else:
subprocess.run(full_cmd, shell=False, **kwargs) # nosec subprocess.run(full_cmd, check=True, shell=False, **kwargs) # nosec