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>
pull/66150/head
Sloane Hertel 5 years ago committed by GitHub
parent b06e78c16c
commit 1b3ca349eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- RoleRequirement - include stderr in the error message if a scm command fails (https://github.com/ansible/ansible/issues/41336)

@ -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)

Loading…
Cancel
Save