Use a venv with previous ansible version for upgrades

When doing the role upgrade, we run every playbook with current's
branch ansible. This is normal for the infrastructure bits (which
are running on current branch), but not for the installation of
the previous branch's role, which should use previous branch's
environment. This script already exists for some OSA roles to
facilitate upgrades but we are now moving it to the tests
repository so all roles can benefit from it.

(Original patch 91b7524603650edbef984fd9fe83e352b90604d2)
Link: https://github.com/ansible/ansible/pull/34790
Co-Authored-By: Jean-Philippe Evrard <jean-philippe@evrard.me>
Closes-Bug: #1741471

Change-Id: I7ebb045885dd645b820de2b7f75b46c755c015f6
(cherry picked from commit f51a22988d)
This commit is contained in:
Markos Chandras 2018-01-22 13:57:57 +00:00 committed by Jesse Pretorius (odyssey4me)
parent d0c0f8c0be
commit b62a1351fa
1 changed files with 33 additions and 0 deletions

33
test-create-previous-venv.sh Executable file
View File

@ -0,0 +1,33 @@
#!/bin/bash
# Copyright 2018, Rackspace US, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
## Shell Opts ----------------------------------------------------------------
set -e
## Vars ----------------------------------------------------------------------
export WORKING_DIR=${WORKING_DIR:-$(pwd)}
export PREVIOUS_VENV=${PREVIOUS_VENV:-"ansible-previous"}
pushd ${WORKING_DIR}/.tox
virtualenv ${PREVIOUS_VENV}
${PREVIOUS_VENV}/bin/pip install -c https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt?h=stable/ocata \
-rhttps://git.openstack.org/cgit/openstack/openstack-ansible/plain/global-requirement-pins.txt?h=stable/ocata \
-r${WORKING_DIR}/tests/common/previous/test-ansible-deps.txt ara
# Display venv contents
${PREVIOUS_VENV}/bin/pip freeze
popd