1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

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:

    265d14736b/influxdb/influxdb08/client.py (L252)

Fail with a more descriptive error in this case.
This commit is contained in:
Guido Günther 2018-10-08 13:23:53 +02:00 committed by ansibot
parent ffcebd317b
commit 960dfa862b

View file

@ -6,7 +6,6 @@
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.1', ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'], 'status': ['preview'],
'supported_by': 'community'} 'supported_by': 'community'}
@ -101,11 +100,13 @@ except ImportError:
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.influxdb import InfluxDb from ansible.module_utils.influxdb import InfluxDb
from ansible.module_utils._text import to_native
def find_retention_policy(module, client): def find_retention_policy(module, client):
database_name = module.params['database_name'] database_name = module.params['database_name']
policy_name = module.params['policy_name'] policy_name = module.params['policy_name']
hostname = module.params['hostname']
retention_policy = None retention_policy = None
try: try:
@ -115,7 +116,7 @@ def find_retention_policy(module, client):
retention_policy = policy retention_policy = policy
break break
except requests.exceptions.ConnectionError as e: 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 return retention_policy