Only add --no-site-packages when necessary

The --no-site-packages option is deprecated, and is only
necessary for virtualenv versions below 1.7.0. This patch
checks the version and adds it only when necessary.

Change-Id: I19b4acf148c28c96f58bcbda4b19153d56206008
This commit is contained in:
Jesse Pretorius 2018-08-27 23:29:32 +01:00 committed by Jesse Pretorius (odyssey4me)
parent c4d466ad40
commit 94c6e3ff99
2 changed files with 4 additions and 4 deletions

View File

@ -48,8 +48,7 @@
- name: Create the virtualenv (if it does not exist)
command: >-
virtualenv
--no-site-packages
{{ _venv_create_no_download }}
{{ _venv_create_extra_options }}
--python={{ venv_python_executable }}
{{ (ansible_pkg_mgr == 'apt') | ternary('--always-copy', '') }}
{{ venv_install_destination_path }}

View File

@ -40,10 +40,11 @@
- ((_virtualenv_version.stdout | trim) == 'none') or
((_virtualenv_version.stdout | trim) is version_compare('1.10', '<'))
- name: Set the correct virtualenv parameter to prevent downloads when creating
- name: Set extra virtualenv parameters
set_fact:
_venv_create_no_download: >-
_venv_create_extra_options: >-
{{ ((_virtualenv_version.stdout | trim) is version_compare('14.0.0', '<')) | ternary('--never-download', '--no-download') }}
{{ ((_virtualenv_version.stdout | trim) is version_compare('1.7.0', '<')) | ternary('--no-site-packages', '') }}
- name: Check whether the venv_install_source_path is a URL or a file path
set_fact: