|
|
|
|
@ -1,7 +1,6 @@
|
|
|
|
|
---
|
|
|
|
|
- name: Docker | Pull images
|
|
|
|
|
docker_image:
|
|
|
|
|
name: "{{item}}"
|
|
|
|
|
name: '{{item}}'
|
|
|
|
|
source: pull
|
|
|
|
|
with_items:
|
|
|
|
|
- ubuntu
|
|
|
|
|
@ -9,47 +8,47 @@
|
|
|
|
|
|
|
|
|
|
- name: Docker Compose | Create a directory if it does not exist
|
|
|
|
|
file:
|
|
|
|
|
path: "{{directories.docker_compose_directory}}/{{item.name}}"
|
|
|
|
|
path: '{{directories.docker_compose_directory}}/{{item.name}}'
|
|
|
|
|
state: directory
|
|
|
|
|
mode: '0755'
|
|
|
|
|
with_items: "{{services}}"
|
|
|
|
|
with_items: '{{services}}'
|
|
|
|
|
|
|
|
|
|
- name: Docker Compose | Template Docker Compose Files
|
|
|
|
|
template:
|
|
|
|
|
src: "{{item.name}}.j2"
|
|
|
|
|
dest: "{{directories.docker_compose_directory}}/{{item.name}}/docker-compose.yml"
|
|
|
|
|
with_items: "{{services}}"
|
|
|
|
|
src: '{{item.name}}.j2'
|
|
|
|
|
dest: '{{directories.docker_compose_directory}}/{{item.name}}/docker-compose.yml'
|
|
|
|
|
with_items: '{{services}}'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Directories | Ensure required directories
|
|
|
|
|
file:
|
|
|
|
|
path: "{{item}}"
|
|
|
|
|
path: '{{item}}'
|
|
|
|
|
state: directory
|
|
|
|
|
mode: '0755'
|
|
|
|
|
with_items:
|
|
|
|
|
- "{{dashy.config_directory}}"
|
|
|
|
|
- "{{olivetin.config_directory}}"
|
|
|
|
|
- "{{dockervolumebackup.config_directory}}"
|
|
|
|
|
- "{{directories.backups_dir}}/.s3tmp"
|
|
|
|
|
- '{{dashy.config_directory}}'
|
|
|
|
|
- '{{olivetin.config_directory}}'
|
|
|
|
|
- '{{dockervolumebackup.config_directory}}'
|
|
|
|
|
- '{{directories.backups_dir}}/.s3tmp'
|
|
|
|
|
|
|
|
|
|
- name: Dashy | Config Files
|
|
|
|
|
copy:
|
|
|
|
|
src: "{{dashy.source_file}}"
|
|
|
|
|
dest: "{{dashy.config_directory}}/{{dashy.config_file}}"
|
|
|
|
|
src: '{{dashy.source_file}}'
|
|
|
|
|
dest: '{{dashy.config_directory}}/{{dashy.config_file}}'
|
|
|
|
|
notify:
|
|
|
|
|
- restart-dashy
|
|
|
|
|
|
|
|
|
|
- name: Olivetin | Config Files
|
|
|
|
|
copy:
|
|
|
|
|
src: "{{olivetin.source_file}}"
|
|
|
|
|
dest: "{{olivetin.config_directory}}/{{olivetin.config_file}}"
|
|
|
|
|
src: '{{olivetin.source_file}}'
|
|
|
|
|
dest: '{{olivetin.config_directory}}/{{olivetin.config_file}}'
|
|
|
|
|
notify:
|
|
|
|
|
- restart-olivetin
|
|
|
|
|
|
|
|
|
|
- name: Docker Volume Backup | Config Files
|
|
|
|
|
template:
|
|
|
|
|
src: "docker-volume-backup/config.j2"
|
|
|
|
|
dest: "{{dockervolumebackup.config_directory}}/config.yml"
|
|
|
|
|
src: docker-volume-backup/config.j2
|
|
|
|
|
dest: '{{dockervolumebackup.config_directory}}/config.yml'
|
|
|
|
|
notify:
|
|
|
|
|
- restart-docker-volume-backup
|
|
|
|
|
|
|
|
|
|
@ -58,32 +57,35 @@
|
|
|
|
|
name: requests
|
|
|
|
|
|
|
|
|
|
- name: Docker | Find docker volumes
|
|
|
|
|
shell: docker volume ls -f name={{item.name}} --format '{{ '{{' }} .Name {{ '}}' }}'
|
|
|
|
|
with_items: "{{services}}"
|
|
|
|
|
shell: docker volume ls -f name={{item.name}} --format '{{ '{{' }} .Name {{ '}}'
|
|
|
|
|
}}'
|
|
|
|
|
with_items: '{{services}}'
|
|
|
|
|
register: find_volumes
|
|
|
|
|
changed_when: False
|
|
|
|
|
changed_when: false
|
|
|
|
|
|
|
|
|
|
- debug: msg="{{find_volumes.results | map(attribute='stdout_lines') | list | flatten }}"
|
|
|
|
|
- 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: "{{directories.docker_compose_directory}}"
|
|
|
|
|
EXISTING_VOLUMES: "{{ find_volumes.results | map(attribute='stdout_lines') | list\
|
|
|
|
|
\ | flatten }}"
|
|
|
|
|
SERVICES: '{{ services }}'
|
|
|
|
|
DOCKER_COMPOSE_DIR: '{{directories.docker_compose_directory}}'
|
|
|
|
|
args:
|
|
|
|
|
executable: python3
|
|
|
|
|
register: python_output
|
|
|
|
|
changed_when: False
|
|
|
|
|
changed_when: false
|
|
|
|
|
|
|
|
|
|
- debug: msg="{{python_output.stdout_lines | list }}"
|
|
|
|
|
|
|
|
|
|
- name: Docker Volume Backup | Restore any missing backups from S3
|
|
|
|
|
when: restore_from_s3
|
|
|
|
|
docker_container:
|
|
|
|
|
command: "restore-volume --s3 --volume {{item}}"
|
|
|
|
|
image: "ghcr.io/chatton/docker-volume-backup:v0.3.0"
|
|
|
|
|
name: "s3-restore-{{item}}"
|
|
|
|
|
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.
|
|
|
|
|
@ -91,32 +93,33 @@
|
|
|
|
|
- /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 }}"
|
|
|
|
|
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: '{{item}}'
|
|
|
|
|
with_items: '{{ docker_networks }}'
|
|
|
|
|
|
|
|
|
|
- name: Portainer | Update Stack
|
|
|
|
|
when: container_deployment_mode == "portainer"
|
|
|
|
|
chatton.portainer.portainer_stack:
|
|
|
|
|
username: admin
|
|
|
|
|
password: "{{portainer.password}}"
|
|
|
|
|
docker_compose_file_path: "{{directories.docker_compose_directory}}/{{ item.name }}/docker-compose.yml"
|
|
|
|
|
stack_name: "{{ item.name }}"
|
|
|
|
|
endpoint_id: "{{ item.endpoint_id }}"
|
|
|
|
|
password: '{{portainer.password}}'
|
|
|
|
|
docker_compose_file_path: '{{directories.docker_compose_directory}}/{{ item.name
|
|
|
|
|
}}/docker-compose.yml'
|
|
|
|
|
stack_name: '{{ item.name }}'
|
|
|
|
|
endpoint_id: '{{ item.endpoint_id }}'
|
|
|
|
|
state: present
|
|
|
|
|
with_items: "{{services}}"
|
|
|
|
|
with_items: '{{services}}'
|
|
|
|
|
|
|
|
|
|
- name: Docker compose | Update Stack
|
|
|
|
|
when: container_deployment_mode == "compose"
|
|
|
|
|
docker_compose:
|
|
|
|
|
project_src: "{{directories.docker_compose_directory}}/{{ item.name }}"
|
|
|
|
|
project_src: '{{directories.docker_compose_directory}}/{{ item.name }}'
|
|
|
|
|
state: present
|
|
|
|
|
with_items: "{{services}}"
|
|
|
|
|
with_items: '{{services}}'
|
|
|
|
|
|