Skip to content

Commit

Permalink
Fix/issue 13 (#14)
Browse files Browse the repository at this point in the history
* Fix pip installation

* Add dependencies

* Add docker_pip_package for using python2 in test

* Add step for role dependencies download

* Force apt cache update

Workaround for solving geerlingguy/ansible-role-pip#37

* Fix error in tests

Co-authored-by: Miguel Caballer <[email protected]>
  • Loading branch information
maricaantonacci and micafer authored Feb 5, 2021
1 parent ab5f5d0 commit 33061d0
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 33 deletions.
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ install:

# Create ansible.cfg with correct roles_path
- printf '[defaults]\nroles_path=../' >ansible.cfg

# Download role dependencies
- ansible-galaxy install geerlingguy.pip

# Workaround for https://github.com/geerlingguy/ansible-role-pip/issues/37
- sudo apt update

script:
# Basic role syntax check
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ Role Variables
- `docker_storage_driver` (optional): Storage driver to use
- `docker_log_driver` (optional): Log driver to use. Default: 'json-file'
- `docker_logs_opts` (optional): Log driver options. Default: { 'max-file': '3', 'max-size': '100m' }
- `docker_pip_package` (optional): The name of the packge to install to get pip on the system. For older systems that don't have Python 3 available, you can set this to `python-pip`. Default: `python3-pip`

Dependencies
--------------
- geerlingguy.pip

Example Playbook
----------------
Expand Down
1 change: 1 addition & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
# defaults file for ansible-role-docker
docker_pip_package: python3-pip
docker_config: {}
docker_options:
bip: "{{ docker_bridge_ip_cidr |default(None) }}"
Expand Down
8 changes: 7 additions & 1 deletion meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,10 @@ galaxy_info:
galaxy_tags:
- docker

dependencies: []
dependencies:
- role: geerlingguy.pip
vars:
pip_package: "{{ docker_pip_package }}"
pip_install_packages:
- "{{ 'docker' if ansible_version.minor >= 6 else 'docker-py' }}"

31 changes: 0 additions & 31 deletions tasks/common.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,6 @@
---
# Common setup tasks for all supported OS families

- name: "[Common] Install base dependencies"
package:
name={{ item }}
state=present
with_items:
- "{{ python_dev_package }}"
- "{{ python_setuptools_package }}"

- name: "[Common] Install pip"
easy_install:
name=pip
state=present

- name: "[Common] Set docker-py package to be installed"
set_fact:
docker_py_package: "docker-py"

# https://github.com/ansible/ansible/issues/42162
# https://github.com/dcos-labs/ansible-dcos/pull/20
- name: "[Common] Set docker-py package to be installed"
set_fact:
docker_py_package: "docker"
when: ansible_version.minor >= 6

# Required by the Ansible Docker module
- name: "[Common] Install docker-py dependency"
pip:
name="{{docker_py_package}}"
state=latest


- name: "[Common] Install Docker CE package"
package:
name=docker-ce
Expand Down
4 changes: 3 additions & 1 deletion tests/test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---
- hosts: localhost
remote_user: root
vars:
docker_pip_package: python-pip
roles:
- ansible-role-docker
- ansible-role-docker

0 comments on commit 33061d0

Please sign in to comment.