Isolate Ansible bootstrap from repo servers

On first deployment bootstrap-ansible.sh pulls its packages from PyPI.
On upgrade, when the deployment host is shared with a controller, a
pip.conf file exists to restrict pip to the packages hosted by the repo
containers. This causes bootstrap-ansible.sh to fail when the repo
server created by the previous version does not contain a compatible
version.

This commit adds the flag '--isolated' to allow the bootstrap process to
bypass the repo server.

To allow the pip command to fall back on using the isolated flag the
code is refactored to determine the version of pip prior to its use.

Change-Id: Ie9834eb55a689d6f74441cc78e34b62be5d82141
This commit is contained in:
git-harry
2016-05-09 11:50:51 +01:00
parent 2b7d0b91b1
commit 6be15b8ddd

View File

@@ -74,13 +74,22 @@ elif [ -n "$HTTP_PROXY" ]; then
PIP_OPTS="--proxy $HTTP_PROXY"
fi
PIP_COMMAND=pip2
if [ ! $(which "$PIP_COMMAND") ]; then
PIP_COMMAND=pip
fi
# Install requirements if there are any
if [ -f "requirements.txt" ];then
pip2 install $PIP_OPTS -r requirements.txt || pip install $PIP_OPTS -r requirements.txt
# 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.
$PIP_COMMAND install $PIP_OPTS -r requirements.txt || $PIP_COMMAND install --isolated $PIP_OPTS -r requirements.txt
fi
# Install ansible
pip2 install $PIP_OPTS "${ANSIBLE_WORKING_DIR}" || pip install $PIP_OPTS "${ANSIBLE_WORKING_DIR}"
# 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.
$PIP_COMMAND install $PIP_OPTS "${ANSIBLE_WORKING_DIR}" || $PIP_COMMAND install --isolated $PIP_OPTS "${ANSIBLE_WORKING_DIR}"
# Update dependent roles
if [ -f "${ANSIBLE_ROLE_FILE}" ];then