make corevm_ssh_key a var + make docker_dir customizable

This commit is contained in:
2023-07-14 17:19:15 +05:30
parent d95d114d10
commit 5d525e0c4e
4 changed files with 52 additions and 16 deletions

View File

@@ -1,7 +1,7 @@
---
- name: Create directory for service
ansible.builtin.file:
path: /opt/docker/{{ item }}
path: {{docker_dir}}/{{ item }}
state: directory
mode: "0755"
tags: docker
@@ -9,7 +9,7 @@
- name: Copy docker-compose templates for the service
ansible.builtin.template:
src: ./compose/{{ item }}/compose.yml.j2
dest: /opt/docker/{{ item }}/compose.yml
dest: {{docker_dir}}/{{ item }}/compose.yml
backup: true
mode: preserve
register: check_status
@@ -25,7 +25,7 @@
- name: Copy extras file
ansible.builtin.template:
src: ./compose/{{ item }}/extras.conf.j2
dest: /opt/docker/{{ item }}/extras.conf
dest: {{docker_dir}}/{{ item }}/extras.conf
backup: true
mode: preserve
when: file.stat.exists
@@ -33,21 +33,21 @@
- name: "Update docker service image"
ansible.builtin.command:
chdir: "/opt/docker/{{ item }}"
chdir: "{{docker_dir}}/{{ item }}"
cmd: docker compose pull
when: check_status.changed
tags: docker
- name: "Stop docker service"
ansible.builtin.command:
chdir: "/opt/docker/{{ item }}"
chdir: "{{docker_dir}}/{{ item }}"
cmd: docker compose down
when: check_status.changed
tags: docker
- name: "Start docker service"
ansible.builtin.command:
chdir: "/opt/docker/{{ item }}"
chdir: "{{docker_dir}}/{{ item }}"
cmd: docker compose up -d --build --remove-orphans
when: check_status.changed
tags: docker