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 127127 mode : 0640
128128 notify : restart grafana
129129
130- - name : Register previously copied dashboards
130+ - name : Register preexisting dashboards
131131 become : true
132132 find :
133133 paths : " {{ grafana_data_dir }}/dashboards"
134134 hidden : true
135135 patterns :
136136 - " *.json"
137- register : _dashboards_present
137+ register : _dashboards_pre
138138
139139- name : Import grafana dashboards
140140 become : true
141141 copy :
142142 remote_src : yes
143143 src : " {{ _tmp_dashboards.path }}/" # Note trailing / to only copy contents, not directory itself
144144 dest : " {{ grafana_data_dir }}/dashboards/"
145- register : _dashboards_copied
146145 notify : " provisioned dashboards changed"
147146
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+
148156- name : Get dashboard lists
149157 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([]) }}"
152160
153161- name : Remove installed dashboards not defined through this role
154162 become : true
155163 file :
156164 path : " {{ item }}"
157165 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