From ffce67bb7b28fd2be84a9b20310c14be3e198352 Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Thu, 26 Oct 2017 23:42:51 +0200 Subject: [PATCH] python-virtualenv: Fixes. --- python-virtualenv/defaults/main.yml | 7 +++---- python-virtualenv/tasks/main.yml | 29 +++++++---------------------- 2 files changed, 10 insertions(+), 26 deletions(-) diff --git a/python-virtualenv/defaults/main.yml b/python-virtualenv/defaults/main.yml index e7576240..fec869f6 100644 --- a/python-virtualenv/defaults/main.yml +++ b/python-virtualenv/defaults/main.yml @@ -1,14 +1,13 @@ --- py_virtenv_pkgs_state: installed -py_virtenv_site: False +#py_virtenv_site: False py_virtenv_pkgs: - python-pip - python-virtualenv -py_virtenv_pip_pkgs: - - +#py_virtenv_pip_pkgs: # py_virtenv_pip_requirements: "/tmp/foo/requirements.txt" # # py_virtenv_env_base_dir: "/tmp/foo" -py_virtenv_env_base_dir: +#py_virtenv_env_base_dir: diff --git a/python-virtualenv/tasks/main.yml b/python-virtualenv/tasks/main.yml index 2474b170..fe781624 100644 --- a/python-virtualenv/tasks/main.yml +++ b/python-virtualenv/tasks/main.yml @@ -1,34 +1,19 @@ --- - block: - - name: Install the python virtualenv packages apt: name={{ item }} state={{ py_virtenv_pkgs_state }} with_items: '{{ py_virtenv_pkgs }}' - - name: Create the virtenv environments. - command: virtualenv {{ py_virtenv_env_base_dir }} - when: '{{ py_virtenv_env_base_dir }} != ""' +# - name: Create the virtenv environments. +# command: virtualenv {{ py_virtenv_env_base_dir }} - - name: Install a list of pip packages inside the virtualenv, inherit the global site-packages - pip: name={{ item }} virtualenv={{ py_virtenv_env_base_dir }} virtualenv_site_packages=yes + - name: Install a list of pip packages inside the virtualenv, inherit the global site-packages if that is the choice + pip: name={{ item }} virtualenv={{ py_virtenv_env_base_dir }} virtualenv_site_packages={{ py_virtenv_site | default(False) }} with_items: '{{ py_virtenv_pip_pkgs | default ([]) }}' - when: py_virtenv_site - - - name: Install a list of pip packages inside the virtualenv - pip: name={{ item }} virtualenv={{ py_virtenv_env_base_dir }} - with_items: '{{ py_virtenv_pip_pkgs | default ([]) }}' - when: not py_virtenv_site - name: Install a list of pip packages inside the virtualenv from a requirements.txt file, inherit the global site-packages - pip: requirements={{ py_virtenv_pip_requirements }} virtualenv={{ py_virtenv_env_base_dir }} virtualenv_site_packages=yes - when: - - py_virtenv_pip_requirements is defined - - py_virtenv_site - - - name: Install a list of pip packages inside the virtualenv from a requirements.txt file - pip: requirements={{ py_virtenv_pip_requirements }} virtualenv={{ py_virtenv_env_base_dir }} - when: - - py_virtenv_pip_requirements is defined - - not py_virtenv_site + pip: requirements={{ py_virtenv_pip_requirements }} virtualenv={{ py_virtenv_env_base_dir }} virtualenv_site_packages={{ py_virtenv_site | default(False) }} + when: py_virtenv_pip_requirements is defined + when: py_virtenv_env_base_dir is defined tags: [ "python", "py_virtenv" ]