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

service account token does not work with lookup plugin grafana_dashboard #303

Closed
fotto opened this issue Mar 14, 2023 · 3 comments · Fixed by #376
Closed

service account token does not work with lookup plugin grafana_dashboard #303

fotto opened this issue Mar 14, 2023 · 3 comments · Fixed by #376
Assignees

Comments

@fotto
Copy link

fotto commented Mar 14, 2023

SUMMARY

Using lookup plugin "grafana_dashboard" with a service account token returns 401 (Unauthorized)

https://github.com/ansible-collections/community.grafana/blob/main/plugins/lookup/grafana_dashboard.py#L118 appends '==' to all service account tokens generated with Grafana 9.2.x which makes the resulting Authorization Header invalid.

Please verify whether that logic is still applicable.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

plugins/lookup/grafana_dashboard.py

ANSIBLE VERSION
ansible-playbook [core 2.14.3]
COLLECTION VERSION
community.grafana    1.5.4
CONFIGURATION
OS / ENVIRONMENT

Grafana 9.2.10

STEPS TO REPRODUCE
  • create service account in Grafana
  • create service account token for new service acocunt
  • use service account token and Grafana server URL in a playbook containing the snippet shown below
  tasks:
  - name: get existing dashboards
    set_fact:
      grafana_dashboards: "{{ lookup('grafana_dashboard', 'grafana_url=' ~ grafana_server_url ~ ' grafana_api_key=' ~ grafana_api_key) }}"
  - debug:
      var: grafana_dashboards
EXPECTED RESULTS

List of defined dashboards is returned.

The expected result can be enforce by removing 118-124 from https://github.com/ansible-collections/community.grafana/blob/main/plugins/lookup/grafana_dashboard.py#L118

ACTUAL RESULTS
fatal: [ansible_master]: FAILED! => {"msg": "An unhandled exception occurred while running the lookup plugin 'grafana_dashboard'. Error was a <class 'ansible_collections.community.grafana.plugins.lookup.grafana_dashboard.GrafanaAPIException'>, original message: Unable to search dashboards : HTTP Error 401: Unauthorized. Unable to search dashboards : HTTP Error 401: Unauthorized"}
@clasch1985

This comment was marked as off-topic.

@Nemental
Copy link
Collaborator

Nemental commented Aug 7, 2024

Hi @fotto, are you still having this problem? Please let me know. 401 sounds like an authentication problem or a wrong token.

@fotto
Copy link
Author

fotto commented Aug 10, 2024

Hi @fotto, are you still having this problem? Please let me know. 401 sounds like an authentication problem or a wrong token.

Unfortunately, I cannot easily reproduce the setup.

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