--- - name: Include all defaults include_vars: defaults/main-vault.yml - name: Docker | Pull images docker_image: name: "{{item}}" source: pull with_items: - ubuntu - busybox - name: Docker Compose | Create a directory if it does not exist file: path: "{{docker_compose_directory}}/{{item.name}}" state: directory mode: '0755' with_items: "{{services}}" - name: Docker Compose | Template Docker Compose Files template: src: "{{item.name}}.j2" dest: "{{docker_compose_directory}}/{{item.name}}/docker-compose.yml" with_items: "{{services}}" - name: Config Files | Create a directory if it does not exist file: path: "{{item}}" state: directory mode: '0755' with_items: - "{{dashy.destination_dir}}" - "{{olivetin.destination_dir}}" - name: Dashy | Config Files copy: src: "{{dashy.source_file}}" dest: "{{dashy.destination_dir}}/{{dashy.destination_file}}" notify: - restart-dashy - name: Olivetin | Config Files copy: src: "{{olivetin.source_file}}" dest: "{{olivetin.destination_dir}}/{{olivetin.destination_file}}" notify: - restart-olivetin - name: Install python dependencies (requests) pip: name: requests - name: Docker | Find docker volumes shell: docker volume ls -f name={{item.name}} --format '{{ '{{' }} .Name {{ '}}' }}' with_items: "{{services}}" register: find_volumes changed_when: False - debug: msg="{{find_volumes.results | map(attribute='stdout_lines') | list | flatten }}" - name: Docker | Find volumes that need to be restored script: scripts/find-volumes-to-restore.py environment: EXISTING_VOLUMES: "{{ find_volumes.results | map(attribute='stdout_lines') | list | flatten }}" SERVICES: "{{ services }}" DOCKER_COMPOSE_DIR: "{{docker_compose_directory}}" args: executable: python3 register: python_output changed_when: False - debug: msg="{{python_output.stdout_lines | list }}" - name: Docker Volume Backup | Restore any missing backups from S3 docker_container: command: "restore-volume --s3 --volume {{item}}" image: "ghcr.io/chatton/docker-volume-backup:v0.3.0" name: "s3-restore-{{item}}" cleanup: true # delete container after it's done. state: started # container should execute. detach: no # task fails if container exits. volumes: - /var/run/docker.sock:/var/run/docker.sock - /tmp:/tmp # temp s3 archive goes here env: AWS_ACCESS_KEY_ID: "{{aws_s3.aws_access_key}}" AWS_SECRET_ACCESS_KEY: "{{aws_s3.aws_secret_key}}" AWS_DEFAULT_REGION: "{{aws_s3.region}}" AWS_BUCKET: "{{aws_s3.bucket}}" AWS_ENDPOINT: "{{aws_s3.s3_url}}" with_items: "{{ python_output.stdout_lines }}" - name: Docker | Create required docker networks docker_network: name: "{{item}}" with_items: "{{ docker_networks }}" - name: Portainer | Update Stack portainer: username: admin password: "{{portainer.password}}" docker_compose_file_path: "{{docker_compose_directory}}/{{ item.name }}/docker-compose.yml" env_file_path: "{{docker_compose_directory}}/{{ item.name }}/stack.env" stack_name: "{{ item.name }}" with_items: "{{services}}"