Skip to content

Commit

Permalink
Fixes #68
Browse files Browse the repository at this point in the history
  • Loading branch information
haxorof committed Dec 10, 2018
1 parent c3465ba commit 613c3ef
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased](../../releases/tag/X.Y.Z)

### Fixed

- docker_compose_no_pip only works in Ansible 2.7 or later ([#68](../../issues/68))

## [1.11.1](../../releases/tag/1.11.1) - 2018-12-03

### Fixed
Expand Down
64 changes: 56 additions & 8 deletions tasks/postinstall.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,66 @@
url: https://api.github.com/repos/docker/compose/releases/latest
body_format: json
register: _github_docker_compose
when:
- docker_compose_no_pip
until: _github_docker_compose.status == 200
retries: 10
when:
- docker_compose

- name: Set common facts related to docker-compose
set_fact:
_docker_compose_shasum_url: "https://github.com/docker/compose/releases/download/{{ _github_docker_compose.json.tag_name }}/\
docker-compose-{{ ansible_system }}-{{ ansible_architecture }}.sha256"
_docker_compose_url: "https://github.com/docker/compose/releases/download/{{ _github_docker_compose.json.tag_name }}/\
docker-compose-{{ ansible_system }}-{{ ansible_architecture }}"
when:
- docker_compose

- name: Fetch docker-compose SHA265 sum file
get_url:
url: "{{ _docker_compose_shasum_url }}"
dest: "/tmp/ansible.docker-compose-sha256"
register: _github_docker_compose_shasum_file
changed_when: false
until: _github_docker_compose_shasum_file.status_code == 200
retries: 10
when:
- docker_compose

- name: Dump SHA256 file contents to variable
command: cat /tmp/ansible.docker-compose-sha256
register: _github_docker_compose_shasum
changed_when: false
when:
- docker_compose

- name: Remove temporary file for SHA256 sum
file:
path: "/tmp/ansible.docker-compose-sha256"
state: absent
changed_when: false
when:
- docker_compose

- name: Set SHA256 facts related to docker-compose
set_fact:
_docker_compose_checksum: "sha256:{{ _github_docker_compose_shasum.stdout | regex_replace('^([0-9a-zA-Z]*)[\\s\\t]+.+', '\\1') }}"
when:
- docker_compose

# Use when moving to Ansible 2.7 as minimum version
# - name: Set SHA256 facts related to docker-compose (Ansible >= 2.7)
# set_fact:
# _docker_compose_checksum: "sha256:https://github.com/docker/compose/releases/download/{{ _github_docker_compose.json.tag_name }}/\
# docker-compose-{{ ansible_system }}-{{ ansible_architecture }}.sha256"
# when: ansible_version.full is version_compare('2.7', '>=')

# Official installation of docker-compose (Linux): https://docs.docker.com/compose/install/#install-compose
- name: Install docker-compose (Linux)
become: true
get_url:
url: "https://github.com/docker/compose/releases/download/{{ _github_docker_compose.json.tag_name }}/\
docker-compose-{{ ansible_system }}-{{ ansible_architecture }}"
checksum: "sha256:https://github.com/docker/compose/releases/download/{{ _github_docker_compose.json.tag_name }}/\
docker-compose-{{ ansible_system }}-{{ ansible_architecture }}.sha256"
url: "{{ _docker_compose_url }}"
checksum: "{{ _docker_compose_checksum }}"
dest: /usr/local/bin/docker-compose
mode: 0755
when:
- docker_compose_no_pip
when:
- docker_compose
2 changes: 1 addition & 1 deletion tests/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ if File.exist?(testcase_file)
ansible.verbose = false
ansible.install_mode = "pip"
ansible.compatibility_mode = "2.0"
ansible.version = "latest"
ansible.version = "2.5.6"
ansible.playbook = vagrant_config['prep_yml']
ansible.limit = "test-host"
ansible.inventory_path = "hosts"
Expand Down
5 changes: 5 additions & 0 deletions tests/prepare.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
---
- hosts: test-host
tasks:
- name: Print Ansible version
debug:
var: ansible_version.full

- name: Ensure git is installed
become: true
package:
name: git
state: present

- name: Ensure Docker Bench Security is cloned
git:
repo: 'https://github.com/docker/docker-bench-security.git'
Expand Down
4 changes: 4 additions & 0 deletions tests/prepare_snapshot.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
---
- hosts: test-host
tasks:
- name: Print Ansible version
debug:
var: ansible_version.full

- name: Add backport repository for Debian Wheezy
become: true
apt_repository:
Expand Down
4 changes: 4 additions & 0 deletions tests/prepare_storage.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
---
- hosts: test-host
tasks:
- name: Print Ansible version
debug:
var: ansible_version.full

- name: Ensure dependencies are installed (All)
package:
name: "{{ item }}"
Expand Down

0 comments on commit 613c3ef

Please sign in to comment.