--- - name: Deploy Download Stack (gluetun + nzbget + rutorrent) hosts: download-stack become: true vars: service_dir: /home/docker/appdata/download-stack compose_src: "{{ playbook_dir }}/../compose-files/download-stack/download-stack" tasks: - name: Create download-stack directory file: path: "{{ service_dir }}" state: directory mode: '0755' - name: Ensure download network exists shell: docker network inspect download >/dev/null 2>&1 || docker network create download changed_when: false - name: Copy docker-compose.yml copy: src: "{{ compose_src }}/docker-compose.yml" dest: "{{ service_dir }}/docker-compose.yml" mode: '0644' backup: yes - name: Check if local .env exists delegate_to: localhost become: no stat: path: "{{ compose_src }}/.env" register: local_env - name: Copy .env file (if local copy exists) copy: src: "{{ compose_src }}/.env" dest: "{{ service_dir }}/.env" mode: '0600' when: local_env.stat.exists - name: Pull images shell: docker compose pull args: chdir: "{{ service_dir }}" - name: Start gluetun first shell: docker compose up -d --force-recreate gluetun args: chdir: "{{ service_dir }}" - name: Wait for gluetun to become healthy shell: docker inspect --format '{{ '{{' }}.State.Health.Status{{ '}}' }}' gluetun register: gluetun_health until: gluetun_health.stdout == "healthy" retries: 30 delay: 5 changed_when: false - name: Start nzbget and rutorrent shell: docker compose up -d --force-recreate nzbget rutorrent args: chdir: "{{ service_dir }}" - name: Check container status shell: docker ps --filter name=gluetun --filter name=nzbget --filter name=rutorrent --format "table {{ '{{' }}.Names{{ '}}' }}\t{{ '{{' }}.Status{{ '}}' }}" | head -10 register: container_status changed_when: false - name: Show status debug: msg: "{{ container_status.stdout_lines }}"