From 8ce4720f44b2320ea27fdb66e5fdac7dc607e4b3 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Tue, 11 Dec 2018 09:38:06 -0500 Subject: [PATCH] pear: More info if failure occurs (#49735) * added cli errors to error msg for pear --- changelogs/fragments/pear_better_error.yml | 2 ++ lib/ansible/modules/packaging/language/pear.py | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/pear_better_error.yml diff --git a/changelogs/fragments/pear_better_error.yml b/changelogs/fragments/pear_better_error.yml new file mode 100644 index 00000000000..15bb9390853 --- /dev/null +++ b/changelogs/fragments/pear_better_error.yml @@ -0,0 +1,2 @@ +minor_changes: + - more complete information when pear module has an error message diff --git a/lib/ansible/modules/packaging/language/pear.py b/lib/ansible/modules/packaging/language/pear.py index 7333ee2c954..95538af6eb9 100644 --- a/lib/ansible/modules/packaging/language/pear.py +++ b/lib/ansible/modules/packaging/language/pear.py @@ -66,6 +66,7 @@ EXAMPLES = ''' import os +from ansible.module_utils._text import to_text from ansible.module_utils.basic import AnsibleModule @@ -140,7 +141,7 @@ def remove_packages(module, packages): rc, stdout, stderr = module.run_command(cmd, check_rc=False) if rc != 0: - module.fail_json(msg="failed to remove %s" % (package)) + module.fail_json(msg="failed to remove %s: %s" % (package, to_text(stdout + stderr))) remove_c += 1 @@ -171,7 +172,7 @@ def install_packages(module, state, packages): rc, stdout, stderr = module.run_command(cmd, check_rc=False) if rc != 0: - module.fail_json(msg="failed to install %s" % (package)) + module.fail_json(msg="failed to install %s: %s" % (package, to_text(stdout + stderr))) install_c += 1