From 960dfa862b9119a84d8eedf6f68a736228849268 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Mon, 8 Oct 2018 13:23:53 +0200 Subject: [PATCH] influxdb_retention_policy: don't fail with empty error message (#28792) On connection errors the influxdb python module raises an exception with an empty message leading to a fail_json with an empty error message: https://github.com/influxdata/influxdb-python/blob/265d14736bb739aed0f357d8da248d51f549244b/influxdb/influxdb08/client.py#L252 Fail with a more descriptive error in this case. --- .../modules/database/influxdb/influxdb_retention_policy.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/database/influxdb/influxdb_retention_policy.py b/lib/ansible/modules/database/influxdb/influxdb_retention_policy.py index 0ea45273ee..dba3e28a81 100644 --- a/lib/ansible/modules/database/influxdb/influxdb_retention_policy.py +++ b/lib/ansible/modules/database/influxdb/influxdb_retention_policy.py @@ -6,7 +6,6 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type - ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'} @@ -101,11 +100,13 @@ except ImportError: from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.influxdb import InfluxDb +from ansible.module_utils._text import to_native def find_retention_policy(module, client): database_name = module.params['database_name'] policy_name = module.params['policy_name'] + hostname = module.params['hostname'] retention_policy = None try: @@ -115,7 +116,7 @@ def find_retention_policy(module, client): retention_policy = policy break except requests.exceptions.ConnectionError as e: - module.fail_json(msg=str(e)) + module.fail_json(msg="Cannot connect to database %s on %s : %s" % (database_name, hostname, to_native(e))) return retention_policy