2017-05-03 18:51:04 +03:00
|
|
|
---
|
|
|
|
- name: Check current docker-compose version.
|
2021-03-12 15:47:48 +03:00
|
|
|
command: "{{ docker_compose_path }} --version"
|
2022-01-26 19:25:55 +03:00
|
|
|
register: docker_compose_vsn
|
2022-01-13 20:20:24 +03:00
|
|
|
check_mode: false
|
2017-05-03 18:51:04 +03:00
|
|
|
changed_when: false
|
|
|
|
failed_when: false
|
|
|
|
|
2022-01-26 19:25:55 +03:00
|
|
|
- set_fact:
|
|
|
|
docker_compose_current_version: "{{ docker_compose_vsn.stdout | regex_search('(\\d+(\\.\\d+)+)') }}"
|
2022-04-04 18:32:17 +03:00
|
|
|
when: docker_compose_vsn.stdout is defined
|
|
|
|
|
2017-05-03 18:51:04 +03:00
|
|
|
- name: Delete existing docker-compose version if it's different.
|
|
|
|
file:
|
2017-05-03 19:06:24 +03:00
|
|
|
path: "{{ docker_compose_path }}"
|
2017-05-03 18:51:04 +03:00
|
|
|
state: absent
|
2017-05-03 18:59:50 +03:00
|
|
|
when: >
|
2022-04-12 16:53:25 +03:00
|
|
|
docker_compose_current_version is defined
|
|
|
|
and (docker_compose_version | regex_replace('v', '')) not in docker_compose_current_version
|
2017-05-03 18:51:04 +03:00
|
|
|
|
|
|
|
- name: Install Docker Compose (if configured).
|
|
|
|
get_url:
|
2021-03-12 15:44:42 +03:00
|
|
|
url: "{{ docker_compose_url }}"
|
2017-05-03 19:06:24 +03:00
|
|
|
dest: "{{ docker_compose_path }}"
|
2017-05-03 18:51:04 +03:00
|
|
|
mode: 0755
|
2021-03-12 15:47:48 +03:00
|
|
|
when: >
|
2022-01-26 19:25:55 +03:00
|
|
|
(docker_compose_current_version is not defined)
|
|
|
|
or (docker_compose_current_version|length == 0)
|
2022-04-04 18:32:17 +03:00
|
|
|
or (docker_compose_current_version is version((docker_compose_version | regex_replace('v', '')), '<'))
|