--- - name: Show differences between repo and deployed compose files hosts: docker_hosts become: yes gather_facts: no tasks: - name: Set appdata path set_fact: appdata_path: "{{ docker_appdata | default('/home/docker/appdata') }}" - name: Find compose files for this host in repo delegate_to: localhost become: no find: paths: "{{ playbook_dir }}/../compose-files/{{ inventory_hostname }}" patterns: "docker-compose.yml,docker-compose.yaml" recurse: yes register: repo_compose_files - name: Compare each file shell: | if [ -f "{{ appdata_path }}/{{ item.path | dirname | basename }}/docker-compose.yml" ]; then diff -u "{{ appdata_path }}/{{ item.path | dirname | basename }}/docker-compose.yml" - < /dev/stdin || true else echo "NEW FILE - does not exist on host yet" fi args: stdin: "{{ lookup('file', item.path) }}" loop: "{{ repo_compose_files.files }}" loop_control: label: "{{ item.path | dirname | basename }}" register: diff_results changed_when: false - name: Show differences debug: msg: | === {{ item.item.path | dirname | basename }} === {{ item.stdout if item.stdout else 'No differences' }} loop: "{{ diff_results.results }}" loop_control: label: "{{ item.item.path | dirname | basename }}" when: item.stdout | length > 0