From c75211306d41bd76babccd9273063eca49709b47 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Evrard Date: Tue, 29 Jan 2019 16:39:51 +0100 Subject: [PATCH] Mark (and use) version with the OSA wrapper script By doing that, we compute (every bootstrap ansible) the version of OSA, which is then used in playbooks using an env lookup. This is faster than doing the lookup pipe of version in the variable, as this would be computed once, gaining around 0.4s per playbook. This is about as fast as the current static code, and doesn't require bumping at every release. This also allows more flexible releasing (no need to bump metadata here for a minor bump anymore), as we would have only one source of truth. Change-Id: I75657c6dae2c6246ec2513f4ec452a4c354d638b (cherry picked from commit c44fbcbbe3b6d88e9393503e92ac670f9e811148) (cherry picked from commit a30ce47845039140ecd6def60917207a020c03ea) (cherry picked from commit 7e0d2e5e5c9cad5be2091d7a973dc2b5abf4d561) --- inventory/group_vars/all/all.yml | 2 +- scripts/bootstrap-ansible.sh | 5 +++++ scripts/openstack-ansible.sh | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/inventory/group_vars/all/all.yml b/inventory/group_vars/all/all.yml index 497b1edeb8..1c997c6c2b 100644 --- a/inventory/group_vars/all/all.yml +++ b/inventory/group_vars/all/all.yml @@ -14,7 +14,7 @@ # limitations under the License. ## OpenStack Source Code Release -openstack_release: 18.1.4 +openstack_release: "{{ lookup('env', 'OSA_VERSION') | default('undefined', true) }}" ## Verbosity Options debug: False diff --git a/scripts/bootstrap-ansible.sh b/scripts/bootstrap-ansible.sh index bc97373d30..b144e33a0f 100755 --- a/scripts/bootstrap-ansible.sh +++ b/scripts/bootstrap-ansible.sh @@ -143,6 +143,9 @@ PIP_OPTS+=" --constraint ${UPPER_CONSTRAINTS_FILE}" # Upgrade pip setuptools and wheel to the appropriate version ${PIP_COMMAND} install --isolated ${PIP_OPTS} --upgrade pip setuptools wheel +# Get current code version (this runs at the root of OSA clone) +CURRENT_OSA_VERSION=$(cd ${OSA_CLONE_DIR}; /opt/ansible-runtime/bin/python setup.py --version) + # Install ansible and the other required packages ${PIP_COMMAND} install --isolated ${PIP_OPTS} -r requirements.txt ${ANSIBLE_PACKAGE} @@ -178,6 +181,8 @@ 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 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. +sed -i "s|CURRENT_OSA_VERSION|${CURRENT_OSA_VERSION}|g" /usr/local/bin/openstack-ansible # Ensure wrapper tool is executable chmod +x /usr/local/bin/openstack-ansible diff --git a/scripts/openstack-ansible.sh b/scripts/openstack-ansible.sh index dd3d823a71..cbe677bd12 100644 --- a/scripts/openstack-ansible.sh +++ b/scripts/openstack-ansible.sh @@ -18,6 +18,7 @@ # 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}" +export OSA_VERSION="CURRENT_OSA_VERSION" function info { if [ "${ANSIBLE_NOCOLOR:-0}" -eq "1" ]; then