-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dashboard: Fail if the target directory does not exist
Previously, this would 'succeed' but the dashboard would not be added.
- Loading branch information
1 parent
e132eaf
commit 5f72a4d
Showing
4 changed files
with
39 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
bugfixes: | ||
- grafana_dashboard now explicitely fails if the folder doesn't exist upon creation. | ||
It would previously silently pass but not create the dashboard. | ||
(https://github.com/ansible-collections/community.grafana/issues/153) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
tests/integration/targets/grafana_dashboard/tasks/dashboard-folder-destination.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- | ||
- name: copy dashboard file | ||
copy: | ||
src: "files/dashboard.json" | ||
dest: "/tmp/dashboard.json" | ||
|
||
- block: | ||
- name: Check import grafana dashboard from file to unknown folder fails | ||
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: inexistent | ||
register: result | ||
ignore_errors: true | ||
|
||
- debug: | ||
var: result | ||
|
||
- set_fact: | ||
# XXX: Too many quotes of different types to do inline. | ||
# I did not manage to find a good way of having it inline. | ||
expected_error: "error : Dashboard folder 'inexistent' does not exist." | ||
|
||
- assert: | ||
that: | ||
- "result.changed == false" | ||
- "result.failed == true" | ||
- "result.msg == expected_error" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters