diff --git a/changelogs/fragments/1703-sensu_silence-fix_json_parsing.yml b/changelogs/fragments/1703-sensu_silence-fix_json_parsing.yml new file mode 100644 index 0000000000..18d39b5674 --- /dev/null +++ b/changelogs/fragments/1703-sensu_silence-fix_json_parsing.yml @@ -0,0 +1,2 @@ +bugfixes: + - sensu-silence module - fix json parsing of sensu API responses on Python 3.5 (https://github.com/ansible-collections/community.general/pull/1703). diff --git a/plugins/modules/monitoring/sensu/sensu_silence.py b/plugins/modules/monitoring/sensu/sensu_silence.py index acd64f975c..12dc5d2068 100644 --- a/plugins/modules/monitoring/sensu/sensu_silence.py +++ b/plugins/modules/monitoring/sensu/sensu_silence.py @@ -97,6 +97,7 @@ RETURN = ''' import json +from ansible.module_utils._text import to_native from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.urls import fetch_url @@ -129,7 +130,7 @@ def query(module, url, check, subscription): ) try: - json_out = json.loads(response.read()) + json_out = json.loads(to_native(response.read())) except Exception: json_out = "" @@ -181,7 +182,7 @@ def clear(module, url, check, subscription): ) try: - json_out = json.loads(response.read()) + json_out = json.loads(to_native(response.read())) except Exception: json_out = "" @@ -246,7 +247,7 @@ def create( ) try: - json_out = json.loads(response.read()) + json_out = json.loads(to_native(response.read())) except Exception: json_out = ""