Different pip install with/without venv

When testing the scripts with newer ansible version, it was failing
to install packages with pip and without venv. The reason is because
even the venv vars are set to omit, the module is still acting as it
had an empty virtualenv, causing this to fail. So just create a
different step, without the vars being set.

Change-Id: I0b268a170e69ccc36f90d875f25453d3874b22b0
This commit is contained in:
Yolanda Robla 2017-09-19 17:55:24 +02:00
parent 2c6d130f0b
commit adfe6b52f1

View File

@ -17,21 +17,34 @@
- name: set virtualenv_command - name: set virtualenv_command
set_fact: set_fact:
venv_command: "{{ hostvars[inventory_hostname].ansible_python.executable }} -m virtualenv" venv_command: "{{ hostvars[inventory_hostname].ansible_python.executable }} -m virtualenv"
when: enable_venv when: enable_venv|bool
- name: "Install {{ package }} package from pip" - name: "Install {{ package }} package from pip using virtualenv"
pip: pip:
name: "{{ package }}" name: "{{ package }}"
state: "{{ state | default(omit) }}" state: "{{ state | default(omit) }}"
version: "{{ version | default(omit) }}" version: "{{ version | default(omit) }}"
virtualenv: "{{ bifrost_venv_dir if enable_venv else omit }}" virtualenv: "{{ bifrost_venv_dir }}"
virtualenv_command: "{{ venv_command | default(omit) }}" virtualenv_command: "{{ venv_command | default(omit) }}"
extra_args: "{{ extra_args | default(omit) }}" extra_args: "{{ extra_args | default(omit) }}"
register: pip_package_install_done register: pip_package_install_done
until: pip_package_install_done|succeeded until: pip_package_install_done|succeeded
retries: 5 retries: 5
delay: 10 delay: 10
when: source_install is not defined or source_install == false when: (source_install is not defined or source_install == false) and enable_venv|bool
- name: "Install {{ package }} package from pip without virtualenv"
pip:
name: "{{ package }}"
state: "{{ state | default(omit) }}"
version: "{{ version | default(omit) }}"
extra_args: "{{ extra_args | default(omit) }}"
register: pip_package_install_done
until: pip_package_install_done|succeeded
retries: 5
delay: 10
when: (source_install is not defined or source_install == false) and not enable_venv|bool
# NOTE (cinerama): We should be able to use the pip module here and # NOTE (cinerama): We should be able to use the pip module here and
# possibly merge these two tasks when # possibly merge these two tasks when
# https://github.com/ansible/ansible-modules-core/pull/2600 lands. # https://github.com/ansible/ansible-modules-core/pull/2600 lands.