Use new docker compose module and force restart if copy changed
This commit is contained in:
parent
e1d46ee244
commit
4735876db2
@ -25,6 +25,7 @@
|
||||
dest: "{{ docker_compose_remote_project_dir }}"
|
||||
mode: "preserve"
|
||||
directory_mode: "711"
|
||||
register: copy_result
|
||||
loop: "{{ docker_compose_project_list }}"
|
||||
|
||||
- name: Create external docker networks
|
||||
@ -34,23 +35,16 @@
|
||||
loop: "{{ docker_compose_external_network }}"
|
||||
when: docker_compose_external_network is defined
|
||||
|
||||
# Compose V2 Not supported
|
||||
# - name: Manage docker compose project
|
||||
# community.docker.docker_compose:
|
||||
# project_src: "{{ remote_project_dir + '/' + item.name }}"
|
||||
# remove_orphans: true
|
||||
# pull: true
|
||||
# build: true
|
||||
# state: "{{ docker_compose_state }}"
|
||||
# loop: "{{ docker_compose_project_list }}"
|
||||
|
||||
- name: Manage docker compose project
|
||||
ansible.builtin.shell:
|
||||
chdir: "{{ docker_compose_remote_project_dir + '/' + item.name }}"
|
||||
cmd: "docker compose pull && docker compose {{ 'restart' if docker_compose_state == 'restarted' else 'up -d' }} "
|
||||
loop: "{{ docker_compose_project_list }}"
|
||||
register: docker_compose_out
|
||||
changed_when: "'Started' in docker_compose_out.stderr"
|
||||
community.docker.docker_compose_v2:
|
||||
project_src: "{{ docker_compose_remote_project_dir + '/' + item.item.name }}"
|
||||
remove_orphans: true
|
||||
pull: always
|
||||
build: always
|
||||
state: "{{ 'restarted' if item.changed else docker_compose_state }}"
|
||||
loop: "{{ copy_result.results }}"
|
||||
when: not item.failed
|
||||
|
||||
|
||||
- name: Prune docker
|
||||
community.docker.docker_prune:
|
||||
|
Loading…
Reference in New Issue
Block a user