diff --git a/defaults/main/base.yml b/defaults/main/base.yml new file mode 100644 index 0000000..3788b64 --- /dev/null +++ b/defaults/main/base.yml @@ -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" diff --git a/defaults/main.yml b/defaults/main/python.yml similarity index 83% rename from defaults/main.yml rename to defaults/main/python.yml index a01f051..71f9059 100644 --- a/defaults/main.yml +++ b/defaults/main/python.yml @@ -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" @@ -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 }}" diff --git a/defaults/main/venv.yml b/defaults/main/venv.yml new file mode 100644 index 0000000..a7dd60f --- /dev/null +++ b/defaults/main/venv.yml @@ -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 }}" diff --git a/tasks/venv.yml b/tasks/venv.yml index 576d3ce..6d9c882 100644 --- a/tasks/venv.yml +++ b/tasks/venv.yml @@ -6,7 +6,6 @@ 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: @@ -14,14 +13,14 @@ 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 @@ -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 diff --git a/tasks/venv27.yml b/tasks/venv27.yml new file mode 100644 index 0000000..d13408b --- /dev/null +++ b/tasks/venv27.yml @@ -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 diff --git a/tasks/venvs.yml b/tasks/venvs.yml index c28511b..f3cc48b 100644 --- a/tasks/venvs.yml +++ b/tasks/venvs.yml @@ -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 }}"