From a7cfcd2a1c5bf249a2307dc4e67df7892a1f64b0 Mon Sep 17 00:00:00 2001 From: Julia Kreger Date: Mon, 20 Jan 2020 13:17:37 -0800 Subject: [PATCH] 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 --- .../tasks/install.yml | 10 ++---- .../tasks/pip_install.yml | 33 +++++++++++++++---- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/playbooks/roles/bifrost-keystone-install/tasks/install.yml b/playbooks/roles/bifrost-keystone-install/tasks/install.yml index 95d952e68..e4bc29b7d 100644 --- a/playbooks/roles/bifrost-keystone-install/tasks/install.yml +++ b/playbooks/roles/bifrost-keystone-install/tasks/install.yml @@ -33,7 +33,6 @@ include: pip_install.yml package=configparser virtualenv=bifrost_venv_dir - extra_args="-c {{ upper_constraints_file }}" when: - skip_install is not defined - enable_venv | bool == true @@ -42,7 +41,6 @@ include: pip_install.yml package=pymysql virtualenv=bifrost_venv_dir - extra_args="-c {{ upper_constraints_file }}" when: - skip_install is not defined - enable_venv | bool == true @@ -51,7 +49,6 @@ include: pip_install.yml package=python-openstackclient virtualenv=bifrost_venv_dir - extra_args="-c {{ upper_constraints_file }}" when: - skip_install is not defined - enable_venv | bool == true @@ -63,7 +60,7 @@ state=latest sourcedir={{ keystone_git_folder }} source_install={{ keystone_source_install | bool }} - extra_args="--no-cache-dir {{ pip_opts }} -c {{ upper_constraints_file }}" + extra_args="--no-cache-dir {{ pip_opts }}" when: - skip_install is not defined - enable_venv | bool == true @@ -71,7 +68,6 @@ - name: "Install configparser if not using a venv" include: pip_install.yml package=configparser - extra_args="-c {{ upper_constraints_file }}" when: - skip_install is not defined - enable_venv | bool == false @@ -79,7 +75,6 @@ - name: "Install pymysql if not using a venv" include: pip_install.yml package=pymysql - extra_args="-c {{ upper_constraints_file }}" when: - skip_install is not defined - enable_venv | bool == false @@ -87,7 +82,6 @@ - name: "Install python-openstackclient if not using a venv" include: pip_install.yml package=python-openstackclient - extra_args="-c {{ upper_constraints_file }}" when: - skip_install is not defined - enable_venv | bool == false @@ -98,7 +92,7 @@ state=latest sourcedir={{ keystone_git_folder }} source_install={{ keystone_source_install | bool }} - extra_args="--no-cache-dir {{ pip_opts }} -c {{ upper_constraints_file }}" + extra_args="--no-cache-dir {{ pip_opts }}" when: - skip_install is not defined - enable_venv | bool == false diff --git a/playbooks/roles/bifrost-keystone-install/tasks/pip_install.yml b/playbooks/roles/bifrost-keystone-install/tasks/pip_install.yml index 8a8d3fd94..5aa929846 100644 --- a/playbooks/roles/bifrost-keystone-install/tasks/pip_install.yml +++ b/playbooks/roles/bifrost-keystone-install/tasks/pip_install.yml @@ -1,3 +1,5 @@ +# 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 @@ -17,6 +19,15 @@ 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 }}" @@ -24,7 +35,7 @@ version: "{{ version | default(omit) }}" virtualenv: "{{ bifrost_venv_dir }}" virtualenv_command: "{{ venv_command | default(omit) }}" - extra_args: "{{ extra_args | 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 @@ -37,7 +48,7 @@ name: "{{ package }}" state: "{{ state | default(omit) }}" version: "{{ version | default(omit) }}" - extra_args: "{{ extra_args | 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 @@ -46,14 +57,22 @@ 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 and -# possibly merge these two tasks when -# https://github.com/ansible/ansible-modules-core/pull/2600 lands. -- name: "Install from {{ sourcedir | default(package) }} using pip" - command: pip3 install {{ sourcedir | default(package) }} {{ extra_args | default('') }} +# 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 {} }}"