Skip to content

Conversation

@MatthieuFrax
Copy link

SUMMARY

Manage Grafana Folders Permissions

ISSUE TYPE
  • New Module Pull Request
COMPONENT NAME

plugins/modules/grafana_folder_permission.py

ADDITIONAL INFORMATION

Using tag 1.5.4 to develop this feature

requirements:

  • The Folders Permission API is only available starting Grafana 6 and the module will fail if the server version is lower than version 6.
    options:
    state:
    description:
    • State of permission for the folder
      default: present
      type: str
      choices: ["present", "absent"]
      folder:
      description:
    • Folder name to apply permission
      required: true
      type: str
      team:
      description:
    • Team name to apply permission
      type: str
      user:
      description:
    • User name to apply permission
      type: str
      role:
      description:
    • User name to apply permission
      type: str
      choices: ['Admin', 'Viewer', 'Editor']
      permission:
      description:
    • User name to apply permission
      type: str
      choices: ['view', 'edit', 'admin']
      required: true
      extends_documentation_fragment:
  • community.grafana.basic_auth
  • community.grafana.api_key
    '''

EXAMPLES = '''

  • name: Set view permission for user that have the role viewer
    community.grafana.grafana_folder_permission:
    url: "https://grafana.example.com"
    grafana_api_key: "{{ some_api_token_value }}"
    folder: "folder"
    role: "Viewer"
    permission: "view"
    state: present

  • name: Set edit permission for team "justice league"
    community.grafana.grafana_folder_permission:
    url: "https://grafana.example.com"
    grafana_api_key: "{{ some_api_token_value }}"
    folder: "folder"
    team: "justice league"
    permission: "edit"

  • name: Remove admin permission for user "batman"
    community.grafana.grafana_folder_permission:
    url: "https://grafana.example.com"
    grafana_api_key: "{{ some_api_token_value }}"
    folder: "folder"
    user: "batman"
    permission: "admin"
    state: absent

@MatthieuFrax MatthieuFrax requested review from rrey and seuf as code owners June 26, 2025 16:11
@codecov
Copy link

codecov bot commented Jun 26, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.80%. Comparing base (a3b68b4) to head (f454d05).
Report is 492 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #434      +/-   ##
==========================================
+ Coverage   73.85%   75.80%   +1.94%     
==========================================
  Files          13       17       +4     
  Lines        1595     2079     +484     
  Branches      274      454     +180     
==========================================
+ Hits         1178     1576     +398     
- Misses        280      333      +53     
- Partials      137      170      +33     
Flag Coverage Δ
integration 71.30% <ø> (+2.68%) ⬆️
units 65.24% <ø> (-0.53%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator

@Nemental Nemental left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @MatthieuFrax
Thanks for your contribution! We definitely need some ansible integration/tests here... Please keep an eye on the grafana role inside the collection, which also has to be updated for supporting the new module.

module: grafana_folder_permissions
author:
- G3S team
version_added: "1.5.4-g3s-1"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this version? The current collection version is 2.2.0.

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 this pull request may close these issues.

2 participants