From 0635dfbccc98bc2beb308d2b30ddbaf404201087 Mon Sep 17 00:00:00 2001 From: Jesse Pretorius Date: Wed, 17 Apr 2019 12:25:45 +0100 Subject: [PATCH] Ensure that global-requirement-pins.txt is applied In the previous repo build process, we had global constraints which override upper constraints and anything set in the roles. This was essential for two purposes: 1. To enable us to pin things that were not in upper constraints. eg: pip, setuptools, wheel 2. To enable us to pin things which were in upper constraints, but broken. This would usually be a temporary measure until upper constraints was fixed. This patch extracts the global pins from global-requirement-pins.txt into a list and sets 'venv_build_global_constraints' to the resulting list so that it is applied to all venvs built. In order to reliably find this file without using a hard-coded path, we implement a change to the wrapper script to set the path in it in a similar manner to that implemented for the inventory path. Depends-On: I9ae3ef19c863b9237a51d2fcd6f4ebce1a9ebad7 Change-Id: I138fe1c8ea80fe71244ab0dc6497cfc6d7bdf953 --- inventory/group_vars/all/all.yml | 6 ++++++ scripts/bootstrap-ansible.sh | 3 ++- scripts/openstack-ansible.sh | 5 ++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/inventory/group_vars/all/all.yml b/inventory/group_vars/all/all.yml index 2e203c9852..cb6a113b33 100644 --- a/inventory/group_vars/all/all.yml +++ b/inventory/group_vars/all/all.yml @@ -128,3 +128,9 @@ is_metal: >- {{ (properties is defined) and (properties.is_metal is defined) and (properties.is_metal | bool) }} + +_global_pins_file_path: >- + {{ (lookup('env', 'OSA_CLONE_ROOT') | default('/opt/openstack-ansible', true)) ~ '/global-requirement-pins.txt' }} + +venv_build_global_constraints: >- + {{ lookup('file', _global_pins_file_path).splitlines() | reject('match','^#.*$') | reject('equalto', '') | list }} diff --git a/scripts/bootstrap-ansible.sh b/scripts/bootstrap-ansible.sh index 3a8af10fd5..1a0623b441 100755 --- a/scripts/bootstrap-ansible.sh +++ b/scripts/bootstrap-ansible.sh @@ -176,8 +176,9 @@ sed -i "s|OSA_PLAYBOOK_PATH|${OSA_PLAYBOOK_PATH}|g" /usr/local/bin/openstack-ans # Create openstack ansible wrapper tool cp -v ${OSA_WRAPPER_BIN} /usr/local/bin/openstack-ansible +# Mark the current OSA git repo clone directory, so we don't need to compute it every time. sed -i "s|OSA_CLONE_DIR|${OSA_CLONE_DIR}|g" /usr/local/bin/openstack-ansible -# Mark the current OSA version in the wrapper, so we don't need to compute it everytime. +# Mark the current OSA version in the wrapper, so we don't need to compute it every time. sed -i "s|CURRENT_OSA_VERSION|${CURRENT_OSA_VERSION}|g" /usr/local/bin/openstack-ansible # Ensure wrapper tool is executable diff --git a/scripts/openstack-ansible.sh b/scripts/openstack-ansible.sh index c368c987a7..9044087b72 100644 --- a/scripts/openstack-ansible.sh +++ b/scripts/openstack-ansible.sh @@ -18,7 +18,10 @@ # OpenStack wrapper tool to ease the use of ansible with multiple variable files. export PATH="/opt/ansible-runtime/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${PATH}" + +# These environment variables are used in group_vars export OSA_VERSION="CURRENT_OSA_VERSION" +export OSA_CLONE_ROOT="OSA_CLONE_DIR" function info { if [ "${ANSIBLE_NOCOLOR:-0}" -eq "1" ]; then @@ -32,7 +35,7 @@ function info { RUN_CMD=$(basename ${0}) # Apply the OpenStack-Ansible configuration selectively. -if [[ "${PWD}" == *"OSA_CLONE_DIR"* ]] || [ "${RUN_CMD}" == "openstack-ansible" ]; then +if [[ "${PWD}" == *"${OSA_CLONE_ROOT}"* ]] || [ "${RUN_CMD}" == "openstack-ansible" ]; then # Source the Ansible configuration. . /usr/local/bin/openstack-ansible.rc