- 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)
64 lines
2 KiB
YAML
64 lines
2 KiB
YAML
---
|
|
- name: Collect docker-compose files from all hosts
|
|
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 all docker-compose files
|
|
find:
|
|
paths: "{{ appdata_path }}"
|
|
patterns: "docker-compose.yml,docker-compose.yaml"
|
|
recurse: yes
|
|
depth: 3
|
|
register: compose_files
|
|
|
|
- name: Show found compose files
|
|
debug:
|
|
msg: "Found {{ compose_files.files | length }} compose files on {{ inventory_hostname }}"
|
|
|
|
- name: Create local directory for host
|
|
delegate_to: localhost
|
|
become: no
|
|
file:
|
|
path: "{{ playbook_dir }}/../compose-files/{{ inventory_hostname }}"
|
|
state: directory
|
|
mode: '0755'
|
|
|
|
- name: Fetch compose files
|
|
fetch:
|
|
src: "{{ item.path }}"
|
|
dest: "{{ playbook_dir }}/../compose-files/{{ inventory_hostname }}/{{ item.path | dirname | basename }}/"
|
|
flat: yes
|
|
loop: "{{ compose_files.files }}"
|
|
loop_control:
|
|
label: "{{ item.path | dirname | basename }}/docker-compose.yml"
|
|
|
|
- name: Also fetch .env.example if exists
|
|
fetch:
|
|
src: "{{ item.path | dirname }}/.env.example"
|
|
dest: "{{ playbook_dir }}/../compose-files/{{ inventory_hostname }}/{{ item.path | dirname | basename }}/"
|
|
flat: yes
|
|
fail_on_missing: no
|
|
loop: "{{ compose_files.files }}"
|
|
loop_control:
|
|
label: "{{ item.path | dirname | basename }}/.env.example"
|
|
|
|
- name: Summary
|
|
hosts: localhost
|
|
gather_facts: no
|
|
tasks:
|
|
- name: Count collected files
|
|
find:
|
|
paths: "{{ playbook_dir }}/../compose-files"
|
|
patterns: "docker-compose.yml,docker-compose.yaml"
|
|
recurse: yes
|
|
register: total_files
|
|
|
|
- name: Show summary
|
|
debug:
|
|
msg: "Total compose files collected: {{ total_files.files | length }}"
|