From 0a7b295d72fe16a9079c519665e3dde5cc1440bd Mon Sep 17 00:00:00 2001 From: khaledk2 Date: Mon, 26 Oct 2026 13:11:07 +0000 Subject: [PATCH 01/10] fix version test --- molecule/resources/tests/test_default.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/molecule/resources/tests/test_default.py b/molecule/resources/tests/test_default.py index 7b0cefe..eb2960c 100644 --- a/molecule/resources/tests/test_default.py +++ b/molecule/resources/tests/test_default.py @@ -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('Python 3.12') assert host.file(venv + '/bin/python').is_file assert host.file(venv + '/bin/python3').is_file assert host.file(venv + '/bin/pip').is_file From 5c9f15026126642a0137534e6f55315325e7b9a7 Mon Sep 17 00:00:00 2001 From: khaledk2 Date: Mon, 26 Oct 2026 13:28:01 +0000 Subject: [PATCH 02/10] test pip version --- molecule/resources/tests/test_default.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/molecule/resources/tests/test_default.py b/molecule/resources/tests/test_default.py index eb2960c..cf0f2ef 100644 --- a/molecule/resources/tests/test_default.py +++ b/molecule/resources/tests/test_default.py @@ -8,7 +8,7 @@ def test_virtualenv(host): venv = '/opt/test/python3-virtualenv' assert host.check_output(venv + '/bin/python --version').startswith('Python 3.12') - assert host.check_output(venv + '/bin/pip --version').startswith('Python 3.12') + assert host.check_output(venv + '/bin/pip --version').startswith('pip 26') assert host.file(venv + '/bin/python').is_file assert host.file(venv + '/bin/python3').is_file assert host.file(venv + '/bin/pip').is_file From c5b606d2e42e279d70a007992d72c8c17b4e629f Mon Sep 17 00:00:00 2001 From: khaledk2 Date: Mon, 26 Oct 2026 13:53:51 +0000 Subject: [PATCH 03/10] fix check pip version --- molecule/resources/tests/test_default.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/molecule/resources/tests/test_default.py b/molecule/resources/tests/test_default.py index cf0f2ef..bd93771 100644 --- a/molecule/resources/tests/test_default.py +++ b/molecule/resources/tests/test_default.py @@ -8,7 +8,7 @@ def test_virtualenv(host): venv = '/opt/test/python3-virtualenv' assert host.check_output(venv + '/bin/python --version').startswith('Python 3.12') - assert host.check_output(venv + '/bin/pip --version').startswith('pip 26') + assert host.check_output(venv + '/bin/pip --version').startswith('pip 23') assert host.file(venv + '/bin/python').is_file assert host.file(venv + '/bin/python3').is_file assert host.file(venv + '/bin/pip').is_file From 455276adba17b6534c2476cf235e15ece8b0fea9 Mon Sep 17 00:00:00 2001 From: khaledk2 Date: Mon, 26 Oct 2026 14:00:28 +0000 Subject: [PATCH 04/10] fix check pip version --- molecule/resources/tests/test_default.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/molecule/resources/tests/test_default.py b/molecule/resources/tests/test_default.py index bd93771..1059926 100644 --- a/molecule/resources/tests/test_default.py +++ b/molecule/resources/tests/test_default.py @@ -8,7 +8,7 @@ def test_virtualenv(host): venv = '/opt/test/python3-virtualenv' assert host.check_output(venv + '/bin/python --version').startswith('Python 3.12') - assert host.check_output(venv + '/bin/pip --version').startswith('pip 23') + 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 From bed977407f44eabb7d998bc2d0c2bec23efff444 Mon Sep 17 00:00:00 2001 From: khaledk2 Date: Mon, 26 Oct 2026 23:56:02 +0000 Subject: [PATCH 05/10] patch for pip issue --- tasks/python-venv_installation.yml | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/tasks/python-venv_installation.yml b/tasks/python-venv_installation.yml index 43ac41b..eb6afdc 100644 --- a/tasks/python-venv_installation.yml +++ b/tasks/python-venv_installation.yml @@ -1,4 +1,3 @@ ---- - name: python venv | check if the {{ env_name }} dir exists stat: @@ -71,3 +70,27 @@ src: "{{ virtualenv_basedir }}/venv-{{ python_version }}" dest: "{{ virtualenv_basedir }}/{{ env_name }}" state: link + +## check of 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: + version_p: "{{ installed_pythonversion.stdout.split('.')[-1] | int }}" + +# patch for the pip issue + +- name: update the pip version if the it python version less than 3.11.18 or python 3.12.16 + 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 version_p < 16) or (python_version == '3.11' and version_p < 18)" + +- name: update the certifi version if python version less than 3.11.18 or 3.12.16 + 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 version_p < 16) or (python_version == '3.11' and version_p < 18)" + + + From b614754240614a79231d99bb9ab0706164e859e0 Mon Sep 17 00:00:00 2001 From: khaledk2 Date: Tue, 27 Oct 2026 00:01:32 +0000 Subject: [PATCH 06/10] remove empty lines --- tasks/python-venv_installation.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/tasks/python-venv_installation.yml b/tasks/python-venv_installation.yml index eb6afdc..13fbae7 100644 --- a/tasks/python-venv_installation.yml +++ b/tasks/python-venv_installation.yml @@ -91,6 +91,3 @@ 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 version_p < 16) or (python_version == '3.11' and version_p < 18)" - - - From 64cd4eff2878b410ca2e6805f232d0da75a4189a Mon Sep 17 00:00:00 2001 From: khaledk2 Date: Tue, 27 Oct 2026 08:37:41 +0000 Subject: [PATCH 07/10] clean up the code --- tasks/python-venv_installation.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks/python-venv_installation.yml b/tasks/python-venv_installation.yml index 13fbae7..0733cd2 100644 --- a/tasks/python-venv_installation.yml +++ b/tasks/python-venv_installation.yml @@ -71,7 +71,7 @@ dest: "{{ virtualenv_basedir }}/{{ env_name }}" state: link -## check of the installed python version +## check the installed python version - name: check the installed python version command: "{{ virtualenv_basedir }}/{{ env_name }}/bin/python{{ python_version }} --version" changed_when: false @@ -82,7 +82,7 @@ # patch for the pip issue -- name: update the pip version if the it python version less than 3.11.18 or python 3.12.16 +- name: update the pip version if python version less than 3.11.18 or python 3.12.16 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 version_p < 16) or (python_version == '3.11' and version_p < 18)" From 662a6de25b2882dd09334390697182abdb091f6e Mon Sep 17 00:00:00 2001 From: khaledk2 Date: Tue, 27 Oct 2026 20:30:35 +0000 Subject: [PATCH 08/10] update pip and certifi in case of using updated python version --- tasks/python-venv_installation.yml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tasks/python-venv_installation.yml b/tasks/python-venv_installation.yml index 0733cd2..45919a8 100644 --- a/tasks/python-venv_installation.yml +++ b/tasks/python-venv_installation.yml @@ -78,16 +78,22 @@ register: installed_pythonversion - ansible.builtin.set_fact: - version_p: "{{ installed_pythonversion.stdout.split('.')[-1] | int }}" + int_py_version: "{{ installed_pythonversion.stdout.split('.')[-1] | int }}" # patch for the pip issue -- name: update the pip version if python version less than 3.11.18 or python 3.12.16 +- name: update the pip version if the python version is less than 3.11.18 or python 3.12.16 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 version_p < 16) or (python_version == '3.11' and version_p < 18)" + when: "(python_version == '3.12' and int_py_version < 16) or (python_version == '3.11' and int_py_version < 18)" -- name: update the certifi version if python version less than 3.11.18 or 3.12.16 +- name: update the certifi version if the python version is less than 3.11.18 or 3.12.16 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 version_p < 16) or (python_version == '3.11' and version_p < 18)" + when: "(python_version == '3.12' and int_py_version < 16) or (python_version == '3.11' and int_py_version < 18)" + +- name: update pip and certifi if the python version is equal or grater than 3.11.18 or 3.12.16 + 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 >= 16) or (python_version == '3.11' and int_py_version >= 18)" + From d69f6b7de6b3604599f4b362b17fe430eb9b4442 Mon Sep 17 00:00:00 2001 From: khaledk2 Date: Wed, 28 Oct 2026 14:08:52 +0000 Subject: [PATCH 09/10] Fix permission --- tasks/python-venv_installation.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tasks/python-venv_installation.yml b/tasks/python-venv_installation.yml index 45919a8..d602a02 100644 --- a/tasks/python-venv_installation.yml +++ b/tasks/python-venv_installation.yml @@ -83,16 +83,19 @@ # 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 < 16) or (python_version == '3.11' and int_py_version < 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 < 16) or (python_version == '3.11' and int_py_version < 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 >= 16) or (python_version == '3.11' and int_py_version >= 18)" From d353445fba4938321868dfa8bb81d2218fe1afb5 Mon Sep 17 00:00:00 2001 From: khaledk2 Date: Wed, 28 Oct 2026 19:10:42 +0000 Subject: [PATCH 10/10] fix int compare --- tasks/python-venv_installation.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tasks/python-venv_installation.yml b/tasks/python-venv_installation.yml index d602a02..a5ccc2e 100644 --- a/tasks/python-venv_installation.yml +++ b/tasks/python-venv_installation.yml @@ -86,17 +86,17 @@ 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 < 16) or (python_version == '3.11' and int_py_version < 18)" + 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 < 16) or (python_version == '3.11' and int_py_version < 18)" + 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 >= 16) or (python_version == '3.11' and int_py_version >= 18)" + when: "(python_version == '3.12' and (int_py_version | int) >= 16) or (python_version == '3.11' and (int_py_version | int) >= 18)"