tests: Variabalize virtualenv creation in isssue 152 regression test

Prep for AlamaLinux 9 introduction
pull/1373/head
Alex Willmer 1 week ago
parent 1cbd1777bc
commit e044893a88

@ -35,3 +35,11 @@ become_unpriv_available: >-
-}} -}}
pkg_mgr_python_interpreter: python pkg_mgr_python_interpreter: python
virtualenv_create_argv:
- virtualenv
- -p
- "{{ virtualenv_python }}"
- "{{ virtualenv_path }}"
virtualenv_path: /path/intentionally/left/invalid
virtualenv_python: /path/intentionally/left/invalid

@ -1,26 +1,29 @@
- name: regression/issue_152__virtualenv_python_fails.yml - name: regression/issue_152__virtualenv_python_fails.yml
gather_facts: true gather_facts: true
hosts: test-targets hosts: test-targets
vars:
virtualenv_path: /tmp/issue_152_virtualenv
virtualenv_python: "{{ ansible_facts.python.executable }}"
tasks: tasks:
- custom_python_detect_environment: - custom_python_detect_environment:
register: lout register: lout
# Can't use pip module because it can't create virtualenvs, must call it # Can't use pip module because it can't create virtualenvs, must call it
# directly. # directly.
- name: Create /tmp/issue_152_virtualenv - name: Create temporary virtualenv
environment: environment:
https_proxy: "{{ lookup('env', 'https_proxy')|default('') }}" https_proxy: "{{ lookup('env', 'https_proxy')|default('') }}"
no_proxy: "{{ lookup('env', 'no_proxy')|default('') }}" no_proxy: "{{ lookup('env', 'no_proxy')|default('') }}"
PATH: "{{ lookup('env', 'PATH') }}" PATH: "{{ lookup('env', 'PATH') }}"
command: command:
cmd: virtualenv -p "{{ ansible_facts.python.executable }}" /tmp/issue_152_virtualenv argv: "{{ virtualenv_create_argv }}"
creates: /tmp/issue_152_virtualenv creates: "{{ virtualenv_path }}"
when: when:
- lout.python.version.full is version('2.7', '>=', strict=True) - lout.python.version.full is version('2.7', '>=', strict=True)
- custom_python_detect_environment: - custom_python_detect_environment:
vars: vars:
ansible_python_interpreter: /tmp/issue_152_virtualenv/bin/python ansible_python_interpreter: "{{ virtualenv_path }}/bin/python"
register: out register: out
when: when:
- lout.python.version.full is version('2.7', '>=', strict=True) - lout.python.version.full is version('2.7', '>=', strict=True)
@ -28,7 +31,7 @@
- name: Check virtualenv was used - name: Check virtualenv was used
# On macOS runners a symlink /tmp -> /private/tmp has been seen # On macOS runners a symlink /tmp -> /private/tmp has been seen
vars: vars:
requested_executable: /tmp/issue_152_virtualenv/bin/python requested_executable: "{{ virtualenv_path }}/bin/python"
expected_executables: expected_executables:
- "{{ requested_executable }}" - "{{ requested_executable }}"
- "{{ requested_executable.replace('/tmp', out.fs['/tmp'].resolved) }}" - "{{ requested_executable.replace('/tmp', out.fs['/tmp'].resolved) }}"
@ -40,9 +43,9 @@
when: when:
- lout.python.version.full is version('2.7', '>=', strict=True) - lout.python.version.full is version('2.7', '>=', strict=True)
- name: Cleanup /tmp/issue_152_virtualenv - name: Cleanup temporary virtualenv
file: file:
path: /tmp/issue_152_virtualenv path: "{{ virtualenv_path }}"
state: absent state: absent
when: when:
- lout.python.version.full is version('2.7', '>=', strict=True) - lout.python.version.full is version('2.7', '>=', strict=True)

Loading…
Cancel
Save