Role: docker_compose: replace command with module (#214)
All checks were successful
ansible-lint / gitleaks (push) Successful in -16m19s
ansible-lint / Ansible Lint (push) Successful in -15m56s

Reviewed-on: #214
Co-authored-by: Michael Grote <michael.grote@posteo.de>
Co-committed-by: Michael Grote <michael.grote@posteo.de>
This commit is contained in:
Michael Grote 2024-10-23 17:59:34 +02:00 committed by Michael Grote
parent d65c56332b
commit c8e7fe9dc6

View file

@ -51,13 +51,13 @@
when:
- item.network is defined
- name: (re)start container
- name: restart changed container
become: true
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
community.docker.docker_compose_v2:
project_src: "{{ compose_dest_basedir }}/{{ item.name }}"
state: restarted
dependencies: true
pull: missing
loop: "{{ compose_files }}"
when:
- item.state == "present"
@ -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"