From 1b3ca349eb1e10859139f70380f438d6a60893f2 Mon Sep 17 00:00:00 2001 From: Sloane Hertel <shertel@redhat.com> Date: Tue, 14 Jan 2020 09:46:23 -0500 Subject: [PATCH] RoleRequirement - Include stderr in the error message (#66006) * RoleRequirement - Include stderr in the error message if there's a non-0 return code * Don't try to concatenate str and bytes Co-Authored-By: Sam Doran <sdoran@redhat.com> --- .../66006-RoleRequirement-include-stderr-error-msg.yaml | 2 ++ lib/ansible/playbook/role/requirement.py | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/66006-RoleRequirement-include-stderr-error-msg.yaml diff --git a/changelogs/fragments/66006-RoleRequirement-include-stderr-error-msg.yaml b/changelogs/fragments/66006-RoleRequirement-include-stderr-error-msg.yaml new file mode 100644 index 00000000000..10464cd95c7 --- /dev/null +++ b/changelogs/fragments/66006-RoleRequirement-include-stderr-error-msg.yaml @@ -0,0 +1,2 @@ +bugfixes: + - RoleRequirement - include stderr in the error message if a scm command fails (https://github.com/ansible/ansible/issues/41336) diff --git a/lib/ansible/playbook/role/requirement.py b/lib/ansible/playbook/role/requirement.py index 8e974f16848..084f4beedca 100644 --- a/lib/ansible/playbook/role/requirement.py +++ b/lib/ansible/playbook/role/requirement.py @@ -145,11 +145,11 @@ class RoleRequirement(RoleDefinition): except Exception as e: ran = " ".join(cmd) display.debug("ran %s:" % ran) - display.debug("\tstdout: " + stdout) - display.debug("\tstderr: " + stderr) + display.debug("\tstdout: " + to_text(stdout)) + display.debug("\tstderr: " + to_text(stderr)) raise AnsibleError("when executing %s: %s" % (ran, to_native(e))) if popen.returncode != 0: - raise AnsibleError("- command %s failed in directory %s (rc=%s)" % (' '.join(cmd), tempdir, popen.returncode)) + raise AnsibleError("- command %s failed in directory %s (rc=%s) - %s" % (' '.join(cmd), tempdir, popen.returncode, to_native(stderr))) if scm not in ['hg', 'git']: raise AnsibleError("- scm %s is not currently supported" % scm)