You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
89 lines
2.9 KiB
YAML
89 lines
2.9 KiB
YAML
- 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 | Copy Docker Compose Files
|
|
copy:
|
|
src: "{{item.name}}/docker-compose.yml"
|
|
dest: "{{docker_compose_directory}}/{{item.name}}/docker-compose.yml"
|
|
with_items: "{{services}}"
|
|
|
|
- name: Docker Compose | Copy Stack Env File
|
|
copy:
|
|
src: "{{item.name}}/stack.env"
|
|
dest: "{{docker_compose_directory}}/{{item.name}}/stack.env"
|
|
with_items: "{{services}}"
|
|
|
|
- name: Config Files | Create a directory if it does not exist
|
|
file:
|
|
path: "{{item.destination_directory}}"
|
|
state: directory
|
|
mode: '0755'
|
|
with_items: "{{config_files}}"
|
|
|
|
- name: Config Files | Copy config file
|
|
copy:
|
|
src: "{{item.source_file}}"
|
|
dest: "{{item.destination_directory}}/{{item.destination_file}}"
|
|
with_items: "{{config_files}}"
|
|
|
|
- name: Install python dependencies (requests)
|
|
ansible.builtin.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 }}"
|
|
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_secrets.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}}"
|