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 c44fbcbbe3)
(cherry picked from commit a30ce47845)
(cherry picked from commit 7e0d2e5e5c)
This commit is contained in:
Jean-Philippe Evrard 2019-01-29 16:39:51 +01:00
parent deb4e1fbf7
commit 94f1b6512e
3 changed files with 7 additions and 1 deletions

View File

@ -14,7 +14,7 @@
# limitations under the License.
## OpenStack Source Code Release
openstack_release: 16.0.26
openstack_release: "{{ lookup('env', 'OSA_VERSION') | default('undefined', true) }}"
## Verbosity Options
debug: False

View File

@ -173,6 +173,9 @@ PIP_OPTS+=" --constraint ${UPPER_CONSTRAINTS_FILE}"
# a different version of Ansible to the one we want to install. As such, we
# use --isolated so that the config file is ignored.
# 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}
@ -205,6 +208,8 @@ sed -i "s|OSA_HOST_VARS_DIR|${OSA_CLONE_DIR}/host_vars/|g" /usr/local/bin/openst
# 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

View File

@ -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