syntax fix for docker-tasks

This commit is contained in:
Arya 2023-07-14 21:32:36 +05:30
parent 3ea64ddbb8
commit 8b90ad1c57
Signed by: arya
GPG Key ID: 842D12BDA50DF120

View File

@ -1,15 +1,15 @@
--- ---
- name: Create directory for service - name: Create directory for service
ansible.builtin.file: ansible.builtin.file:
path: {{docker_dir}}/{{ item }} path: "{{ docker_dir }}/{{ item }}"
state: directory state: directory
mode: "0755" mode: "0755"
tags: docker tags: docker
- name: Copy docker-compose templates for the service - name: Copy docker-compose templates for the service
ansible.builtin.template: ansible.builtin.template:
src: ./compose/{{ item }}/compose.yml.j2 src: "./compose/{{ item }}/compose.yml.j2"
dest: {{docker_dir}}/{{ item }}/compose.yml dest: "{{ docker_dir }}/{{ item }}/compose.yml"
backup: true backup: true
mode: preserve mode: preserve
register: check_status register: check_status
@ -24,8 +24,8 @@
- name: Copy extras file - name: Copy extras file
ansible.builtin.template: ansible.builtin.template:
src: ./compose/{{ item }}/extras.conf.j2 src: "./compose/{{ item }}/extras.conf.j2"
dest: {{docker_dir}}/{{ item }}/extras.conf dest: "{{ docker_dir }}/{{ item }}/extras.conf"
backup: true backup: true
mode: preserve mode: preserve
when: file.stat.exists when: file.stat.exists
@ -33,21 +33,27 @@
- name: "Update docker service image" - name: "Update docker service image"
ansible.builtin.command: ansible.builtin.command:
chdir: "{{docker_dir}}/{{ item }}" chdir: "{{ docker_dir }}/{{ item }}"
cmd: docker compose pull cmd: docker compose pull
when: check_status.changed when: check_status.changed
register: updateout
changed_when: updateout.rc != 0
tags: docker tags: docker
- name: "Stop docker service" - name: "Stop docker service"
ansible.builtin.command: ansible.builtin.command:
chdir: "{{docker_dir}}/{{ item }}" chdir: "{{ docker_dir }}/{{ item }}"
cmd: docker compose down cmd: docker compose down
when: check_status.changed when: check_status.changed
register: stopout
changed_when: stopout.rc != 0
tags: docker tags: docker
- name: "Start docker service" - name: "Start docker service"
ansible.builtin.command: ansible.builtin.command:
chdir: "{{docker_dir}}/{{ item }}" chdir: "{{ docker_dir }}/{{ item }}"
cmd: docker compose up -d --build --remove-orphans cmd: docker compose up -d --build --remove-orphans
when: check_status.changed when: check_status.changed
register: startout
changed_when: startout.rc != 0
tags: docker tags: docker