Skip to content

Commit

Permalink
Handle docker-compose version
Browse files Browse the repository at this point in the history
docker-compose > 1.10 requires the docker python package which is
incompatible with the docker_container module in Ansible < 2.3.
  • Loading branch information
Jonathan Piron committed Jan 20, 2017
1 parent 6a5ca77 commit 2299a2f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,15 @@
- python-dev
- python-pip

# Display an informative message if the docker-compose version needs to be downgraded
- name: Docker-compose version downgrade
debug:
msg: >-
Downgrading docker-compose version to {{ _pip_version_docker_compose }} because of docker-compose > 1.10
requiring docker python package (instead of the docker-py one) which is incompatible with the docker_container
module in Ansible < 2.3
when: pip_install_docker_compose and _pip_version_docker_compose != pip_version_docker_compose

# Upgrade pip with pip to fix angstwad/docker.ubuntu/pull/35 and docker-py/issues/525
- name: Install pip, setuptools, docker-py and docker-compose with pip
pip:
Expand All @@ -166,7 +175,7 @@
- { name: pip, version: "{{ pip_version_pip }}", install: "{{ pip_install_pip }}" }
- { name: setuptools, version: "{{ pip_version_setuptools }}", install: "{{ pip_install_setuptools }}" }
- { name: docker-py, version: "{{ pip_version_docker_py }}", install: "{{ pip_install_docker_py }}" }
- { name: docker-compose, version: "{{ pip_version_docker_compose }}", install: "{{ pip_install_docker_compose }}" }
- { name: docker-compose, version: "{{ _pip_version_docker_compose }}", install: "{{ pip_install_docker_compose }}" }
when: item.install

- name: Check if /etc/updatedb.conf exists
Expand Down
8 changes: 8 additions & 0 deletions vars/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
# Downgrade docker-compose version if ansible version < 2.3 and docker-compose > 1.9.0
# Because of docker-compose 1.10+ requires docker python package (instead of the docker-py one)
# which is incompatible with the docker_container module in Ansible < 2.3
_pip_version_docker_compose: >-
{{ '1.9.0' if ansible_version.full | version_compare('2.3', '<')
and (pip_version_docker_compose=='latest' or pip_version_docker_compose | version_compare('1.9.0', '>'))
else pip_version_docker_compose }}

0 comments on commit 2299a2f

Please sign in to comment.