Skip to content

Commit

Permalink
fixup! fixup! fixup! fixup! fixup! fixup! Allow managing dashboards i…
Browse files Browse the repository at this point in the history
…n subfolders
  • Loading branch information
BenjaminSchubert committed Dec 11, 2024
1 parent f2b68a1 commit 159f61a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions changelogs/fragments/411-dashboard-subfolders.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

---
minor_changes:
- Allow creating dashboards in subfolders for `grafana_dashboard`
5 changes: 5 additions & 0 deletions plugins/modules/grafana_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,11 @@ def grafana_create_dashboard(module, data):

# test if the folder exists
folder_exists = False
if data["parent_uid"] and grafana_version < 11:
module.fail_json(

Check warning on line 404 in plugins/modules/grafana_dashboard.py

View check run for this annotation

Codecov / codecov/patch

plugins/modules/grafana_dashboard.py#L404

Added line #L404 was not covered by tests
failed=True, msg="Subfolder API is available starting Grafana v11"
)

if grafana_version >= 5:
folder_exists, folder_id = grafana_folder_exists(
module, data["url"], data["folder"], data["parent_uid"], headers
Expand Down
1 change: 1 addition & 0 deletions roles/grafana/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ Configure Grafana organizations, dashboards, folders, datasources, teams and use
| org_id | no |
| org_name | no |
| overwrite | no |
| parent_uid | no |
| path | no |
| slug | no |
| state | no |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,8 @@
that:
- diff_result4.failed == false
- diff_result4.changed == true
rescue:
- name: Skip if we are running an older version of Grafana
ansible.builtin.assert:
that:
- sub_folder.msg | default ('') == 'Subfolder API is available'

0 comments on commit 159f61a

Please sign in to comment.