From dca9d618f055d3f84758e51d5ac3052ab9e9c673 Mon Sep 17 00:00:00 2001 From: Alexander Winkler Date: Tue, 29 Dec 2015 08:02:13 +0100 Subject: [PATCH] fixed inline for more compatibility --- .../modules/extras/packaging/os/pkgutil.py | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/lib/ansible/modules/extras/packaging/os/pkgutil.py b/lib/ansible/modules/extras/packaging/os/pkgutil.py index 899a7dce47..72d2bf6428 100644 --- a/lib/ansible/modules/extras/packaging/os/pkgutil.py +++ b/lib/ansible/modules/extras/packaging/os/pkgutil.py @@ -154,7 +154,11 @@ def main(): if len(out) > 75: out = out[:75] + '...' if rc != 0: - module.fail_json(msg=err if err else out) + if err: + msg = err + else: + msg = out + module.fail_json(msg=msg) elif state == 'latest': if not package_installed(module, name): @@ -164,7 +168,12 @@ def main(): if len(out) > 75: out = out[:75] + '...' if rc != 0: - module.fail_json(msg=err if err else out) + if err: + msg = err + else: + msg = out + module.fail_json(msg=msg) + else: if not package_latest(module, name, site): if module.check_mode: @@ -173,7 +182,11 @@ def main(): if len(out) > 75: out = out[:75] + '...' if rc != 0: - module.fail_json(msg=err if err else out) + if err: + msg = err + else: + msg = out + module.fail_json(msg=msg) elif state == 'absent': if package_installed(module, name): @@ -183,7 +196,11 @@ def main(): if len(out) > 75: out = out[:75] + '...' if rc != 0: - module.fail_json(msg=err if err else out) + if err: + msg = err + else: + msg = out + module.fail_json(msg=msg) if rc is None: # pkgutil was not executed because the package was already present/absent