Skip to content

Commit b08a2b9

Browse files
author
Gustavo Muniz do Carmo
committed
pip version according python version
1 parent 9effd0b commit b08a2b9

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
**/*/__pycache__
22
.vscode
3+
env

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Ansible role to install [Ansible](https://www.ansible.com).
1313
- codeyourinfra.ansible
1414
```
1515
16+
The role requires the *ansible_python_version* variable, obtained through the [gathering facts phase](https://docs.ansible.com/ansible/latest/user_guide/playbooks_variables.html#information-discovered-from-systems-facts). So please don't turn off facts.
17+
1618
## Build process
1719
1820
The build process is performed in [Travis CI](https://travis-ci.org/codeyourinfra/ansible). During the build, the role is tested by using [Molecule](https://molecule.readthedocs.io).

tasks/main.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,21 @@
55
loop:
66
- libssl-dev
77
- libffi-dev
8-
- python-pip
9-
- python3-pip
8+
9+
- name: Python version
10+
debug:
11+
var: ansible_python_version
12+
13+
- name: Install pip3/uninstall pip, if python3.
14+
apt:
15+
name: python3-pip
16+
state: "{{ 'present' if ansible_python_version is version('3', '>=') else 'absent' }}"
17+
18+
- name: Install pip/unsintall pip3, if python.
19+
apt:
20+
name: python-pip
21+
state: "{{ 'present' if ansible_python_version is version('3', '<') else 'absent' }}"
22+
1023
- name: Install Ansible
1124
pip:
1225
name: ansible

tests/test.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22
- hosts: containers
3-
gather_facts: no
43
roles:
54
- ansible
65
tasks:

0 commit comments

Comments
 (0)