- collect-compose.yml: Fetches all compose files from docker_hosts - collect-env-templates.yml: Creates .env.example with secrets redacted - deploy-compose.yml: Pushes compose files to hosts (with optional restart) - diff-compose.yml: Shows differences before deploying Collected 23 compose files from 7 hosts: - replicant: 12 stacks (arr-stack, mealie, portainer, etc) - docker666: 4 stacks (unifi, gluetun, uptime, utils) - databases: 3 stacks (postgres, forgejo, utils) - download-stack: 2 stacks (download-stack, utils) - media-transcode: 1 stack (utils) - network-services: 1 stack (utils) - immich: 1 stack (utils)
44 lines
1.5 KiB
YAML
44 lines
1.5 KiB
YAML
---
|
|
- 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
|