Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overhaul venvs #25

Merged
merged 4 commits into from
May 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions defaults/main/base.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
##
# role main options
##

python_24: false
python_26: false
python_27: false
python_31: false
python_32: false
python_33: false
python_34: false
python_35: false
python_36: false
python_37: false
python_38: false
python_39: false
python_310: false
python_311: false
python_312: true
python_313: false

pillow: false
lxml: false

# fine grained settings
base_install_folder: "/srv"
56 changes: 3 additions & 53 deletions defaults/main.yml → defaults/main/python.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,9 @@
---
##
# role main options
# Pythons configuration
##

python_24: false
python_26: false
python_27: false
python_31: false
python_32: false
python_33: false
python_34: false
python_35: false
python_36: false
python_37: false
python_38: false
python_39: false
python_310: false
python_311: false
python_312: true
python_313: false

pillow: false
lxml: false
ftp_url: "https://www.python.org/ftp/python"

versions:
py24: "2.4.6"
Expand Down Expand Up @@ -59,41 +41,9 @@ hashes:
py312: "8defb33f0c37aa4bdd3a38ba52abde4e"
py313: "e1208b22c67c77de72a5e20025b2fb53"

venv_versions:
py24: "1.7.2"
py26: "1.10"
py27: "16.6.1"

##
# fine grained settings
# Specific python version details, based on the variables above
##
base_install_folder: "/srv"
ftp_url: "https://www.python.org/ftp/python"
pkg_url: "https://files.pythonhosted.org/packages"

venv24:
version: "{{ venv_versions.py24 }}"
file_hash: "7b88d35d0a353ec70e42aa37fd8b0bd1c643419c80f022ffaafa4d6449f0"
url: "{{ pkg_url }}/16/86/{{ file_hash }}/virtualenv-1.7.2.tar.gz"
md5: "b5d63b05373a4344ae099a68875aae78"
tar_file: "/tmp/virtualenv-{{ venv_versions.py24 }}.tar.gz"
sources: "/tmp/virtualenv-{{ venv_versions.py24 }}"

venv26:
version: "{{ venv_versions.py26 }}"
file_hash: "f425e456e017af4801bb08920e30c149a44ac0c194f2225bdb712e77701c"
url: "{{ pkg_url }}/d5/5b/{{ file_hash }}/virtualenv-1.10.tar.gz"
md5: "9745c28256c70c76d36adb3767a00212"
tar_file: "/tmp/virtualenv-{{ venv_versions.py26 }}.tar.gz"
sources: "/tmp/virtualenv-{{ venv_versions.py26 }}"

venv27:
version: "{{ venv_versions.py27 }}"
file_hash: "706af3ee62032933a3217454609c50a5325a6bd9c2c2f495b58c456ba286"
url: "{{ pkg_url }}/37/27/{{ file_hash }}/virtualenv-16.6.1.tar.gz"
md5: "b05b03dc6ecb3caaa3d58bfcccf4e786"
tar_file: "/tmp/virtualenv-{{ venv_versions.py27 }}.tar.gz"
sources: "/tmp/virtualenv-{{ venv_versions.py27 }}"

py24:
version: "{{ versions.py24 }}"
Expand Down
49 changes: 49 additions & 0 deletions defaults/main/venv.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
##
# Virtual environment related configuration
#
# !! Note that Python 2.7 is installed slightly different
##

pkg_url: "https://files.pythonhosted.org/packages"

venv_versions:
py24: "1.7.2"
py26: "1.10"
py27: "20.15.1"

venv_url_hashes:
py24: "7b88d35d0a353ec70e42aa37fd8b0bd1c643419c80f022ffaafa4d6449f0"
py26: "f425e456e017af4801bb08920e30c149a44ac0c194f2225bdb712e77701c"
py27: "df7c7b1b7a5ac4e41fac24c3682c1cc32f2c1d683d308bba2500338d1e3e"

venv_file_hashes:
py24: "b5d63b05373a4344ae099a68875aae78"
py26: "9745c28256c70c76d36adb3767a00212"
py27: "e9a76a95dc28cf9b55cfc87bd4eef20c"

venv27_wheel_name: "virtualenv-{{ venv_versions.py27 }}-py2.py3-none-any.whl"

