65 lines
2.2 KiB
YAML
65 lines
2.2 KiB
YAML
|
---
|
||
|
- name: Docker Deploy
|
||
|
hosts: all
|
||
|
gather_facts: false
|
||
|
vars_files:
|
||
|
- vars/secrets.yml
|
||
|
- vars/services.yml
|
||
|
tasks:
|
||
|
|
||
|
# ----------------------------------------------------------------------------------------------------
|
||
|
|
||
|
- name: Docker Compose down
|
||
|
command: "docker-compose -f {{ docker_dir }}/{{ item }}/docker-compose.yaml down"
|
||
|
loop: "{{ down[inventory_hostname] }}"
|
||
|
when: down is defined and inventory_hostname in down
|
||
|
ignore_errors: yes
|
||
|
|
||
|
- name: Remove project directory
|
||
|
file:
|
||
|
path: "{{ docker_dir }}/{{ item }}"
|
||
|
state: absent
|
||
|
become: true
|
||
|
loop: "{{ remove[inventory_hostname] }}"
|
||
|
when: remove is defined and inventory_hostname in remove
|
||
|
ignore_errors: yes
|
||
|
|
||
|
# ----------------------------------------------------------------------------------------------------
|
||
|
|
||
|
- name: Create project directory
|
||
|
file:
|
||
|
path: "{{ docker_dir }}/{{ item }}"
|
||
|
state: directory
|
||
|
owner: 1000
|
||
|
group: 1000
|
||
|
mode: 0755
|
||
|
loop: "{{ compose[inventory_hostname] }}"
|
||
|
when: compose is defined and inventory_hostname in compose
|
||
|
|
||
|
- name: Inital Setup
|
||
|
include_tasks: "setups/setup-{{ item }}.yml"
|
||
|
loop: "{{ setup[inventory_hostname] }}"
|
||
|
when: setup is defined and inventory_hostname in setup
|
||
|
ignore_errors: yes
|
||
|
|
||
|
- name: Copy Docker Compose
|
||
|
template:
|
||
|
src: "compose/{{ item }}.yaml.j2"
|
||
|
dest: "{{ docker_dir }}/{{ item }}/docker-compose.yaml"
|
||
|
owner: 1000
|
||
|
group: 1000
|
||
|
mode: 0755
|
||
|
loop: "{{ compose[inventory_hostname] }}"
|
||
|
when: compose is defined and inventory_hostname in compose
|
||
|
|
||
|
# ----------------------------------------------------------------------------------------------------
|
||
|
|
||
|
- name: Docker Compose pull
|
||
|
command: "docker-compose -f {{ docker_dir }}/{{ item }}/docker-compose.yaml pull"
|
||
|
loop: "{{ compose[inventory_hostname] }}"
|
||
|
when: compose is defined and inventory_hostname in compose
|
||
|
|
||
|
- name: Docker Compose up
|
||
|
command: "docker-compose -f {{ docker_dir }}/{{ item }}/docker-compose.yaml up --remove-orphans --force-recreate -d"
|
||
|
loop: "{{ compose[inventory_hostname] }}"
|
||
|
when: compose is defined and inventory_hostname in compose
|