You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When crafting a URL for Grafana's API, the grafana_datasource module (and maybe others, I didn't check them) appends two strings together, the passed in grafana_url and the appropriate endpoint. This results in a URL like "...com//api/..." Grafana is picky about matching routes, so returns an error page in HTML, not JSON as the module expects. It attempts to parse the page as JSON which results in a JSONDecodeError.
Arch Linux, targeting itself. Everything is installed from the distribution packages.
STEPS TO REPRODUCE
Simply running this playbook should trigger the error:
---
- name: create a datasource in grafana to read metricscommunity.grafana.grafana_datasource:
name: "{{ item }}"grafana_url: "https://grafana.example.com/"# NB: the trailing slashgrafana_api_key: "{{ grafana_admin_api_key }}"org_id: "1"ds_type: "influxdb"ds_url: "http://influx:8086"database: "telegraf"time_interval: ">10s"user: grafanapassword: "{{ influxdb_users_grafana }}"
EXPECTED RESULTS
Not a python exception, but either it gracefully handling it or returning a human friendly error message rather than a screen full of red error text. 😄
ACTUAL RESULTS
"module_stderr": "Traceback (most recent call last):\n File \"/home/user/.ansible/tmp/ansible-tmp-1603857202.7836478-2983891-108174010981857/AnsiballZ_grafana_datasource.py\", line 102, in <module>\n _ansiballz_main()\n File \"/home/user/.ansible/tmp/ansible-tmp-1603857202.7836478-2983891-108174010981857/AnsiballZ_grafana_datasource.py\", line 94, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/home/user/.ansible/tmp/ansible-tmp-1603857202.7836478-2983891-108174010981857/AnsiballZ_grafana_datasource.py\", line 40, in invoke_module\n runpy.run_module(mod_name='ansible_collections.community.grafana.plugins.modules.grafana_datasource', init_globals=None, run_name='__main__', alter_sys=True)\n File \"/usr/lib/python3.8/runpy.py\", line 207, in run_module\n return _run_module_code(code, init_globals, run_name, mod_spec)\n File \"/usr/lib/python3.8/runpy.py\", line 97, in _run_module_code\n _run_code(code, mod_globals, init_globals,\n File \"/usr/lib/python3.8/runpy.py\", line 87, in _run_code\n exec(code, run_globals)\n File \"/tmp/ansible_community.grafana.grafana_datasource_payload_oszg32vj/ansible_community.grafana.grafana_datasource_payload.zip/ansible_collections/community/grafana/plugins/modules/grafana_datasource.py\", line 752, in <module>\n File \"/tmp/ansible_community.grafana.grafana_datasource_payload_oszg32vj/ansible_community.grafana.grafana_datasource_payload.zip/ansible_collections/community/grafana/plugins/modules/grafana_datasource.py\", line 726, in main\n File \"/tmp/ansible_community.grafana.grafana_datasource_payload_oszg32vj/ansible_community.grafana.grafana_datasource_payload.zip/ansible_collections/community/grafana/plugins/modules/grafana_datasource.py\", line 628, in datasource_by_name\n File \"/tmp/ansible_community.grafana.grafana_datasource_payload_oszg32vj/ansible_community.grafana.grafana_datasource_payload.zip/ansible_collections/community/grafana/plugins/modules/grafana_datasource.py\", line 617, in _send_request\n File \"/tmp/ansible_community.grafana.grafana_datasource_payload_oszg32vj/ansible_community.grafana.grafana_datasource_payload.zip/ansible/module_utils/basic.py\", line 2136, in from_json\n File \"/usr/lib/python3.8/json/__init__.py\", line 357, in loads\n return _default_decoder.decode(s)\n File \"/usr/lib/python3.8/json/decoder.py\", line 337, in decode\n obj, end = self.raw_decode(s, idx=_w(s, 0).end())\n File \"/usr/lib/python3.8/json/decoder.py\", line 355, in raw_decode\n raise JSONDecodeError(\"Expecting value\", s, err.value) from None\njson.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)\n
The text was updated successfully, but these errors were encountered:
SUMMARY
When crafting a URL for Grafana's API, the
grafana_datasource
module (and maybe others, I didn't check them) appends two strings together, the passed ingrafana_url
and the appropriate endpoint. This results in a URL like "...com//api/..." Grafana is picky about matching routes, so returns an error page in HTML, not JSON as the module expects. It attempts to parse the page as JSON which results in aJSONDecodeError
.ISSUE TYPE
A bit of both, I think.
COMPONENT NAME
ANSIBLE VERSION
CONFIGURATION
OS / ENVIRONMENT
Arch Linux, targeting itself. Everything is installed from the distribution packages.
STEPS TO REPRODUCE
Simply running this playbook should trigger the error:
EXPECTED RESULTS
Not a python exception, but either it gracefully handling it or returning a human friendly error message rather than a screen full of red error text. 😄
ACTUAL RESULTS
The text was updated successfully, but these errors were encountered: