ansible-collections/community.grafana

Folder permissions

Lusitaniae opened this issue · 4 comments

SUMMARY

We're using Grafana to let customers see data on their own environments.

We usually create a folder and add the customer 'team' with the role of viewer

Which seems to be missing here

Seems it would require a 2nd API call to set the correct permissions

Worthwhile adding to folder module or making a new one?

https://grafana.com/docs/grafana/latest/http_api/folder_permissions/

Ansible task to do it

    - name: Set folder permissions
      uri:
        url: "{{ url }}/api/folders/{{ folder.folder.uid }}/permissions"
        method: POST
        body: | # 1 - viewer | 2 - editor # teamId requires int here, otherwise returns 400
            {"items": [{"role": "Editor", "permission": 2}, {"teamId": {{ team_id }}, "permission": 1}]}
        body_format: json
        return_content: yes
        headers:
          Authorization: "Bearer {{ grafana_key }}"
      register: folder_perms```
rrey commented

Hi @Lusitaniae that's a nice addition for the folder module I guess.

I won't be able to work on it unfortunately :( PR welcome !

Thanks for creating issues lately, that's helping 👍

Understand, thanks for all your work so far!