Skip to content

Commit

Permalink
Mark OSA version in the wrapper script
Browse files Browse the repository at this point in the history
By doing that, we compute (every bootstrap ansible) the version
of OSA, which can then be used in playbooks using a lookup.

This would be faster than doing the lookup in the variable, as
this would be computed once, gaining around 0.4s per playbook.

Change-Id: Idd3a842f94eb30dec2afa6da84615a8605ef9e78
  • Loading branch information
evrardjp authored and Jesse Pretorius (odyssey4me) committed Feb 12, 2019
1 parent f5bcc2f commit c44fbcb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions scripts/bootstrap-ansible.sh
Expand Up @@ -113,6 +113,9 @@ fi
PYTHON_EXEC_PATH="${PYTHON_EXEC_PATH:-$(which python2 || which python)}"
PYTHON_VERSION="$($PYTHON_EXEC_PATH -c 'import sys; print(".".join(map(str, sys.version_info[:3])))')"

# Get current code version (this runs at the root of OSA clone)
CURRENT_OSA_VERSION=$(cd ${OSA_CLONE_DIR}; ${PYTHON_EXEC_PATH} setup.py --version)

# Use https when Python with native SNI support is available
UPPER_CONSTRAINTS_PROTO=$([ "$PYTHON_VERSION" == $(echo -e "$PYTHON_VERSION\n2.7.9" | sort -V | tail -1) ] && echo "https" || echo "http")

Expand Down Expand Up @@ -177,6 +180,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
Expand Down
1 change: 1 addition & 0 deletions scripts/openstack-ansible.sh
Expand Up @@ -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
Expand Down

0 comments on commit c44fbcb

Please sign in to comment.