From d072a187e4fb66431347012ff5ef87db6928c1c4 Mon Sep 17 00:00:00 2001 From: Jeff Geerling Date: Wed, 3 May 2017 10:51:04 -0500 Subject: [PATCH 1/3] Fixes #2: Allow for Docker Compose version upgrades. --- defaults/main.yml | 2 +- tasks/docker-compose.yml | 18 ++++++++++++++++++ tasks/main.yml | 6 +----- 3 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 tasks/docker-compose.yml diff --git a/defaults/main.yml b/defaults/main.yml index 863d74f..9771cf3 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -3,7 +3,7 @@ docker_package: "docker-engine" # Docker Compose options. docker_install_compose: true -docker_compose_version: "1.11.2" +docker_compose_version: "1.13.0" # Used only for Debian/Ubuntu. Add 'testing' if you don't want stable. docker_apt_repository: "deb https://apt.dockerproject.org/repo {{ ansible_distribution|lower }}-{{ ansible_distribution_release }} main" diff --git a/tasks/docker-compose.yml b/tasks/docker-compose.yml new file mode 100644 index 0000000..5b4fb8e --- /dev/null +++ b/tasks/docker-compose.yml @@ -0,0 +1,18 @@ +--- +- name: Check current docker-compose version. + command: docker-compose --version + register: docker_compose_current_version + changed_when: false + failed_when: false + +- name: Delete existing docker-compose version if it's different. + file: + path: /usr/local/bin/docker-compose + state: absent + when: docker_compose_version not in docker_compose_current_version.stdout + +- name: Install Docker Compose (if configured). + get_url: + url: https://github.com/docker/compose/releases/download/{{ docker_compose_version }}/docker-compose-Linux-x86_64 + dest: /usr/local/bin/docker-compose + mode: 0755 diff --git a/tasks/main.yml b/tasks/main.yml index 985c8ad..9abd2ed 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -14,9 +14,5 @@ state: started enabled: yes -- name: Install Docker Compose (if configured). - get_url: - url: https://github.com/docker/compose/releases/download/{{ docker_compose_version }}/docker-compose-Linux-x86_64 - dest: /usr/local/bin/docker-compose - mode: 0755 +- include: docker-compose.yml when: docker_install_compose From ab49c85d984b2821cd98e608e72db8018b65b776 Mon Sep 17 00:00:00 2001 From: Jeff Geerling Date: Wed, 3 May 2017 10:59:50 -0500 Subject: [PATCH 2/3] Issue #2: Only use variable if it's defined. --- tasks/docker-compose.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tasks/docker-compose.yml b/tasks/docker-compose.yml index 5b4fb8e..5b0857a 100644 --- a/tasks/docker-compose.yml +++ b/tasks/docker-compose.yml @@ -9,7 +9,9 @@ file: path: /usr/local/bin/docker-compose state: absent - when: docker_compose_version not in docker_compose_current_version.stdout + when: > + docker_compose_current_version.stdout is defined + and docker_compose_version not in docker_compose_current_version.stdout - name: Install Docker Compose (if configured). get_url: From 9180fbe7e5e83f7eebb9da8d7ca1e81e37fb1b06 Mon Sep 17 00:00:00 2001 From: Jeff Geerling Date: Wed, 3 May 2017 11:06:24 -0500 Subject: [PATCH 3/3] Issue #2: Allow customization of the Docker Compose path. --- README.md | 1 + defaults/main.yml | 1 + tasks/docker-compose.yml | 4 ++-- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index de1372a..13af257 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ The Docker package to install. docker_install_compose: true docker_compose_version: "1.11.2" + docker_compose_path: /usr/local/bin/docker-compose Docker Compose installation options. diff --git a/defaults/main.yml b/defaults/main.yml index 9771cf3..2283fb9 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -4,6 +4,7 @@ docker_package: "docker-engine" # Docker Compose options. docker_install_compose: true docker_compose_version: "1.13.0" +docker_compose_path: /usr/local/bin/docker-compose # Used only for Debian/Ubuntu. Add 'testing' if you don't want stable. docker_apt_repository: "deb https://apt.dockerproject.org/repo {{ ansible_distribution|lower }}-{{ ansible_distribution_release }} main" diff --git a/tasks/docker-compose.yml b/tasks/docker-compose.yml index 5b0857a..92cf4f2 100644 --- a/tasks/docker-compose.yml +++ b/tasks/docker-compose.yml @@ -7,7 +7,7 @@ - name: Delete existing docker-compose version if it's different. file: - path: /usr/local/bin/docker-compose + path: "{{ docker_compose_path }}" state: absent when: > docker_compose_current_version.stdout is defined @@ -16,5 +16,5 @@ - name: Install Docker Compose (if configured). get_url: url: https://github.com/docker/compose/releases/download/{{ docker_compose_version }}/docker-compose-Linux-x86_64 - dest: /usr/local/bin/docker-compose + dest: "{{ docker_compose_path }}" mode: 0755