Skip to content

Commit

Permalink
fixup! Allow managing dashboards in subfolders
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminSchubert committed Dec 10, 2024
1 parent 8ba881a commit cdd3e3e
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
2 changes: 1 addition & 1 deletion plugins/modules/grafana_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
community.grafana.grafana_dashboard:
grafana_url: http://grafana.company.com
grafana_api_key: "{{ grafana_api_key }}"
folder: public
foldehttps://github.com/ansible-collections/community.grafana/r: public
dashboard_url: https://grafana.com/api/dashboards/6098/revisions/1/download
- name: Import Grafana dashboard zabbix in a subfolder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,57 @@
- dfff_result2.failed == true
- dfff_result2.changed == false
- "dfff_result2.msg == 'error : Dashboard folder \\'inexistent\\' does not exist.'"

- name: Create a dashboard in a folder
block:
- name: Create the original folder
community.grafana.grafana_folder:
title: parent_folder
state: present
register: parent_folder

- name: Create the dashboard in the folder
community.grafana.grafana_dashboard:
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
state: present
commit_message: Updated by ansible
path: /tmp/dashboard.json
overwrite: true
folder: parent_folder
check_mode: false
register: diff_result3
ignore_errors: true
- ansible.builtin.assert:
that:
- diff_result3.failed == false
- diff_result3.changed == true

- name: Create a dashboard in a subfolder
block:
- name: Create the subfolder
community.grafana.grafana_folder:
title: sub_folder
parent_uid: "{{ parent_folder.folder.uid }}"
state: present
register: sub_folder

- name: Create the dashboard in the subfolder
community.grafana.grafana_dashboard:
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
state: present
commit_message: Updated by ansible
path: /tmp/dashboard.json
overwrite: true
folder: sub_folder
parent_uid: "{{ parent_folder.folder.uid }}"
check_mode: false
register: diff_result4
ignore_errors: true
- ansible.builtin.assert:
that:
- diff_result4.failed == false
- diff_result4.changed == true

0 comments on commit cdd3e3e

Please sign in to comment.