When apt errors, include it's exit code
We invoke /usr/bin/apt inside of the ansible module. When that command exits, it doesn't always include a helpful error message. Include the exit code so that user's have all the information we can gice them as to why apt failed. Addresses #19128
This commit is contained in:
parent
9d41aefd71
commit
b4f976e9b9
1 changed files with 4 additions and 4 deletions
|
@ -526,7 +526,7 @@ def install(m, pkgspec, cache, upgrade=False, default_release=None,
|
||||||
else:
|
else:
|
||||||
diff = {}
|
diff = {}
|
||||||
if rc:
|
if rc:
|
||||||
return (False, dict(msg="'%s' failed: %s" % (cmd, err), stdout=out, stderr=err))
|
return (False, dict(msg="'%s' failed: %s" % (cmd, err), stdout=out, stderr=err, rc=rc))
|
||||||
else:
|
else:
|
||||||
return (True, dict(changed=True, stdout=out, stderr=err, diff=diff))
|
return (True, dict(changed=True, stdout=out, stderr=err, diff=diff))
|
||||||
else:
|
else:
|
||||||
|
@ -659,7 +659,7 @@ def remove(m, pkgspec, cache, purge=False, force=False,
|
||||||
else:
|
else:
|
||||||
diff = {}
|
diff = {}
|
||||||
if rc:
|
if rc:
|
||||||
m.fail_json(msg="'apt-get remove %s' failed: %s" % (packages, err), stdout=out, stderr=err)
|
m.fail_json(msg="'apt-get remove %s' failed: %s" % (packages, err), stdout=out, stderr=err, rc=rc)
|
||||||
m.exit_json(changed=True, stdout=out, stderr=err, diff=diff)
|
m.exit_json(changed=True, stdout=out, stderr=err, diff=diff)
|
||||||
|
|
||||||
|
|
||||||
|
@ -708,7 +708,7 @@ def upgrade(m, mode="yes", force=False, default_release=None,
|
||||||
else:
|
else:
|
||||||
diff = {}
|
diff = {}
|
||||||
if rc:
|
if rc:
|
||||||
m.fail_json(msg="'%s %s' failed: %s" % (apt_cmd, upgrade_command, err), stdout=out)
|
m.fail_json(msg="'%s %s' failed: %s" % (apt_cmd, upgrade_command, err), stdout=out, rc=rc)
|
||||||
if (apt_cmd == APT_GET_CMD and APT_GET_ZERO in out) or (apt_cmd == APTITUDE_CMD and APTITUDE_ZERO in out):
|
if (apt_cmd == APT_GET_CMD and APT_GET_ZERO in out) or (apt_cmd == APTITUDE_CMD and APTITUDE_ZERO in out):
|
||||||
m.exit_json(changed=False, msg=out, stdout=out, stderr=err)
|
m.exit_json(changed=False, msg=out, stdout=out, stderr=err)
|
||||||
m.exit_json(changed=True, msg=out, stdout=out, stderr=err, diff=diff)
|
m.exit_json(changed=True, msg=out, stdout=out, stderr=err, diff=diff)
|
||||||
|
@ -785,7 +785,7 @@ def get_cache(module):
|
||||||
if rc == 0:
|
if rc == 0:
|
||||||
break
|
break
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
module.fail_json(msg='Updating the cache to correct corrupt package lists failed:\n%s\n%s' % (str(e), str(so) + str(se)))
|
module.fail_json(msg='Updating the cache to correct corrupt package lists failed:\n%s\n%s' % (str(e), str(so) + str(se)), rc=rc)
|
||||||
# try again
|
# try again
|
||||||
cache = apt.Cache()
|
cache = apt.Cache()
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue