File tree Expand file tree Collapse file tree 1 file changed +14
-6
lines changed
ansible/roles/grafana-dashboards/tasks Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change 127
127
mode : 0640
128
128
notify : restart grafana
129
129
130
- - name : Register previously copied dashboards
130
+ - name : Register preexisting dashboards
131
131
become : true
132
132
find :
133
133
paths : " {{ grafana_data_dir }}/dashboards"
134
134
hidden : true
135
135
patterns :
136
136
- " *.json"
137
- register : _dashboards_present
137
+ register : _dashboards_pre
138
138
139
139
- name : Import grafana dashboards
140
140
become : true
141
141
copy :
142
142
remote_src : yes
143
143
src : " {{ _tmp_dashboards.path }}/" # Note trailing / to only copy contents, not directory itself
144
144
dest : " {{ grafana_data_dir }}/dashboards/"
145
- register : _dashboards_copied
146
145
notify : " provisioned dashboards changed"
147
146
147
+ - name : Register all installed dashboards
148
+ become : true
149
+ find :
150
+ paths : " {{ grafana_data_dir }}/dashboards"
151
+ hidden : true
152
+ patterns :
153
+ - " *.json"
154
+ register : _dashboards_post
155
+
148
156
- name : Get dashboard lists
149
157
set_fact :
150
- _dashboards_present_list : " {{ _dashboards_present | json_query('files[*].path') | default([]) }}"
151
- _dashboards_copied_list : " {{ _dashboards_copied | json_query('results [*].dest ') | default([]) }}"
158
+ _dashboards_pre_list : " {{ _dashboards_pre | json_query('files[*].path') | default([]) }}"
159
+ _dashboards_post_list : " {{ _dashboards_post | json_query('files [*].path ') | default([]) }}"
152
160
153
161
- name : Remove installed dashboards not defined through this role
154
162
become : true
155
163
file :
156
164
path : " {{ item }}"
157
165
state : absent
158
- with_items : " {{ _dashboards_present_list | difference( _dashboards_copied_list ) }}"
166
+ with_items : " {{ _dashboards_pre_list | difference( _dashboards_post_list ) }}"
You can’t perform that action at this time.
0 commit comments