Debian Codegraph @

ansible_collections/community/grafana/tests/integration/targets/grafana_dashboard/tasks/dashboard-export.yml

raw symbols SCIP
1 ---
2 - name: Export Dashboard | check mode | uid does not exist
3 community.grafana.grafana_dashboard:
4 state: export
5 path: /tmp/dashboard_export.json
6 overwrite: true
7 uid: "090909090"
8 check_mode: true
9 ignore_errors: true
10 register: de_result1
11 - ansible.builtin.assert:
12 that:
13 - de_result1.failed == false
14 - de_result1.changed == false
15 - de_result1.uid is defined
16 - de_result1.uid is string
17 - de_result1.uid == "090909090"
18 - de_result1.msg == 'Dashboard ' ~ de_result1.uid ~ ' does not exist.'
19
20 - name: Export Dashboard | run mode | uid does not exist
21 community.grafana.grafana_dashboard:
22 state: export
23 path: /tmp/dashboard_export.json
24 overwrite: true
25 uid: "090909090"
26 check_mode: false
27 ignore_errors: true
28 register: de_result2
29 - ansible.builtin.assert:
30 that:
31 - de_result2.failed == false
32 - de_result2.changed == false
33 - de_result2.uid is defined
34 - de_result2.uid is string
35 - de_result2.uid == "090909090"
36 - de_result2.msg == 'Dashboard ' ~ de_result2.uid ~ ' does not exist.'
37
38 - name: Export Dashboard | check mode | uid exists
39 community.grafana.grafana_dashboard:
40 state: export
41 path: /tmp/dashboard_export.json
42 overwrite: true
43 uid: "{{ uid_to_export }}"
44 check_mode: true
45 register: de_result3
46 - ansible.builtin.assert:
47 that:
48 - de_result3.failed == false
49 - de_result3.changed == true
50 - de_result3.uid is defined
51 - de_result3.uid is string
52 - de_result3.uid == uid_to_export
53 - de_result3.msg == 'Dashboard ' ~ de_result3.uid ~ ' will be exported to /tmp/dashboard_export.json'
54
55 - name: Export Dashboard | run mode | uid exists
56 community.grafana.grafana_dashboard:
57 state: export
58 path: /tmp/dashboard_export.json
59 overwrite: true
60 uid: "{{ uid_to_export }}"
61 check_mode: false
62 register: de_result4
63 - ansible.builtin.assert:
64 that:
65 - de_result4.failed == false
66 - de_result4.changed == true
67 - de_result4.uid is defined
68 - de_result4.uid is string
69 - de_result4.uid == uid_to_export
70 - de_result4.msg == 'Dashboard ' ~ de_result4.uid ~ ' exported to /tmp/dashboard_export.json'
71
72 - name: Export Dashboard | Load /tmp/dashboard_export.json or fail if missing
73 ansible.builtin.set_fact:
74 exported_dashboard_lines: "{{ lookup('file', '/tmp/dashboard_export.json').splitlines() }}"
75
76 - name: Export Dashboard | Assert that exported dashboard contains formatted JSON
77 ansible.builtin.assert:
78 that:
79 - exported_dashboard_lines | length >= 2
80 - exported_dashboard_lines[0] == '{'
81 - exported_dashboard_lines[-1] == '}'