Faster venv-ansible-playbook.sh

If running a playbook more than once, there's no need to re-bootstrap
the virtual environment.  Assume if the verified crio directory already
exists, it should be used (after re-asserting hashes of requirements).

Signed-off-by: Chris Evich <cevich@redhat.com>
This commit is contained in:
Chris Evich 2017-09-20 15:15:08 -04:00
parent d153815f74
commit 29c4d890c8

View file

@ -56,27 +56,29 @@ echo
( (
set -x set -x
cd "$WORKSPACE" cd "$WORKSPACE"
# N/B: local system's virtualenv binary - uncontrolled version fixed below # When running more than once, make it fast by skipping the bootstrap
virtualenv --no-site-packages --python=python2.7 ./.venvbootstrap if [ ! -d "./.cri-o_venv" ]; then
# Set up paths to install/operate out of $WORKSPACE/.venvbootstrap # N/B: local system's virtualenv binary - uncontrolled version fixed below
source ./.venvbootstrap/bin/activate virtualenv --no-site-packages --python=python2.7 ./.venvbootstrap
# N/B: local system's pip binary - uncontrolled version fixed below # Set up paths to install/operate out of $WORKSPACE/.venvbootstrap
# pip may not support --cache-dir, force it's location into $WORKSPACE the ugly-way source ./.venvbootstrap/bin/activate
OLD_HOME="$HOME" # N/B: local system's pip binary - uncontrolled version fixed below
export HOME="$WORKSPACE" # pip may not support --cache-dir, force it's location into $WORKSPACE the ugly-way
export PIPCACHE="$WORKSPACE/.cache/pip" OLD_HOME="$HOME"
pip install --force-reinstall --upgrade pip==9.0.1 export HOME="$WORKSPACE"
# Undo --cache-dir workaround export PIPCACHE="$WORKSPACE/.cache/pip"
export HOME="$OLD_HOME" pip install --force-reinstall --upgrade pip==9.0.1
# Install fixed, trusted, hashed versions of all requirements (including pip and virtualenv) # Undo --cache-dir workaround
pip --cache-dir="$PIPCACHE" install --require-hashes \ export HOME="$OLD_HOME"
--requirement "$SCRIPT_PATH/requirements.txt" # Install fixed, trusted, hashed versions of all requirements (including pip and virtualenv)
pip --cache-dir="$PIPCACHE" install --require-hashes \
# Setup trusted virtualenv using hashed binary from requirements.txt --requirement "$SCRIPT_PATH/requirements.txt"
./.venvbootstrap/bin/virtualenv --no-site-packages --python=python2.7 ./.cri-o_venv
# Exit untrusted virtualenv
deactivate
# Setup trusted virtualenv using hashed binary from requirements.txt
./.venvbootstrap/bin/virtualenv --no-site-packages --python=python2.7 ./.cri-o_venv
# Exit untrusted virtualenv
deactivate
fi
# Enter trusted virtualenv # Enter trusted virtualenv
source ./.cri-o_venv/bin/activate source ./.cri-o_venv/bin/activate
# Re-install from cache # Re-install from cache