##
# main venvs configuration, based on the variables above
##

venv24:
version: "{{ venv_versions.py24 }}"
url: "{{ pkg_url }}/16/86/{{ venv_url_hashes.py24 }}/virtualenv-1.7.2.tar.gz"
md5: "{{ venv_file_hashes.py24 }}"
tar_file: "/tmp/virtualenv-{{ venv_versions.py24 }}.tar.gz"
sources: "/tmp/virtualenv-{{ venv_versions.py24 }}"

venv26:
version: "{{ venv_versions.py26 }}"
url: "{{ pkg_url }}/d5/5b/{{ venv_url_hashes.py26 }}/virtualenv-1.10.tar.gz"
md5: "{{ venv_file_hashes.py26 }}"
tar_file: "/tmp/virtualenv-{{ venv_versions.py26 }}.tar.gz"
sources: "/tmp/virtualenv-{{ venv_versions.py26 }}"

venv27:
version: "{{ venv_versions.py27 }}"
url: "{{ pkg_url }}/6f/43/{{ venv_url_hashes.py27 }}/{{ venv27_wheel_name }}"
md5: "{{ venv_file_hashes.py27 }}"
wheel_file: "/tmp/{{ venv27_wheel_name }}"
7 changes: 3 additions & 4 deletions tasks/venv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,21 @@
path: "{{ py_data.install }}/bin/virtualenv"
register: already_installed
ignore_errors: true
when: should_install

- name: "Virtualenv | Download | {{ py_data.version }}"
ansible.builtin.get_url:
url: "{{ venv_data.url }}"
dest: "{{ venv_data.tar_file }}"
checksum: "md5:{{ venv_data.md5 }}"
mode: "0440"
when: should_install and not already_installed.stat.exists
when: not already_installed.stat.exists

- name: "Virtualenv | Uncompress | {{ py_data.version }}"
ansible.builtin.unarchive:
src: "{{ venv_data.tar_file }}"
dest: /tmp
copy: false
when: should_install and not already_installed.stat.exists
when: not already_installed.stat.exists

- name: " Virtualenv | Install | {{ py_data.version }}"
become: true
Expand All @@ -31,4 +30,4 @@
creates: "{{ py_data.install }}/bin/virtualenv"
with_items:
- "{{ py_data.bin }} setup.py install"
when: should_install and not already_installed.stat.exists
when: not already_installed.stat.exists
41 changes: 41 additions & 0 deletions tasks/venv27.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---

- name: "Virtualenv | Check if it is already installed | {{ py_data.version }}"
become: true
ansible.builtin.stat:
path: "{{ py_data.install }}/bin/virtualenv"
register: already_installed
ignore_errors: true

- name: "Virtualenv | Download | {{ py_data.version }}"
ansible.builtin.get_url:
url: "{{ venv_data.url }}"
dest: "{{ venv_data.wheel_file }}"
checksum: "md5:{{ venv_data.md5 }}"
mode: "0440"
when: not already_installed.stat.exists

- name: "Virtualenv | Download | pip"
ansible.builtin.get_url:
url: "https://bootstrap.pypa.io/pip/2.7/get-pip.py"
dest: "/tmp/get-pip.py"
checksum: "md5:60e8267eb1b7bc71dc4843eb7bd294d3"
mode: "0440"
when: not already_installed.stat.exists

- name: "Virtualenv | Install | pip"
ansible.builtin.command: "{{ item }}"
args:
creates: "{{ py_data.install }}/bin/pip"
with_items:
- "{{ py_data.install }}/bin/python /tmp/get-pip.py"
when: not already_installed.stat.exists

- name: " Virtualenv | Install | {{ py_data.version }}"
become: true
ansible.builtin.command: "{{ item }}"
args:
creates: "{{ py_data.install }}/bin/virtualenv"
with_items:
- "{{ py_data.install }}/bin/pip install {{ venv_data.wheel_file }}"
when: not already_installed.stat.exists
2 changes: 1 addition & 1 deletion tasks/venvs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

- name: Install Virtualenv for Python 2.7
ansible.builtin.include_tasks:
file: venv.yml
file: venv27.yml
vars:
py_data: "{{ py27 }}"
venv_data: "{{ venv27 }}"
Expand Down