diff --git a/releasenotes/notes/explicit-ansible-version-d4052b4900faba99.yaml b/releasenotes/notes/explicit-ansible-version-d4052b4900faba99.yaml new file mode 100644 index 000000000..0cbe7c3f5 --- /dev/null +++ b/releasenotes/notes/explicit-ansible-version-d4052b4900faba99.yaml @@ -0,0 +1,7 @@ +--- +upgrade: + - | + Define a default ansible version to install using DEFAULT_PIP_ANSIBLE + variable, but allow override it either using a schema understood by pip + using ANSIBLE_PIP_VERSION, or setting a local path or a remote url using + ANSIBLE_SOURCE_PATH. \ No newline at end of file diff --git a/scripts/ansible-pip-str.py b/scripts/ansible-pip-str.py deleted file mode 100644 index 45d1a9a6a..000000000 --- a/scripts/ansible-pip-str.py +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/env python - -# Copyright (c) 2017 Mirantis 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. - -"""Helper script to choose which ansible version to install for bifrost""" - -from __future__ import print_function -import sys - -import six - -in_str = sys.argv[1] -HELP_MSG = ("Unsupported version or format %s - " - "Supporting format [stable-]MAJ.MIN where MAJ.MIN is 1.9 or 2.x" - % in_str) - -if in_str.startswith('stable-'): - in_version = in_str.split('stable-')[1] -else: - if six.text_type(in_str[0]).isdecimal(): - print("ansible==%s" % in_str) - else: - print("ansible%s" % in_str) - sys.exit(0) - -if len(in_version) != 3 and in_version[1] != '.': - print(HELP_MSG) - sys.exit(1) -else: - maj_version = in_version[0] - try: - min_version = int(in_version[2]) - except ValueError: - print(HELP_MSG) - sys.exit(1) - -if maj_version == '1' and min_version == 9: - upper_bound = '2.0' -elif maj_version == '2': - upper_bound = '2.%i' % (min_version + 1) -else: - print(HELP_MSG) - sys.exit(1) - -print("ansible<%s" % upper_bound) diff --git a/scripts/env-setup.sh b/scripts/env-setup.sh index 4d4e21316..fe7c515b8 100755 --- a/scripts/env-setup.sh +++ b/scripts/env-setup.sh @@ -5,15 +5,16 @@ set -eu # NOTE(pas-ha) the above exports some useful variables like # $PYTHON , $PIP and $VENV depending on venv install or not -ANSIBLE_PIP_VERSION=${ANSIBLE_PIP_VERSION:-${ANSIBLE_GIT_BRANCH:-stable-2.8}} +DEFAULT_PIP_ANSIBLE='!=2.8.9,<2.9' -ANSIBLE_PIP_STRING=$(${PYTHON} $(dirname $0)/ansible-pip-str.py ${ANSIBLE_PIP_VERSION}) +ANSIBLE_PIP_VERSION=${ANSIBLE_PIP_VERSION:-${DEFAULT_PIP_ANSIBLE}} +ANSIBLE_SOURCE_PATH=${ANSIBLE_SOURCE_PATH:-ansible${ANSIBLE_PIP_VERSION}} if [ -n "${VENV-}" ]; then - sudo ${PIP} install --ignore-installed "${ANSIBLE_PIP_STRING}" + sudo ${PIP} install --ignore-installed "${ANSIBLE_SOURCE_PATH}" ANSIBLE=${VENV}/bin/ansible else - ${PIP} install --user --upgrade "${ANSIBLE_PIP_STRING}" + ${PIP} install --user --upgrade "${ANSIBLE_SOURCE_PATH}" ANSIBLE=${HOME}/.local/bin/ansible fi