Julia Kreger a7cfcd2a1c Sync pip_install files
We've made changes to the primary role install files,
however we didn't make the same changes to the keystone
role file.

Change-Id: I8b35bd30d94f997045ae37edcdb7691a25f2c57b
2020-02-05 08:43:00 +01:00

79 lines
3.2 KiB
YAML

# Copyright (c) 2015 Hewlett Packard Enterprise Development LP.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
- name: set virtualenv_command
set_fact:
venv_command: "python3 -m venv"
when: enable_venv
- name: Set extra_args if upper_constraints_file is defined
set_fact:
constraints_extra_args: "{{ extra_args | default('') }} -c {{ upper_constraints_file }}"
when:
- (upper_constraints_file | default('')) != ''
# NOTE(dtantsur): constraining does not work correctly correctly with
# source installation if the package itself is in constraints.
- source_install is not defined or source_install == false
- name: "Install {{ package }} package from pip using virtualenv"
pip:
name: "{{ package }}"
state: "{{ state | default(omit) }}"
version: "{{ version | default(omit) }}"
virtualenv: "{{ bifrost_venv_dir }}"
virtualenv_command: "{{ venv_command | default(omit) }}"
extra_args: "{{ constraints_extra_args | default(extra_args) | default(omit) }}"
requirements: "{{ requirements_file | default(omit) }}"
register: pip_package_install_done
until: pip_package_install_done is succeeded
retries: 5
delay: 10
when: (source_install is not defined or source_install | bool == false ) and enable_venv | default(false) | bool
- name: "Install {{ package }} package from pip without virtualenv"
pip:
name: "{{ package }}"
state: "{{ state | default(omit) }}"
version: "{{ version | default(omit) }}"
extra_args: "{{ constraints_extra_args | default(extra_args) | default(omit) }}"
requirements: "{{ requirements_file | default(omit) }}"
executable: /usr/bin/pip3
register: pip_package_install_done
until: pip_package_install_done is succeeded
retries: 5
delay: 10
when: (source_install is not defined or source_install | bool == false ) and enable_venv | default(false) | bool == false
# NOTE (cinerama): We should be able to use the pip module here
- name: "Install requirements from {{ sourcedir }} using pip"
command: |
pip3 install -r {{ sourcedir }}/requirements.txt
{{ extra_args | default('') }}
{% if upper_constraints_file %}-c {{ upper_constraints_file }}{% endif %}
register: pip_package_install_done
until: pip_package_install_done is succeeded
retries: 5
delay: 10
when: source_install is defined and source_install | default(true) | bool
environment: "{{ bifrost_venv_env if enable_venv else {} }}"
# NOTE(dtantsur): do not use constraints here, it does not work when the
# package itself is constrained.
- name: "Install from {{ sourcedir }} using pip"
command: pip3 install {{ sourcedir }} {{ extra_args | default('') }}
when: source_install is defined and (source_install | bool == true)
environment: "{{ bifrost_venv_env if enable_venv else {} }}"