Grafana RBAC provisioning

Note: Available in Grafana Enterprise and Grafana Cloud Advanced.

You can create, change or remove Custom roles and create or remove basic role assignments, by adding one or more YAML configuration files in the provisioning/access-control/ directory.

Grafana performs provisioning during startup. After you make a change to the configuration file, you can reload it during runtime. You do not need to restart the Grafana server for your changes to take effect.

Before you begin:

  • Ensure that you have access to files on the server where Grafana is running.

To manage and assign RBAC roles using provisioning:

  1. Sign in to the Grafana server.

  2. Locate the Grafana provisioning folder.

  3. Create a new YAML in the following folder: provisioning/access-control. For example, provisioning/access-control/custom-roles.yml

  4. Add RBAC provisioning details to the configuration file. See manage RBAC roles and assign RBAC roles for instructions, and see this example role provisioning file for a complete example of a provisioning file.

  5. Reload the provisioning configuration file.

    For more information about reloading the provisioning configuration at runtime, refer to Reload provisioning configurations.

Example role configuration file using Grafana provisioning

The following example shows a complete YAML configuration file that:

  • Create custom roles
  • Delete custom roles
  • Update basic roles permissions
  • Assign roles to teams
  • Revoke assignments of roles to teams

Example

  1. ---
  2. # config file version
  3. apiVersion: 2
  4. # <list> list of roles to insert/update/delete
  5. roles:
  6. # <string, required> name of the role you want to create or update. Required.
  7. - name: 'custom:users:writer'
  8. # <string> uid of the role. Has to be unique for all orgs.
  9. uid: customuserswriter1
  10. # <string> description of the role, informative purpose only.
  11. description: 'Create, read, write users'
  12. # <int> version of the role, Grafana will update the role when increased.
  13. version: 2
  14. # <int> org id. Defaults to Grafana's default if not specified.
  15. orgId: 1
  16. # <list> list of the permissions granted by this role.
  17. permissions:
  18. # <string, required> action allowed.
  19. - action: 'users:read'
  20. #<string> scope it applies to.
  21. scope: 'users:*'
  22. - action: 'users:write'
  23. scope: 'users:*'
  24. - action: 'users:create'
  25. - name: 'custom:global:users:reader'
  26. # <bool> overwrite org id and creates a global role.
  27. global: true
  28. # <string> state of the role. Defaults to 'present'. If 'absent', role will be deleted.
  29. state: 'absent'
  30. # <bool> force deletion revoking all grants of the role.
  31. force: true
  32. - uid: 'basic_editor'
  33. version: 2
  34. global: true
  35. # <list> list of roles to copy permissions from.
  36. from:
  37. - uid: 'basic_editor'
  38. global: true
  39. - name: 'fixed:users:writer'
  40. global: true
  41. # <list> list of the permissions to add/remove on top of the copied ones.
  42. permissions:
  43. - action: 'users:read'
  44. scope: 'users:*'
  45. - action: 'users:write'
  46. scope: 'users:*'
  47. # <string> state of the permission. Defaults to 'present'. If 'absent', the permission will be removed.
  48. state: absent
  49. # <list> list role assignments to teams to create or remove.
  50. teams:
  51. # <string, required> name of the team you want to assign roles to. Required.
  52. - name: 'Users writers'
  53. # <int> org id. Will default to Grafana's default if not specified.
  54. orgId: 1
  55. # <list> list of roles to assign to the team
  56. roles:
  57. # <string> uid of the role you want to assign to the team.
  58. - uid: 'customuserswriter1'
  59. # <int> org id. Will default to Grafana's default if not specified.
  60. orgId: 1
  61. # <string> name of the role you want to assign to the team.
  62. - name: 'fixed:users:writer'
  63. # <bool> overwrite org id to specify the role is global.
  64. global: true
  65. # <string> state of the assignment. Defaults to 'present'. If 'absent', the assignment will be revoked.
  66. state: absent