This repository was archived by the owner on Jun 8, 2022. It is now read-only.
File tree 5 files changed +38
-18
lines changed
5 files changed +38
-18
lines changed Original file line number Diff line number Diff line change @@ -34,3 +34,4 @@ script:
34
34
- docker exec --tty $container_id env TERM=xterm /opt/test_env/env_1/bin/pip freeze | grep -q 'requests==2.18.4' && exit 0 || exit 1
35
35
- docker exec --tty $container_id env TERM=xterm /opt/test_env/env_2/bin/python --version == 'Python 3.6.2'
36
36
- docker exec --tty $container_id env TERM=xterm /opt/test_env/env_2/bin/pip --version == '8.0.0'
37
+ - docker exec --tty $container_id env TERM=xterm /opt/test_env/env_3/bin/python --version == '2.7.14'
Original file line number Diff line number Diff line change @@ -3,17 +3,12 @@ pyslackers.python
3
3
4
4
[ ![ Build Status] ( https://travis-ci.org/pyslackers/ansible-role-python.svg?branch=master )] ( https://travis-ci.org/pyslackers/ansible-role-python )
5
5
6
- Python3 role for ansible. This supports multiple python versions thanks to pythonz.
7
-
8
- Requirements
9
- ------------
10
-
11
- None
6
+ Python role for ansible. This supports multiple python versions thanks to pythonz.
12
7
13
8
Role Variables
14
9
--------------
15
10
16
- * ` python_versions ` : List of valid python 3 versions to install.
11
+ * ` python_versions ` : List of valid python versions to install.
17
12
* ` virtualenvs ` : Dict of virtual environment to create.
18
13
* ` path ` : Virtual environment directory.
19
14
* ` version ` : Virtual environment python version.
@@ -25,11 +20,6 @@ Role Variables
25
20
* ` pip_version ` : Pythonz pythons interpreter pip version (default to ` latest ` ).
26
21
* ` setuptools_version ` : Pythonz pythons interpreter setuptools version (default to ` latest ` ).
27
22
28
- Dependencies
29
- ------------
30
-
31
- None
32
-
33
23
Example Playbook
34
24
----------------
35
25
@@ -53,8 +43,3 @@ License
53
43
-------
54
44
55
45
MIT
56
-
57
- Author Information
58
- ------------------
59
-
60
- None
Original file line number Diff line number Diff line change 14
14
with_items :
15
15
- {name: pip, state: "{{ 'present' if pip_version is defined else 'latest' }}", version: "{{ pip_version | default(omit) }}"}
16
16
- {name: setuptools, state: "{{ 'present' if setuptools_version is defined else 'latest' }}", version: "{{ setuptools_version | default(omit) }}"}
17
+ when : " python_version[0] == '3'"
18
+
19
+ - name : " Install pip"
20
+ command : " /usr/local/pythonz/pythons/CPython-{{ python_version }}/bin/python -m ensurepip"
21
+ args :
22
+ creates : " /usr/local/pythonz/pythons/CPython-{{ python_version }}/bin/pip"
23
+ when : " python_version[0] == '2'"
24
+
25
+
26
+ - name : " Update pip, setuptools & virtualenv for python {{ python_version }}"
27
+ pip :
28
+ executable : " /usr/local/pythonz/pythons/CPython-{{ python_version }}/bin/pip"
29
+ name : " {{ item.name }}"
30
+ version : " {{ item.version }}"
31
+ state : " {{ item.state }}"
32
+ with_items :
33
+ - {name: pip, state: "{{ 'present' if pip_version is defined else 'latest' }}", version: "{{ pip_version | default(omit) }}"}
34
+ - {name: setuptools, state: "{{ 'present' if setuptools_version is defined else 'latest' }}", version: "{{ setuptools_version | default(omit) }}"}
35
+ - {name: virtualenv, state: "{{ 'present' if virtualenv_version is defined else 'latest' }}", version: "{{ virtualenv_version | default(omit) }}"}
36
+ when : " python_version[0] == '2'"
Original file line number Diff line number Diff line change 24
24
force : yes
25
25
when :
26
26
- not current_python_version|skipped
27
- - virtualenv.value.version not in current_python_version.stdout
27
+ - virtualenv.value.version not in current_python_version.stdout and virtualenv.value.version not in current_python_version.stderr
28
28
29
29
- name : " Create environment {{ virtualenv.key }}"
30
30
pip :
33
33
state : " {{ 'present' if virtualenv.value.pip_version is defined else 'latest' }}"
34
34
name : pip
35
35
version : " {{ virtualenv.value.pip_version | default(omit) }}"
36
+ when : " virtualenv.value.version[0] == '3'"
37
+
38
+ - name : " Create environment {{ virtualenv.key }}"
39
+ pip :
40
+ virtualenv : " {{ virtualenv.value.path }}"
41
+ virtualenv_command : " /usr/local/pythonz/pythons/CPython-{{ virtualenv.value.version }}/bin/virtualenv"
42
+ virtualenv_python : " /usr/local/pythonz/pythons/CPython-{{ virtualenv.value.version }}/bin/python"
43
+ state : " {{ 'present' if virtualenv.value.pip_version is defined else 'latest' }}"
44
+ name : pip
45
+ version : " {{ virtualenv.value.pip_version | default(omit) }}"
46
+ when : " virtualenv.value.version[0] == '2'"
36
47
37
48
- name : Update setuptools
38
49
pip :
Original file line number Diff line number Diff line change 13
13
path : /opt/test_env/env_2
14
14
version : " 3.6.2"
15
15
pip_version : " 8.0.0"
16
+ env_3 :
17
+ path : /opt/test_env/env_3
18
+ version : 2.7.14
16
19
roles :
17
20
- ansible-role-python
You can’t perform that action at this time.
0 commit comments