Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error on grafana 9.0 #248

Closed
miettal opened this issue Jun 16, 2022 · 2 comments · Fixed by #249
Closed

error on grafana 9.0 #248

miettal opened this issue Jun 16, 2022 · 2 comments · Fixed by #249

Comments

@miettal
Copy link
Contributor

miettal commented Jun 16, 2022

SUMMARY

Datasource module cause error of "KeyError: 'password'".

It seems grafana droped password and basicAuthPassword attributes of datasource object from 9.0.0.

Removes support for storing/using datasource password and basicAuthPassword unencrypted which was deprecated in Grafana v8.1.0.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

datasource module

ANSIBLE VERSION

2.12.5

COLLECTION VERSION

1.4

CONFIGURATION

OS / ENVIRONMENT
STEPS TO REPRODUCE
      - name: xxx
        grafana_datasource:
          name: "xxx"
          grafana_url: "http://localhost:3000"
          grafana_user: "xxx"
          grafana_password: "xxx"
          org_id: "1"
          ds_type: "influxdb"
          ds_url: "http://localhost:8086"
          database: "xxx"
          user: 'xxx'
          password: 'xxx'
EXPECTED RESULTS

success

ACTUAL RESULTS
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: KeyError: 'password'
fatal: [xxx]: FAILED! => {"changed": false, "module_stderr": "", "module_stdout": "Traceback (most recent call last):\r\n  File \"/home/ubuntu/.ansible/tmp/ansible-tmp-1655391494.499609-53346-58637564971731/AnsiballZ_grafana_datasource.py\", line 107,
in <module>\r\n    _ansiballz_main()\r\n  File \"/home/ubuntu/.ansible/tmp/ansible-tmp-1655391494.499609-53346-58637564971731/AnsiballZ_grafana_datasource.py\", line 99, in _ansiballz_main\r\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n  File \"/home/u
buntu/.ansible/tmp/ansible-tmp-1655391494.499609-53346-58637564971731/AnsiballZ_grafana_datasource.py\", line 47, in invoke_module\r\n    runpy.run_module(mod_name='ansible_collections.community.grafana.plugins.modules.grafana_datasource', init_globals=dict(_module_fqn=
'ansible_collections.community.grafana.plugins.modules.grafana_datasource', _modlib_path=modlib_path),\r\n  File \"/usr/lib/python3.8/runpy.py\", line 207, in run_module\r\n    return _run_module_code(code, init_globals, run_name, mod_spec)\r\n  File \"/usr/lib/python3.
8/runpy.py\", line 97, in _run_module_code\r\n    _run_code(code, mod_globals, init_globals,\r\n  File \"/usr/lib/python3.8/runpy.py\", line 87, in _run_code\r\n    exec(code, run_globals)\r\n  File \"/tmp/ansible_grafana_datasource_payload_7uu8wyxo/ansible_grafana_data
source_payload.zip/ansible_collections/community/grafana/plugins/modules/grafana_datasource.py\", line 769, in <module>\r\n  File \"/tmp/ansible_grafana_datasource_payload_7uu8wyxo/ansible_grafana_datasource_payload.zip/ansible_collections/community/grafana/plugins/modu
les/grafana_datasource.py\", line 752, in main\r\n  File \"/tmp/ansible_grafana_datasource_payload_7uu8wyxo/ansible_grafana_datasource_payload.zip/ansible_collections/community/grafana/plugins/modules/grafana_datasource.py\", line 477, in compare_datasources\r\nKeyError
: 'password'\r\n", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

https://github.com/ansible-collections/community.grafana/blob/main/plugins/modules/grafana_datasource.py#L504

@kongslund
Copy link
Contributor

I noticed the same issue with Grafana 9.0.0 and a Prometheus data source.

@LiMuBei
Copy link
Contributor

LiMuBei commented Oct 8, 2023

For me this is not solved. I have data sources that have never been configured with basic auth, yet the function comparing the current data source and the new one expects there to be something related to basic auth (either user or password, depending on the module version). See

del current['basicAuthUser']

If basicAuth is false, because nothing is configured this will always fail. Now the fun part is, that if you configure basicAuth in the UI with some foobar values, this will work once, but then fail again because Ansible will set basicAuth to false again. If you also configure basicAuth foobar values in Ansible, things "work". The real fun is then, that it does this of course for all kinds of data sources, even those that do not support basicAuth at all (like PostgreSQL) at which part there is no workaround...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants