Change bootstrap to install a pip version within a major range
This patch sets bootstrap-ansible to always install a pip version within a specific major range. Change-Id: Ib33a39f9c9bb1c648977200a76c1936b0461c2f7
This commit is contained in:
parent
9923612370
commit
2b6c9c39fa
@ -21,6 +21,7 @@ MAX_RETRIES=${MAX_RETRIES:-5}
|
|||||||
REPORT_DATA=${REPORT_DATA:-""}
|
REPORT_DATA=${REPORT_DATA:-""}
|
||||||
ANSIBLE_PARAMETERS=${ANSIBLE_PARAMETERS:-""}
|
ANSIBLE_PARAMETERS=${ANSIBLE_PARAMETERS:-""}
|
||||||
STARTTIME="${STARTTIME:-$(date +%s)}"
|
STARTTIME="${STARTTIME:-$(date +%s)}"
|
||||||
|
PIP_MAJOR_VERSION=${PIP_MAJOR_VERSION:-"7"}
|
||||||
|
|
||||||
# The default SSHD configuration has MaxSessions = 10. If a deployer changes
|
# The default SSHD configuration has MaxSessions = 10. If a deployer changes
|
||||||
# their SSHD config, then the FORKS may be set to a higher number. We set the
|
# their SSHD config, then the FORKS may be set to a higher number. We set the
|
||||||
@ -211,14 +212,23 @@ function print_report {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function get_pip {
|
function get_pip {
|
||||||
# if pip is already installed, don't bother doing anything
|
|
||||||
if [ ! "$(which pip)" ]; then
|
# check if pip is already installed
|
||||||
|
if [ "$(which pip)" ]; then
|
||||||
|
|
||||||
|
# if the version installed is the wrong version, fix it
|
||||||
|
if [ "$(pip --version | awk '{print $2}' | cut -d. -f1)" != ${PIP_MAJOR_VERSION} ]; then
|
||||||
|
pip install -I "pip>=${PIP_MAJOR_VERSION},<$((PIP_MAJOR_VERSION+1))"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# when pip is not installed, install it
|
||||||
|
else
|
||||||
|
|
||||||
# If GET_PIP_URL is set, then just use it
|
# If GET_PIP_URL is set, then just use it
|
||||||
if [ -n "${GET_PIP_URL:-}" ]; then
|
if [ -n "${GET_PIP_URL:-}" ]; then
|
||||||
curl --silent ${GET_PIP_URL} > /opt/get-pip.py
|
curl --silent ${GET_PIP_URL} > /opt/get-pip.py
|
||||||
if head -n 1 /opt/get-pip.py | grep python; then
|
if head -n 1 /opt/get-pip.py | grep python; then
|
||||||
python2 /opt/get-pip.py || python /opt/get-pip.py
|
python /opt/get-pip.py "pip>=${PIP_MAJOR_VERSION},<$((PIP_MAJOR_VERSION+1))"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -226,14 +236,14 @@ function get_pip {
|
|||||||
# Try getting pip from bootstrap.pypa.io as a primary source
|
# Try getting pip from bootstrap.pypa.io as a primary source
|
||||||
curl --silent https://bootstrap.pypa.io/get-pip.py > /opt/get-pip.py
|
curl --silent https://bootstrap.pypa.io/get-pip.py > /opt/get-pip.py
|
||||||
if head -n 1 /opt/get-pip.py | grep python; then
|
if head -n 1 /opt/get-pip.py | grep python; then
|
||||||
python2 /opt/get-pip.py || python /opt/get-pip.py
|
python /opt/get-pip.py "pip>=${PIP_MAJOR_VERSION},<$((PIP_MAJOR_VERSION+1))"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Try the get-pip.py from the github repository as a secondary source
|
# Try the get-pip.py from the github repository as a primary source
|
||||||
curl --silent https://raw.github.com/pypa/pip/master/contrib/get-pip.py > /opt/get-pip.py
|
curl --silent https://raw.githubusercontent.com/pypa/get-pip/master/get-pip.py > /opt/get-pip.py
|
||||||
if head -n 1 /opt/get-pip.py | grep python; then
|
if head -n 1 /opt/get-pip.py | grep python; then
|
||||||
python2 /opt/get-pip.py || python /opt/get-pip.py
|
python /opt/get-pip.py "pip>=${PIP_MAJOR_VERSION},<$((PIP_MAJOR_VERSION+1))"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user