Skip to content

Commit

Permalink
Implement when not ansible_check_mode condition
Browse files Browse the repository at this point in the history
  • Loading branch information
1 parent 1738e06 commit 9d110d5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion roles/grafana/tasks/dashboards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,18 @@
become: true
register: __dashboards_copied
notify: "provisioned dashboards changed"
when: not ansible_check_mode

- name: "Register present and copied dashboards list"
ansible.builtin.set_fact:
__dashboards_present_list: "{{ __dashboards_present | json_query('files[*].path') | default([]) }}"
__dashboards_copied_list: "{{ __dashboards_copied | json_query('results[*].dest') | default([]) }}"
when: not ansible_check_mode

- name: "Remove dashboards not present on deployer machine (synchronize)"
ansible.builtin.file:
path: "{{ item }}"
state: absent
loop: "{{ __dashboards_present_list | difference(__dashboards_copied_list) }}"
become: true
when: grafana_provisioning_synced
when: grafana_provisioning_synced and not ansible_check_mode

0 comments on commit 9d110d5

Please sign in to comment.