Skip to content
This repository was archived by the owner on Jun 8, 2022. It is now read-only.

Commit f4c7bc3

Browse files
committed
Install multiple python version
1 parent a3cd803 commit f4c7bc3

File tree

8 files changed

+26
-13
lines changed

8 files changed

+26
-13
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ script:
2222
&& (echo 'Idempotence test: pass' && exit 0)
2323
|| (echo 'Idempotence test: fail' && exit 1)
2424
- stat /usr/local/pythonz/pythons/CPython-3.6.2/bin/python
25+
- stat /usr/local/pythonz/pythons/CPython-3.6.3/bin/python

README.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ pyslackers.python
33

44
[![Build Status](https://travis-ci.org/pyslackers/ansible-role-python.svg?branch=master)](https://travis-ci.org/pyslackers/ansible-role-python)
55

6-
Python role for ansible. This supports multiple python versions thanks to pythonz.
6+
Python3 role for ansible. This supports multiple python versions thanks to pythonz.
77

88
Requirements
99
------------
@@ -13,7 +13,7 @@ None
1313
Role Variables
1414
--------------
1515

16-
* `version`: The python version, this must be a valid value in the python ftp site.
16+
* `python_versions`: List of valid python 3 versions to install.
1717

1818
Dependencies
1919
------------
@@ -25,7 +25,9 @@ Example Playbook
2525

2626
```yml
2727
- role: pyslackers.python
28-
version: "3.6.2"
28+
python_versions:
29+
- "3.6.2"
30+
- "3.6.3"
2931
```
3032
3133
License

defaults/main.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
---
2-
version: "3.6.2"
2+
python_versions:
3+
- "3.6.3"

tasks/main.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
---
22
- import_tasks: pythonz.yml
3-
- import_tasks: python.yml
3+
- include_tasks: python.yml
4+
with_items: "{{ python_versions }}"
5+
loop_control:
6+
loop_var: python_version

tasks/python.yml

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
---
2-
- name: "Install python {{ version }}"
3-
command: "/usr/local/pythonz/bin/pythonz install {{ version }}"
2+
- name: "Install python {{ python_version }}"
3+
command: "/usr/local/pythonz/bin/pythonz install {{ python_version }}"
44
args:
5-
creates: "/usr/local/pythonz/pythons/CPython-{{ version }}/bin/python"
5+
creates: "/usr/local/pythonz/pythons/CPython-{{ python_version }}/bin/python"
66

7-
- name: "Install virtualenv for python {{ version }}"
7+
- name: "Update pip & setuptools for python {{ python_version }}"
88
pip:
9-
executable: "/usr/local/pythonz/pythons/CPython-{{ version }}/bin/pip3"
10-
name: virtualenv
9+
executable: "/usr/local/pythonz/pythons/CPython-{{ python_version }}/bin/pip3"
10+
name: "{{ item }}"
1111
state: latest
12+
with_items:
13+
- pip
14+
- setuptools

tasks/pythonz.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
force: no
2525
repo: https://github.com/saghul/pythonz.git
2626
dest: /usr/src/pythonz
27-
version: c3fcfa8876eda7fcafe55ae244d6884a4d540aeb
27+
version: master
2828
register: new_pythonz_release
2929

3030
- name: Install pythonz

tests/inventory

-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
localhost
2-

tests/test.yml

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
---
22
- hosts: localhost
3+
vars:
4+
python_versions:
5+
- "3.6.3"
6+
- "3.6.2"
37
roles:
48
- ansible-role-python

0 commit comments

Comments
 (0)