Skip to content

Commit

Permalink
Mark (and use) version with the OSA 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 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 c44fbcb)
(cherry picked from commit a30ce47)
(cherry picked from commit 7e0d2e5)
  • Loading branch information
evrardjp committed Feb 16, 2019
1 parent 5fbdf24 commit c752113
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion inventory/group_vars/all/all.yml
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions scripts/bootstrap-ansible.sh
Expand Up @@ -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}

Expand Down Expand Up @@ -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
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 c752113

Please sign in to comment.