From 85b1b4070a6521b48265d4ef2d2d6d1cb9d061d1 Mon Sep 17 00:00:00 2001 From: Alex Willmer Date: Sun, 11 Aug 2024 02:12:16 +0100 Subject: [PATCH] tests: Respect configured or detected Python more often Relying on the virtualenv default or hardcoding "python" results in a Python 2.x virtualenv on some targets (e.g. debian10-test). This caused a failure when testing with Ansible >= 10 (ansible-core >= 2.17), which have dropped Python 2.x support. refs #1074 --- .../integration/interpreter_discovery/complex_args.yml | 3 +-- tests/ansible/integration/stub_connections/kubectl.yml | 1 - tests/ansible/integration/stub_connections/lxc.yml | 1 - tests/ansible/integration/stub_connections/lxd.yml | 1 - tests/ansible/integration/stub_connections/mitogen_doas.yml | 1 - tests/ansible/integration/stub_connections/mitogen_sudo.yml | 1 - .../ansible/regression/issue_152__virtualenv_python_fails.yml | 4 +++- 7 files changed, 4 insertions(+), 8 deletions(-) diff --git a/tests/ansible/integration/interpreter_discovery/complex_args.yml b/tests/ansible/integration/interpreter_discovery/complex_args.yml index a3755ebf..ea7e2d63 100644 --- a/tests/ansible/integration/interpreter_discovery/complex_args.yml +++ b/tests/ansible/integration/interpreter_discovery/complex_args.yml @@ -25,8 +25,7 @@ # special_python: source /tmp/fake && python - name: set python using sourced file set_fact: - # Avoid 2.x vs 3.x cross-compatiblity issues (that I can't remember the exact details of). - special_python: "source /tmp/fake || true && python{{ ansible_facts.python.version.major }}" + special_python: "source /tmp/fake || true && {{ ansible_facts.python.executable }}" - name: run get_url with specially-sourced python uri: diff --git a/tests/ansible/integration/stub_connections/kubectl.yml b/tests/ansible/integration/stub_connections/kubectl.yml index e3e927c0..13e522d2 100644 --- a/tests/ansible/integration/stub_connections/kubectl.yml +++ b/tests/ansible/integration/stub_connections/kubectl.yml @@ -12,7 +12,6 @@ - custom_python_detect_environment: vars: ansible_connection: kubectl - ansible_python_interpreter: python # avoid Travis virtualenv breakage mitogen_kubectl_path: stub-kubectl.py register: out diff --git a/tests/ansible/integration/stub_connections/lxc.yml b/tests/ansible/integration/stub_connections/lxc.yml index ae71a603..3f1a2282 100644 --- a/tests/ansible/integration/stub_connections/lxc.yml +++ b/tests/ansible/integration/stub_connections/lxc.yml @@ -8,7 +8,6 @@ - custom_python_detect_environment: vars: ansible_connection: lxc - ansible_python_interpreter: python # avoid Travis virtualenv breakage mitogen_lxc_attach_path: stub-lxc-attach.py register: out diff --git a/tests/ansible/integration/stub_connections/lxd.yml b/tests/ansible/integration/stub_connections/lxd.yml index a2f8f80a..fd811fb7 100644 --- a/tests/ansible/integration/stub_connections/lxd.yml +++ b/tests/ansible/integration/stub_connections/lxd.yml @@ -8,7 +8,6 @@ - custom_python_detect_environment: vars: ansible_connection: lxd - ansible_python_interpreter: python # avoid Travis virtualenv breakage mitogen_lxc_path: stub-lxc.py register: out diff --git a/tests/ansible/integration/stub_connections/mitogen_doas.yml b/tests/ansible/integration/stub_connections/mitogen_doas.yml index 338bc09b..a8b77edd 100644 --- a/tests/ansible/integration/stub_connections/mitogen_doas.yml +++ b/tests/ansible/integration/stub_connections/mitogen_doas.yml @@ -8,7 +8,6 @@ - custom_python_detect_environment: vars: ansible_connection: mitogen_doas - ansible_python_interpreter: python # avoid Travis virtualenv breakage ansible_doas_exe: stub-doas.py ansible_user: someuser register: out diff --git a/tests/ansible/integration/stub_connections/mitogen_sudo.yml b/tests/ansible/integration/stub_connections/mitogen_sudo.yml index 0ab18f3b..bcf0f22f 100644 --- a/tests/ansible/integration/stub_connections/mitogen_sudo.yml +++ b/tests/ansible/integration/stub_connections/mitogen_sudo.yml @@ -8,7 +8,6 @@ - custom_python_detect_environment: vars: ansible_connection: mitogen_sudo - ansible_python_interpreter: python # avoid Travis virtualenv breakage ansible_user: root ansible_become_exe: stub-sudo.py ansible_become_flags: -H --type=sometype --role=somerole diff --git a/tests/ansible/regression/issue_152__virtualenv_python_fails.yml b/tests/ansible/regression/issue_152__virtualenv_python_fails.yml index 610eaf33..e0439fdd 100644 --- a/tests/ansible/regression/issue_152__virtualenv_python_fails.yml +++ b/tests/ansible/regression/issue_152__virtualenv_python_fails.yml @@ -12,7 +12,9 @@ https_proxy: "{{ lookup('env', 'https_proxy')|default('') }}" no_proxy: "{{ lookup('env', 'no_proxy')|default('') }}" PATH: "{{ lookup('env', 'PATH') }}" - shell: virtualenv /tmp/issue_152_virtualenv + command: + cmd: virtualenv -p "{{ ansible_facts.python.executable }}" /tmp/issue_152_virtualenv + creates: /tmp/issue_152_virtualenv when: - lout.python.version.full is version('2.7', '>=', strict=True)