From 07123ebeaa39a1c5de938e11eefef18366d5c3f2 Mon Sep 17 00:00:00 2001 From: Chris Smart Date: Mon, 22 Aug 2016 22:04:02 +1000 Subject: [PATCH] Fix wrong version of pip used in bootstrap The bootstrap-ansible script is failing with a Python backtrace as it fails to parse the "ndg-httpsclient>=0.4.2;python_version<'3.0'" line in requirements.txt properly. Commit c904de2db512 "Isolate Ansible from the deployment host" introduced the separation of Ansible into a virtualenv. Even though pip is updated and placed under /usr/local/bin, the system's package is the version which is copied into the virtualenv (version 1.5.4 in Ubuntu 14.04). Commit ab887ee13def "Include python requirements to resolve SNI issue for Ansible venv" introduced a python_version environment marker to the ndg-httpsclient line in requirements.txt file. This is a feature which was added in pip version 6.0 and is therefore not supported by the older version being run in the virtualenv. This patch uses the system's version of pip which is installed into the virtualenv, to update itself to the latest version. This way we can ensure that we are using the correct version of pip which supports environment markers and other newer features. Change-Id: I96536b390ab5bde27397d1ff5de6c16332570e65 --- scripts/bootstrap-ansible.sh | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/scripts/bootstrap-ansible.sh b/scripts/bootstrap-ansible.sh index c496c91fc3..d1bf7fab7c 100755 --- a/scripts/bootstrap-ansible.sh +++ b/scripts/bootstrap-ansible.sh @@ -84,20 +84,22 @@ elif [ -n "$HTTP_PROXY" ]; then PIP_OPTS="--proxy $HTTP_PROXY" fi -PIP_COMMAND=pip2 -if [ ! $(which "$PIP_COMMAND") ]; then - PIP_COMMAND=pip -fi - # Create a Virtualenv for the Ansible runtime PYTHON_EXEC_PATH="$(which python2 || which python)" -virtualenv --always-copy --system-site-packages --python="${PYTHON_EXEC_PATH}" /opt/ansible-runtime +virtualenv --clear --always-copy --system-site-packages --python="${PYTHON_EXEC_PATH}" /opt/ansible-runtime # Install ansible PIP_OPTS+=" --upgrade" PIP_COMMAND="/opt/ansible-runtime/bin/pip" -# When upgrading there will already be a pip.conf file locking pip down to the repo server, in such cases it may be -# necessary to use --isolated because the repo server does not meet the specified requirements. + +# When upgrading there will already be a pip.conf file locking pip down to the +# repo server, in such cases it may be necessary to use --isolated because the +# repo server does not meet the specified requirements. + +# Ensure we are running the required versions of pip, wheel and setuptools +${PIP_COMMAND} install ${PIP_OPTS} ${PIP_INSTALL_OPTIONS} || ${PIP_COMMAND} install ${PIP_OPTS} --isolated ${PIP_INSTALL_OPTIONS} + +# Install the required packages for ansible $PIP_COMMAND install $PIP_OPTS -r requirements.txt ${ANSIBLE_PACKAGE} || $PIP_COMMAND install --isolated $PIP_OPTS -r requirements.txt ${ANSIBLE_PACKAGE} # Link the venv installation of Ansible to the local path