2023-05-13 06:44:40 +05:30
|
|
|
---
|
2023-05-29 21:19:16 +05:30
|
|
|
- name: Create directory for service
|
2023-07-07 22:40:54 +05:30
|
|
|
ansible.builtin.file:
|
2023-07-14 17:19:15 +05:30
|
|
|
path: {{docker_dir}}/{{ item }}
|
2023-05-29 21:19:16 +05:30
|
|
|
state: directory
|
2023-07-07 22:40:54 +05:30
|
|
|
mode: "0755"
|
2023-06-05 14:32:24 +05:30
|
|
|
tags: docker
|
|
|
|
|
2023-05-13 06:44:40 +05:30
|
|
|
- name: Copy docker-compose templates for the service
|
2023-07-07 22:40:54 +05:30
|
|
|
ansible.builtin.template:
|
|
|
|
src: ./compose/{{ item }}/compose.yml.j2
|
2023-07-14 17:19:15 +05:30
|
|
|
dest: {{docker_dir}}/{{ item }}/compose.yml
|
2023-07-07 22:40:54 +05:30
|
|
|
backup: true
|
|
|
|
mode: preserve
|
2023-05-13 06:44:40 +05:30
|
|
|
register: check_status
|
2023-06-05 14:32:24 +05:30
|
|
|
tags: docker
|
2023-05-13 06:44:40 +05:30
|
|
|
|
2023-07-07 22:40:54 +05:30
|
|
|
- name: Check if extras file exists for the service
|
|
|
|
delegate_to: localhost
|
|
|
|
ansible.builtin.stat:
|
|
|
|
path: ./compose/{{ item }}/extras.conf.j2
|
2023-05-13 06:44:40 +05:30
|
|
|
register: file
|
2023-06-05 14:32:24 +05:30
|
|
|
tags: docker
|
|
|
|
|
2023-05-13 06:44:40 +05:30
|
|
|
- name: Copy extras file
|
2023-07-07 22:40:54 +05:30
|
|
|
ansible.builtin.template:
|
|
|
|
src: ./compose/{{ item }}/extras.conf.j2
|
2023-07-14 17:19:15 +05:30
|
|
|
dest: {{docker_dir}}/{{ item }}/extras.conf
|
2023-07-07 22:40:54 +05:30
|
|
|
backup: true
|
|
|
|
mode: preserve
|
2023-05-13 06:44:40 +05:30
|
|
|
when: file.stat.exists
|
2023-06-05 14:32:24 +05:30
|
|
|
tags: docker
|
2023-05-13 06:44:40 +05:30
|
|
|
|
|
|
|
- name: "Update docker service image"
|
2023-07-07 22:40:54 +05:30
|
|
|
ansible.builtin.command:
|
2023-07-14 17:19:15 +05:30
|
|
|
chdir: "{{docker_dir}}/{{ item }}"
|
2023-05-13 06:44:40 +05:30
|
|
|
cmd: docker compose pull
|
2023-05-29 21:19:16 +05:30
|
|
|
when: check_status.changed
|
2023-06-05 14:32:24 +05:30
|
|
|
tags: docker
|
2023-05-13 06:44:40 +05:30
|
|
|
|
|
|
|
- name: "Stop docker service"
|
2023-07-07 22:40:54 +05:30
|
|
|
ansible.builtin.command:
|
2023-07-14 17:19:15 +05:30
|
|
|
chdir: "{{docker_dir}}/{{ item }}"
|
2023-05-13 06:44:40 +05:30
|
|
|
cmd: docker compose down
|
2023-05-29 21:19:16 +05:30
|
|
|
when: check_status.changed
|
2023-06-05 14:32:24 +05:30
|
|
|
tags: docker
|
2023-05-13 06:44:40 +05:30
|
|
|
|
|
|
|
- name: "Start docker service"
|
2023-07-07 22:40:54 +05:30
|
|
|
ansible.builtin.command:
|
2023-07-14 17:19:15 +05:30
|
|
|
chdir: "{{docker_dir}}/{{ item }}"
|
2023-05-13 06:44:40 +05:30
|
|
|
cmd: docker compose up -d --build --remove-orphans
|
2023-05-29 21:19:16 +05:30
|
|
|
when: check_status.changed
|
2023-06-05 14:32:24 +05:30
|
|
|
tags: docker
|