From 8eacbd0381adb83999431364c2ddc681ac26b976 Mon Sep 17 00:00:00 2001 From: Olli-Antti Kivilahti Date: Sat, 30 Jun 2018 00:28:17 +0300 Subject: [PATCH] elasticsearch_plugin - Show STDERR on module failures. (#41954) * elasticsearch_plugin - Show STDERR on module failures. I tried to install a ES plugin without become: yes and found after debugging the module that the module failed ude to permission issues. The only error message I got was Is analysis-icu a valid plugin name? That was strange considering I followed the example documentation by the letter. I found out that when this module fails, it hides the real reason for failure. This patch replaces the generic error with more meaningful diagnostics. * elasticsearch_plugin - Show STDERR on module failures. Changelog fragment samdoran commented 2 days ago This looks good. Please create a changelog fragment to go along with this change. See fragments for examples. --- .../fragments/elasticsearch_plugin-showSTDERRonFailure.yaml | 3 +++ lib/ansible/modules/database/misc/elasticsearch_plugin.py | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/elasticsearch_plugin-showSTDERRonFailure.yaml diff --git a/changelogs/fragments/elasticsearch_plugin-showSTDERRonFailure.yaml b/changelogs/fragments/elasticsearch_plugin-showSTDERRonFailure.yaml new file mode 100644 index 0000000000..9d6696ca79 --- /dev/null +++ b/changelogs/fragments/elasticsearch_plugin-showSTDERRonFailure.yaml @@ -0,0 +1,3 @@ +--- +bugfixes: +- elasticsearch_plugin - Improve error messages and show stderr of elasticsearch commands diff --git a/lib/ansible/modules/database/misc/elasticsearch_plugin.py b/lib/ansible/modules/database/misc/elasticsearch_plugin.py index 614caa7fca..8652c1a00e 100644 --- a/lib/ansible/modules/database/misc/elasticsearch_plugin.py +++ b/lib/ansible/modules/database/misc/elasticsearch_plugin.py @@ -175,7 +175,7 @@ def install_plugin(module, plugin_bin, plugin_name, version, url, proxy_host, pr if rc != 0: reason = parse_error(out) - module.fail_json(msg='Is %s a valid plugin name?' % plugin_name, err=reason) + module.fail_json(msg="Installing plugin '%s' failed: %s" % (plugin_name, reason), err=err) return True, cmd, out, err @@ -192,7 +192,7 @@ def remove_plugin(module, plugin_bin, plugin_name): if rc != 0: reason = parse_error(out) - module.fail_json(msg=reason) + module.fail_json(msg="Removing plugin '%s' failed: %s" % (plugin_name, reason), err=err) return True, cmd, out, err