ansible/privfrontends/docker-tasks.yaml

49 lines
1.1 KiB
YAML
Raw Normal View History

2023-05-13 06:44:40 +05:30
---
2023-05-29 21:19:16 +05:30
- name: Create directory for service
file:
path: /opt/docker/{{item}}
state: directory
tags: docker
2023-05-13 06:44:40 +05:30
- name: Copy docker-compose templates for the service
2023-05-14 15:56:43 +05:30
template:
2023-05-29 14:08:34 +05:30
src: ./compose/{{item}}/compose.yml.j2
2023-05-13 06:44:40 +05:30
dest: /opt/docker/{{item}}/compose.yml
backup: yes
register: check_status
tags: docker
2023-05-13 06:44:40 +05:30
- name: check if extras file exists for the service
2023-05-29 14:08:34 +05:30
local_action: stat path=./compose/{{item}}/extras.conf.j2
2023-05-13 06:44:40 +05:30
register: file
tags: docker
2023-05-13 06:44:40 +05:30
- name: Copy extras file
2023-05-14 15:56:43 +05:30
template:
2023-05-29 14:08:34 +05:30
src: ./compose/{{item}}/extras.conf.j2
2023-05-13 06:44:40 +05:30
dest: /opt/docker/{{item}}/extras.conf
backup: yes
when: file.stat.exists
tags: docker
2023-05-13 06:44:40 +05:30
- name: "Update docker service image"
command:
chdir: "/opt/docker/{{ item }}"
cmd: docker compose pull
2023-05-29 21:19:16 +05:30
when: check_status.changed
tags: docker
2023-05-13 06:44:40 +05:30
- name: "Stop docker service"
command:
chdir: "/opt/docker/{{ item }}"
cmd: docker compose down
2023-05-29 21:19:16 +05:30
when: check_status.changed
tags: docker
2023-05-13 06:44:40 +05:30
- name: "Start docker service"
command:
chdir: "/opt/docker/{{ item }}"
cmd: docker compose up -d --build --remove-orphans
2023-05-29 21:19:16 +05:30
when: check_status.changed
tags: docker