fix role docker_compose: pull and restart #243
1 changed files with 15 additions and 6 deletions
|
@ -51,13 +51,22 @@
|
|||
when:
|
||||
- item.network is defined
|
||||
|
||||
- name: restart changed container
|
||||
- name: Pull images
|
||||
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 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
|
||||
loop: "{{ compose_files }}"
|
||||
|
||||
- name: (re)start 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
|
||||
loop: "{{ compose_files }}"
|
||||
when:
|
||||
- item.state == "present"
|
||||
|
|
Loading…
Reference in a new issue