Use python version to set DEFAULT_PIP_ANSIBLE

Instead of assuming the python version based on the distro, we
check the python version. (Check borrowed from bifrost-cli)

This patch defaults to the newer ansible version, and if python
is old, we override it with the old ansible package.

This lets us install on the RHELatives like Alma and Rocky, which
the current check is preventing.

Change-Id: I47413eab8c5132ab3201b4c7197ec15c17d18e12
This commit is contained in:
Erik Berg 2024-12-01 13:03:46 +01:00
parent 2d6ccc2b32
commit 76f82acff8

View File

@ -5,11 +5,10 @@ set -euo pipefail
. $(dirname $0)/install-deps.sh
# NOTE(pas-ha) the above exports some useful variables like
# $PYTHON , $PIP and $VENV depending on venv install or not
source /etc/os-release
if [[ $ID == "centos" ]] || [[ $VERSION_CODENAME == "bullseye" ]]; then
DEFAULT_PIP_ANSIBLE='>=9,<10'
if ! python3 -c "import sys; assert sys.version_info >= (3, 10)" 2> /dev/null; then
DEFAULT_PIP_ANSIBLE='>=8,<9'
elif [[ $ID == "ubuntu" ]] || [[ $VERSION_CODENAME == "bookworm" ]] ; then
DEFAULT_PIP_ANSIBLE='>=9,<10'
fi
ANSIBLE_COLLECTIONS_REQ=${ANSIBLE_COLLECTIONS_REQ:-$(dirname $0)/../ansible-collections-requirements.yml}