2021-02-13 14:20:18 +01:00
|
|
|
---
|
|
|
|
- name: Check current docker-compose version.
|
2023-02-17 11:50:19 +01:00
|
|
|
command: "{{ docker_compose_path }} --version"
|
|
|
|
register: docker_compose_vsn
|
|
|
|
check_mode: false
|
2021-02-13 14:20:18 +01:00
|
|
|
changed_when: false
|
|
|
|
failed_when: false
|
|
|
|
|
2023-02-17 11:50:19 +01:00
|
|
|
- set_fact:
|
|
|
|
docker_compose_current_version: "{{ docker_compose_vsn.stdout | regex_search('(\\d+(\\.\\d+)+)') }}"
|
|
|
|
when: >
|
|
|
|
docker_compose_vsn.stdout is defined
|
|
|
|
and (docker_compose_vsn.stdout | length > 0)
|
|
|
|
|
2021-02-13 14:20:18 +01:00
|
|
|
- name: Delete existing docker-compose version if it's different.
|
|
|
|
file:
|
|
|
|
path: "{{ docker_compose_path }}"
|
|
|
|
state: absent
|
|
|
|
when: >
|
2023-02-17 11:50:19 +01:00
|
|
|
docker_compose_current_version is defined
|
|
|
|
and (docker_compose_version | regex_replace('v', '')) not in docker_compose_current_version
|
2021-02-13 14:20:18 +01:00
|
|
|
|
|
|
|
- name: Install Docker Compose (if configured).
|
|
|
|
get_url:
|
2023-02-17 11:50:19 +01:00
|
|
|
url: "{{ docker_compose_url }}"
|
2021-02-13 14:20:18 +01:00
|
|
|
dest: "{{ docker_compose_path }}"
|
|
|
|
mode: 0755
|
2023-02-17 11:50:19 +01:00
|
|
|
when: >
|
|
|
|
(docker_compose_current_version is not defined)
|
|
|
|
or (docker_compose_current_version | length == 0)
|
|
|
|
or (docker_compose_current_version is version((docker_compose_version | regex_replace('v', '')), '<'))
|