--- - name: Install the python virtualenv packages apt: name={{ item }} state={{ py_virtenv_pkgs_state }} with_items: py_virtenv_pkgs tags: [ "python", "py_virtenv" ] - name: Create the virtenv environments. command: virtualenv {{ py_virtenv_env_base_dir }} tags: [ "python", "py_virtenv" ] - 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 with_items: py_virtenv_pip_pkgs when: - py_virtenv_pip_pkgs is defined - py_virtenv_site tags: [ "python", "py_virtenv" ] - 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 when: - py_virtenv_pip_pkgs is defined - not py_virtenv_site tags: [ "python", "py_virtenv" ] - 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 tags: [ "python", "py_virtenv" ] - 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 tags: [ "python", "py_virtenv" ]