Simplify pip options/constraints mechanism

The current constraints generation for the
installation involves multiple tasks and multiple
variables.

Using multiple tasks extends the installation time
unnecessarily and the additional variables are
unnecessary.

This patch aims to simplify the mechanism and
hopes to speed it up a little.

Change-Id: I9bdbe46c56893c3eeb0312065dfddcf32127c97f
This commit is contained in:
Jesse Pretorius 2016-11-02 18:00:56 +00:00 committed by Jesse Pretorius (odyssey4me)
parent c3af1f1a05
commit f155038e11
3 changed files with 14 additions and 26 deletions

View File

@ -21,8 +21,6 @@ sahara_pip_package_state: "latest"
sahara_git_repo: https://git.openstack.org/openstack/sahara
sahara_git_install_branch: master
sahara_requirements_git_repo: https://git.openstack.org/openstack/requirements
sahara_requirements_git_install_branch: master
sahara_developer_mode: false
sahara_developer_constraints:
- "git+{{ sahara_git_repo }}@{{ sahara_git_install_branch }}#egg=sahara"

View File

@ -0,0 +1,7 @@
---
upgrade:
- The variables ``sahara_requirements_git_repo`` and
``sahara_requirements_git_install_branch`` have been
removed in favour of using the URL/path to the
upper-constraints file using the
variable ``pip_install_upper_constraints`` instead.

View File

@ -25,33 +25,13 @@
when:
- sahara_developer_mode | bool
- name: Clone requirements git repository
git:
repo: "{{ sahara_requirements_git_repo }}"
dest: "/opt/requirements"
clone: yes
update: yes
version: "{{ sahara_requirements_git_install_branch }}"
when:
- sahara_developer_mode | bool
- name: Add constraints to pip_install_options fact for developer mode
set_fact:
pip_install_options_fact: "{{ pip_install_options|default('') }} --constraint /opt/developer-pip-constraints.txt --constraint /opt/requirements/upper-constraints.txt"
when:
- sahara_developer_mode | bool
- name: Set pip_install_options_fact when not in developer mode
set_fact:
pip_install_options_fact: "{{ pip_install_options|default('') }}"
when:
- not sahara_developer_mode | bool
- name: Install required pip packages
pip:
name: "{{ sahara_required_pip_packages | join(' ') }}"
state: present
extra_args: "{{ pip_install_options_fact }}"
extra_args: >-
{{ (pip_install_upper_constraints is defined) | ternary('--constraint ' + pip_install_upper_constraints | default(''),'') }}
{{ pip_install_options | default('') }}
register: install_packages
until: install_packages|success
retries: 5
@ -109,7 +89,10 @@
state: "{{ sahara_pip_package_state }}"
virtualenv: "{{ sahara_bin | dirname }}"
virtualenv_site_packages: "no"
extra_args: "{{ pip_install_options_fact }}"
extra_args: >-
{{ sahara_developer_mode | ternary('--constraint /opt/developer-pip-constraints.txt', '') }}
{{ (pip_install_upper_constraints is defined) | ternary('--constraint ' + pip_install_upper_constraints | default(''),'') }}
{{ pip_install_options | default('') }}
register: install_packages
until: install_packages|success
retries: 5