From 8c31964a93dbd0f85e3de6f2655aae6112123ec8 Mon Sep 17 00:00:00 2001 From: Michael Grote Date: Fri, 15 Nov 2024 20:29:06 +0000 Subject: [PATCH 1/5] Revert "Role: docker_compose: replace command with module (#214)" This reverts commit c8e7fe9dc6a6df40f4a9904e800d0acef7b91032. --- .../tasks/main.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/roles/mgrote_docker_compose_inline/tasks/main.yml b/roles/mgrote_docker_compose_inline/tasks/main.yml index 10ad907e..29645687 100644 --- a/roles/mgrote_docker_compose_inline/tasks/main.yml +++ b/roles/mgrote_docker_compose_inline/tasks/main.yml @@ -51,13 +51,13 @@ when: - item.network is defined -- name: restart changed container +- name: (re)start container become: true - community.docker.docker_compose_v2: - project_src: "{{ compose_dest_basedir }}/{{ item.name }}" - state: restarted - dependencies: true - pull: missing + ansible.builtin.command: docker-compose up -d + args: + chdir: "{{ compose_dest_basedir }}/{{ item.name }}" + register: start_result # speichere ergebnis in var + changed_when: "start_result.rc == 0" # markiere tasks als changed when exit-code == 0 loop: "{{ compose_files }}" when: - item.state == "present" @@ -65,9 +65,9 @@ - name: stop old container become: true - community.docker.docker_compose_v2: - project_src: "{{ compose_dest_basedir }}/{{ item.name }}" - state: absent + ansible.builtin.command: docker-compose down # noqa no-changed-when + args: + chdir: "{{ compose_dest_basedir }}/{{ item.name }}" loop: "{{ compose_files }}" when: - item.state == "absent" -- 2.43.0 From 731883bc31f61ce4d63775780e7f18489bfbbf6e Mon Sep 17 00:00:00 2001 From: Michael Grote Date: Fri, 15 Nov 2024 20:30:22 +0000 Subject: [PATCH 2/5] changed Files: roles/mgrote_docker_compose_inline/tasks/main.yml Signed-off-by: Michael Grote --- roles/mgrote_docker_compose_inline/tasks/main.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/roles/mgrote_docker_compose_inline/tasks/main.yml b/roles/mgrote_docker_compose_inline/tasks/main.yml index 29645687..4584b5fb 100644 --- a/roles/mgrote_docker_compose_inline/tasks/main.yml +++ b/roles/mgrote_docker_compose_inline/tasks/main.yml @@ -65,9 +65,9 @@ - name: stop old container become: true - ansible.builtin.command: docker-compose down # noqa no-changed-when - args: - chdir: "{{ compose_dest_basedir }}/{{ item.name }}" + community.docker.docker_compose_v2: + project_src: "{{ compose_dest_basedir }}/{{ item.name }}" + state: absent loop: "{{ compose_files }}" when: - item.state == "absent" -- 2.43.0 From 6ae911b82d930445db19d1428cae5bcc80a15e0a Mon Sep 17 00:00:00 2001 From: Michael Grote Date: Fri, 15 Nov 2024 20:31:19 +0000 Subject: [PATCH 3/5] changed Files: roles/mgrote_docker_compose_inline/tasks/main.yml Signed-off-by: Michael Grote --- roles/mgrote_docker_compose_inline/tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/mgrote_docker_compose_inline/tasks/main.yml b/roles/mgrote_docker_compose_inline/tasks/main.yml index 4584b5fb..a954f734 100644 --- a/roles/mgrote_docker_compose_inline/tasks/main.yml +++ b/roles/mgrote_docker_compose_inline/tasks/main.yml @@ -53,7 +53,7 @@ - name: (re)start container become: true - ansible.builtin.command: docker-compose up -d + ansible.builtin.command: "docker-compose pull && docker-compose up -d" args: chdir: "{{ compose_dest_basedir }}/{{ item.name }}" register: start_result # speichere ergebnis in var -- 2.43.0 From ae87e28245755dcf1832f0cf76d9707df3c96a5a Mon Sep 17 00:00:00 2001 From: Michael Grote Date: Fri, 15 Nov 2024 20:34:36 +0000 Subject: [PATCH 4/5] changed Files: roles/mgrote_docker_compose_inline/tasks/main.yml Signed-off-by: Michael Grote --- roles/mgrote_docker_compose_inline/tasks/main.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/roles/mgrote_docker_compose_inline/tasks/main.yml b/roles/mgrote_docker_compose_inline/tasks/main.yml index a954f734..224a0bed 100644 --- a/roles/mgrote_docker_compose_inline/tasks/main.yml +++ b/roles/mgrote_docker_compose_inline/tasks/main.yml @@ -51,9 +51,17 @@ when: - item.network is defined +- name: Pull images + become: true + ansible.builtin.command: docker-compose pull + args: + chdir: "{{ compose_dest_basedir }}/{{ item.name }}" + register: pull_result # speichere ergebnis in var + changed_when: "pull_result.rc == 0" # markiere tasks als changed when exit-code == 0 + - name: (re)start container become: true - ansible.builtin.command: "docker-compose pull && docker-compose up -d" + ansible.builtin.command: docker-compose up -d args: chdir: "{{ compose_dest_basedir }}/{{ item.name }}" register: start_result # speichere ergebnis in var -- 2.43.0 From 93ae6367561b223e7c93826600ac5d1dc8bf46f9 Mon Sep 17 00:00:00 2001 From: Michael Grote Date: Fri, 15 Nov 2024 20:37:18 +0000 Subject: [PATCH 5/5] changed Files: roles/mgrote_docker_compose_inline/tasks/main.yml Signed-off-by: Michael Grote --- roles/mgrote_docker_compose_inline/tasks/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/roles/mgrote_docker_compose_inline/tasks/main.yml b/roles/mgrote_docker_compose_inline/tasks/main.yml index 224a0bed..70b3eee3 100644 --- a/roles/mgrote_docker_compose_inline/tasks/main.yml +++ b/roles/mgrote_docker_compose_inline/tasks/main.yml @@ -58,6 +58,7 @@ chdir: "{{ compose_dest_basedir }}/{{ item.name }}" register: pull_result # speichere ergebnis in var changed_when: "pull_result.rc == 0" # markiere tasks als changed when exit-code == 0 + loop: "{{ compose_files }}" - name: (re)start container become: true -- 2.43.0