60 lines
1.6 KiB
YAML
60 lines
1.6 KiB
YAML
---
|
|
- name: Create directory for {{item}}
|
|
ansible.builtin.file:
|
|
path: "{{ docker_dir }}/{{ item }}"
|
|
state: directory
|
|
mode: "0755"
|
|
tags: docker,soleil,pizza
|
|
|
|
- name: Copy docker-compose templates for the {{item}}
|
|
ansible.builtin.template:
|
|
src: "./compose/{{ item }}/compose.yml.j2"
|
|
dest: "{{ docker_dir }}/{{ item }}/compose.yml"
|
|
backup: true
|
|
mode: preserve
|
|
register: check_status
|
|
tags: docker,soleil,pizza
|
|
|
|
- name: Check if extras file exists for the {{item}}
|
|
delegate_to: localhost
|
|
ansible.builtin.stat:
|
|
path: ./compose/{{ item }}/extras.conf.j2
|
|
register: file
|
|
tags: docker,soleil,pizza
|
|
|
|
- name: Copy extras file
|
|
ansible.builtin.template:
|
|
src: "./compose/{{ item }}/extras.conf.j2"
|
|
dest: "{{ docker_dir }}/{{ item }}/extras.conf"
|
|
backup: true
|
|
mode: preserve
|
|
when: file.stat.exists
|
|
tags: docker,soleil,pizza
|
|
|
|
- name: "Update docker {{item}} image"
|
|
ansible.builtin.command:
|
|
chdir: "{{ docker_dir }}/{{ item }}"
|
|
cmd: docker compose pull
|
|
when: check_status.changed
|
|
register: updateout
|
|
changed_when: updateout.rc != 0
|
|
tags: docker,soleil,pizza
|
|
|
|
- name: "Stop docker {{item}}"
|
|
ansible.builtin.command:
|
|
chdir: "{{ docker_dir }}/{{ item }}"
|
|
cmd: docker compose down
|
|
when: check_status.changed
|
|
register: stopout
|
|
changed_when: stopout.rc != 0
|
|
tags: docker,soleil,pizza
|
|
|
|
- name: "Start docker {{item}}"
|
|
ansible.builtin.command:
|
|
chdir: "{{ docker_dir }}/{{ item }}"
|
|
cmd: docker compose up -d --build --remove-orphans
|
|
when: check_status.changed
|
|
register: startout
|
|
changed_when: startout.rc != 0
|
|
tags: docker,soleil,pizza
|