diff --git a/lib/ansible/modules/monitoring/grafana_dashboard.py b/lib/ansible/modules/monitoring/grafana_dashboard.py index 67f99e8433..262fe22002 100644 --- a/lib/ansible/modules/monitoring/grafana_dashboard.py +++ b/lib/ansible/modules/monitoring/grafana_dashboard.py @@ -141,6 +141,7 @@ import string from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.urls import fetch_url, url_argument_spec from ansible.module_utils._text import to_native +from ansible.module_utils._text import to_text __metaclass__ = type @@ -183,8 +184,10 @@ def get_grafana_version(module, grafana_url, headers): r, info = fetch_url(module, '%s/api/frontend/settings' % grafana_url, headers=headers, method='GET') if info['status'] == 200: try: - settings = json.loads(r.read()) + settings = json.loads(to_text(r.read())) grafana_version = settings['buildInfo']['version'].split('.')[0] + except UnicodeError as e: + raise GrafanaAPIException('Unable to decode version string to Unicode') except Exception as e: raise GrafanaAPIException(e) else: