Skip to content

Commit fb8d141

Browse files
authored
Merge pull request #25 from gforcada/overhaul-venvs
Overhaul venvs
2 parents 3f3985a + a322440 commit fb8d141

File tree

6 files changed

+124
-58
lines changed

6 files changed

+124
-58
lines changed

defaults/main/base.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
##
3+
# role main options
4+
##
5+
6+
python_24: false
7+
python_26: false
8+
python_27: false
9+
python_31: false
10+
python_32: false
11+
python_33: false
12+
python_34: false
13+
python_35: false
14+
python_36: false
15+
python_37: false
16+
python_38: false
17+
python_39: false
18+
python_310: false
19+
python_311: false
20+
python_312: true
21+
python_313: false
22+
23+
pillow: false
24+
lxml: false
25+
26+
# fine grained settings
27+
base_install_folder: "/srv"

defaults/main.yml renamed to defaults/main/python.yml

Lines changed: 3 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,9 @@
11
---
22
##
3-
# role main options
3+
# Pythons configuration
44
##
55

6-
python_24: false
7-
python_26: false
8-
python_27: false
9-
python_31: false
10-
python_32: false
11-
python_33: false
12-
python_34: false
13-
python_35: false
14-
python_36: false
15-
python_37: false
16-
python_38: false
17-
python_39: false
18-
python_310: false
19-
python_311: false
20-
python_312: true
21-
python_313: false
22-
23-
pillow: false
24-
lxml: false
6+
ftp_url: "https://www.python.org/ftp/python"
257

268
versions:
279
py24: "2.4.6"
@@ -59,41 +41,9 @@ hashes:
5941
py312: "8defb33f0c37aa4bdd3a38ba52abde4e"
6042
py313: "e1208b22c67c77de72a5e20025b2fb53"
6143

62-
venv_versions:
63-
py24: "1.7.2"
64-
py26: "1.10"
65-
py27: "16.6.1"
66-
6744
##
68-
# fine grained settings
45+
# Specific python version details, based on the variables above
6946
##
70-
base_install_folder: "/srv"
71-
ftp_url: "https://www.python.org/ftp/python"
72-
pkg_url: "https://files.pythonhosted.org/packages"
73-
74-
venv24:
75-
version: "{{ venv_versions.py24 }}"
76-
file_hash: "7b88d35d0a353ec70e42aa37fd8b0bd1c643419c80f022ffaafa4d6449f0"
77-
url: "{{ pkg_url }}/16/86/{{ file_hash }}/virtualenv-1.7.2.tar.gz"
78-
md5: "b5d63b05373a4344ae099a68875aae78"
79-
tar_file: "/tmp/virtualenv-{{ venv_versions.py24 }}.tar.gz"
80-
sources: "/tmp/virtualenv-{{ venv_versions.py24 }}"
81-
82-
venv26:
83-
version: "{{ venv_versions.py26 }}"
84-
file_hash: "f425e456e017af4801bb08920e30c149a44ac0c194f2225bdb712e77701c"
85-
url: "{{ pkg_url }}/d5/5b/{{ file_hash }}/virtualenv-1.10.tar.gz"
86-
md5: "9745c28256c70c76d36adb3767a00212"
87-
tar_file: "/tmp/virtualenv-{{ venv_versions.py26 }}.tar.gz"
88-
sources: "/tmp/virtualenv-{{ venv_versions.py26 }}"
89-
90-
venv27:
91-
version: "{{ venv_versions.py27 }}"
92-
file_hash: "706af3ee62032933a3217454609c50a5325a6bd9c2c2f495b58c456ba286"
93-
url: "{{ pkg_url }}/37/27/{{ file_hash }}/virtualenv-16.6.1.tar.gz"
94-
md5: "b05b03dc6ecb3caaa3d58bfcccf4e786"
95-
tar_file: "/tmp/virtualenv-{{ venv_versions.py27 }}.tar.gz"
96-
sources: "/tmp/virtualenv-{{ venv_versions.py27 }}"
9747

9848
py24:
9949
version: "{{ versions.py24 }}"

defaults/main/venv.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
##
3+
# Virtual environment related configuration
4+
#
5+
# !! Note that Python 2.7 is installed slightly different
6+
##
7+
8+
pkg_url: "https://files.pythonhosted.org/packages"
9+
10+
venv_versions:
11+
py24: "1.7.2"
12+
py26: "1.10"
13+
py27: "20.15.1"
14+
15+
venv_url_hashes:
16+
py24: "7b88d35d0a353ec70e42aa37fd8b0bd1c643419c80f022ffaafa4d6449f0"
17+
py26: "f425e456e017af4801bb08920e30c149a44ac0c194f2225bdb712e77701c"
18+
py27: "df7c7b1b7a5ac4e41fac24c3682c1cc32f2c1d683d308bba2500338d1e3e"
19+
20+
venv_file_hashes:
21+
py24: "b5d63b05373a4344ae099a68875aae78"
22+
py26: "9745c28256c70c76d36adb3767a00212"
23+
py27: "e9a76a95dc28cf9b55cfc87bd4eef20c"
24+
25+
venv27_wheel_name: "virtualenv-{{ venv_versions.py27 }}-py2.py3-none-any.whl"
26+
27+
##
28+
# main venvs configuration, based on the variables above
29+
##
30+
31+
venv24:
32+
version: "{{ venv_versions.py24 }}"
33+
url: "{{ pkg_url }}/16/86/{{ venv_url_hashes.py24 }}/virtualenv-1.7.2.tar.gz"
34+
md5: "{{ venv_file_hashes.py24 }}"
35+
tar_file: "/tmp/virtualenv-{{ venv_versions.py24 }}.tar.gz"
36+
sources: "/tmp/virtualenv-{{ venv_versions.py24 }}"
37+
38+
venv26:
39+
version: "{{ venv_versions.py26 }}"
40+
url: "{{ pkg_url }}/d5/5b/{{ venv_url_hashes.py26 }}/virtualenv-1.10.tar.gz"
41+
md5: "{{ venv_file_hashes.py26 }}"
42+
tar_file: "/tmp/virtualenv-{{ venv_versions.py26 }}.tar.gz"
43+
sources: "/tmp/virtualenv-{{ venv_versions.py26 }}"
44+
45+
venv27:
46+
version: "{{ venv_versions.py27 }}"
47+
url: "{{ pkg_url }}/6f/43/{{ venv_url_hashes.py27 }}/{{ venv27_wheel_name }}"
48+
md5: "{{ venv_file_hashes.py27 }}"
49+
wheel_file: "/tmp/{{ venv27_wheel_name }}"

tasks/venv.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,21 @@
66
path: "{{ py_data.install }}/bin/virtualenv"
77
register: already_installed
88
ignore_errors: true
9-
when: should_install
109

1110
- name: "Virtualenv | Download | {{ py_data.version }}"
1211
ansible.builtin.get_url:
1312
url: "{{ venv_data.url }}"
1413
dest: "{{ venv_data.tar_file }}"
1514
checksum: "md5:{{ venv_data.md5 }}"
1615
mode: "0440"
17-
when: should_install and not already_installed.stat.exists
16+
when: not already_installed.stat.exists
1817

1918
- name: "Virtualenv | Uncompress | {{ py_data.version }}"
2019
ansible.builtin.unarchive:
2120
src: "{{ venv_data.tar_file }}"
2221
dest: /tmp
2322
copy: false
24-
when: should_install and not already_installed.stat.exists
23+
when: not already_installed.stat.exists
2524

2625
- name: " Virtualenv | Install | {{ py_data.version }}"
2726
become: true
@@ -31,4 +30,4 @@
3130
creates: "{{ py_data.install }}/bin/virtualenv"
3231
with_items:
3332
- "{{ py_data.bin }} setup.py install"
34-
when: should_install and not already_installed.stat.exists
33+
when: not already_installed.stat.exists

tasks/venv27.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
3+
- name: "Virtualenv | Check if it is already installed | {{ py_data.version }}"
4+
become: true
5+
ansible.builtin.stat:
6+
path: "{{ py_data.install }}/bin/virtualenv"
7+
register: already_installed
8+
ignore_errors: true
9+
10+
- name: "Virtualenv | Download | {{ py_data.version }}"
11+
ansible.builtin.get_url:
12+
url: "{{ venv_data.url }}"
13+
dest: "{{ venv_data.wheel_file }}"
14+
checksum: "md5:{{ venv_data.md5 }}"
15+
mode: "0440"
16+
when: not already_installed.stat.exists
17+
18+
- name: "Virtualenv | Download | pip"
19+
ansible.builtin.get_url:
20+
url: "https://bootstrap.pypa.io/pip/2.7/get-pip.py"
21+
dest: "/tmp/get-pip.py"
22+
checksum: "md5:60e8267eb1b7bc71dc4843eb7bd294d3"
23+
mode: "0440"
24+
when: not already_installed.stat.exists
25+
26+
- name: "Virtualenv | Install | pip"
27+
ansible.builtin.command: "{{ item }}"
28+
args:
29+
creates: "{{ py_data.install }}/bin/pip"
30+
with_items:
31+
- "{{ py_data.install }}/bin/python /tmp/get-pip.py"
32+
when: not already_installed.stat.exists
33+
34+
- name: " Virtualenv | Install | {{ py_data.version }}"
35+
become: true
36+
ansible.builtin.command: "{{ item }}"
37+
args:
38+
creates: "{{ py_data.install }}/bin/virtualenv"
39+
with_items:
40+
- "{{ py_data.install }}/bin/pip install {{ venv_data.wheel_file }}"
41+
when: not already_installed.stat.exists

tasks/venvs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
- name: Install Virtualenv for Python 2.7
2020
ansible.builtin.include_tasks:
21-
file: venv.yml
21+
file: venv27.yml
2222
vars:
2323
py_data: "{{ py27 }}"
2424
venv_data: "{{ venv27 }}"

0 commit comments

Comments
 (0)