diff --git a/plugins/modules/grafana_dashboard.py b/plugins/modules/grafana_dashboard.py index cd729bb6..bfb737bf 100644 --- a/plugins/modules/grafana_dashboard.py +++ b/plugins/modules/grafana_dashboard.py @@ -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 diff --git a/tests/integration/targets/grafana_dashboard/tasks/dashboard-folder-destination.yml b/tests/integration/targets/grafana_dashboard/tasks/dashboard-folder-destination.yml index 4704002f..f8daeab6 100644 --- a/tests/integration/targets/grafana_dashboard/tasks/dashboard-folder-destination.yml +++ b/tests/integration/targets/grafana_dashboard/tasks/dashboard-folder-destination.yml @@ -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