diff --git a/test/integration/targets/pip/tasks/main.yml b/test/integration/targets/pip/tasks/main.yml index 68ecf488baa..e669d297cf6 100644 --- a/test/integration/targets/pip/tasks/main.yml +++ b/test/integration/targets/pip/tasks/main.yml @@ -1,20 +1,30 @@ # Current pip unconditionally uses md5. # We can re-enable if pip switches to a different hash or allows us to not check md5. -- name: find virtualenv command - command: "which virtualenv virtualenv-{{ ansible_python.version.major }}.{{ ansible_python.version.minor }}" - register: command - ignore_errors: true +- name: Python 2 + when: ansible_python.version.major == 2 + block: + - name: find virtualenv command + command: "which virtualenv virtualenv-{{ ansible_python.version.major }}.{{ ansible_python.version.minor }}" + register: command + ignore_errors: true -- name: is virtualenv available to python -m - command: '{{ ansible_python_interpreter }} -m virtualenv' - register: python_m - when: not command.stdout_lines - failed_when: python_m.rc != 2 + - name: is virtualenv available to python -m + command: '{{ ansible_python_interpreter }} -m virtualenv' + register: python_m + when: not command.stdout_lines + failed_when: python_m.rc != 2 -- name: remember selected virtualenv command - set_fact: - virtualenv: "{{ command.stdout_lines[0] if command is successful else ansible_python_interpreter ~ ' -m virtualenv' }}" + - name: remember selected virtualenv command + set_fact: + virtualenv: "{{ command.stdout_lines[0] if command is successful else ansible_python_interpreter ~ ' -m virtualenv' }}" + +- name: Python 3+ + when: ansible_python.version.major > 2 + block: + - name: remember selected virtualenv command + set_fact: + virtualenv: "{{ ansible_python_interpreter ~ ' -m venv' }}" - block: - name: install git, needed for repo installs diff --git a/test/integration/targets/pip/tasks/pip.yml b/test/integration/targets/pip/tasks/pip.yml index 6281bbe80cb..572c7b6f312 100644 --- a/test/integration/targets/pip/tasks/pip.yml +++ b/test/integration/targets/pip/tasks/pip.yml @@ -521,7 +521,7 @@ ### test virtualenv_command begin ### - name: Test virtualenv command with arguments - when: "ansible_system == 'Linux'" + when: ansible_python.version.major == 2 block: - name: make sure the virtualenv does not exist file: @@ -533,7 +533,7 @@ pip: name: "{{ pip_test_package }}" virtualenv: "{{ output_dir }}/pipenv" - virtualenv_command: "virtualenv --verbose" + virtualenv_command: "{{ command.stdout_lines[0] | basename }} --verbose" state: present register: version13