ansible/privfrontends/docker-tasks.yaml

54 lines
1.3 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
2023-07-07 22:40:54 +05:30
ansible.builtin.file:
path: /opt/docker/{{ item }}
2023-05-29 21:19:16 +05:30
state: directory
2023-07-07 22:40:54 +05:30
mode: "0755"
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
dest: /opt/docker/{{ item }}/compose.yml
backup: true
mode: preserve
2023-05-13 06:44:40 +05:30
register: check_status
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
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
dest: /opt/docker/{{ item }}/extras.conf
backup: true
mode: preserve
2023-05-13 06:44:40 +05:30
when: file.stat.exists
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-05-13 06:44:40 +05:30
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"
2023-07-07 22:40:54 +05:30
ansible.builtin.command:
2023-05-13 06:44:40 +05:30
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"
2023-07-07 22:40:54 +05:30
ansible.builtin.command:
2023-05-13 06:44:40 +05:30
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