Skip to content
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
4 changes: 2 additions & 2 deletions molecule/resources/tests/test_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

def test_virtualenv(host):
venv = '/opt/test/python3-virtualenv'
host.check_output(venv + '/bin/python --version').startswith('Python 3.12')
host.check_output(venv + '/bin/pip --version').startswith('Python 3.12')
assert host.check_output(venv + '/bin/python --version').startswith('Python 3.12')
assert host.check_output(venv + '/bin/pip --version').startswith('pip 2')
assert host.file(venv + '/bin/python').is_file
assert host.file(venv + '/bin/python3').is_file
assert host.file(venv + '/bin/pip').is_file
Expand Down
31 changes: 30 additions & 1 deletion tasks/python-venv_installation.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---

- name: python venv | check if the {{ env_name }} dir exists
stat:
Expand Down Expand Up @@ -71,3 +70,33 @@
src: "{{ virtualenv_basedir }}/venv-{{ python_version }}"
dest: "{{ virtualenv_basedir }}/{{ env_name }}"
state: link

## check the installed python version
- name: check the installed python version
command: "{{ virtualenv_basedir }}/{{ env_name }}/bin/python{{ python_version }} --version"
changed_when: false
register: installed_pythonversion

- ansible.builtin.set_fact:
int_py_version: "{{ installed_pythonversion.stdout.split('.')[-1] | int }}"

# patch for the pip issue

- name: update the pip version if the python version is less than 3.11.18 or python 3.12.16
become: true
command: "{{ virtualenv_basedir }}/{{ env_name }}/bin/python{{ python_version }} -m pip install 'pip @ https://files.pythonhosted.org/packages/3f/06/3e4420302363fbb71be3c7f35ce042f54bfca330e3e66b3a2e3c4cca579f/pip-26.2.2-py3-none-any.whl#sha256=fd7f4dfa8190e014013b9f08f3e973f4e4c26ffd179a204895533a7254813a70'"
changed_when: false
when: "(python_version == '3.12' and (int_py_version| int) < 16) or (python_version == '3.11' and (int_py_version| int) < 18)"

- name: update the certifi version if the python version is less than 3.11.18 or 3.12.16
become: true
command: "{{ virtualenv_basedir }}/{{ env_name }}/bin/python{{ python_version }} -m pip install --upgrade 'certifi>=2026.10.19'"
changed_when: false
when: "(python_version == '3.12' and (int_py_version | int) < 16) or (python_version == '3.11' and (int_py_version | int) < 18)"

- name: update pip and certifi if the python version is equal or grater than 3.11.18 or 3.12.16
become: true
command: "{{ virtualenv_basedir }}/{{ env_name }}/bin/python{{ python_version }} -m pip install --upgrade pip certifi"
changed_when: false
when: "(python_version == '3.12' and (int_py_version | int) >= 16) or (python_version == '3.11' and (int_py_version | int) >= 18)"

Loading