Merge "Consolidate env-setup"

This commit is contained in:
Zuul 2020-08-05 09:40:51 +00:00 committed by Gerrit Code Review
commit 478e03ab5e

View File

@ -7,16 +7,20 @@ set -eu
DEFAULT_PIP_ANSIBLE='>=2.9,<2.10' DEFAULT_PIP_ANSIBLE='>=2.9,<2.10'
ANSIBLE_PIP_VERSION=${ANSIBLE_PIP_VERSION:-${DEFAULT_PIP_ANSIBLE}} ANSIBLE_COLLECTION_REQ=${ANSIBLE_COLLECTION_REQ:-$(dirname $0)/../ansible-collection-requirements.yml}
ANSIBLE_SOURCE_PATH=${ANSIBLE_SOURCE_PATH:-ansible${ANSIBLE_PIP_VERSION}}
ANSIBLE_COLLECTION_SOURCE_PATH= ANSIBLE_COLLECTION_SOURCE_PATH=
if [[ -d "${WORKSPACE:-}/openstack/ansible-collections-openstack" ]]; then if [[ -d "${WORKSPACE:-}/openstack/ansible-collections-openstack" ]]; then
ANSIBLE_COLLECTION_SOURCE_PATH="${WORKSPACE}/openstack/ansible-collections-openstack" ANSIBLE_COLLECTION_SOURCE_PATH="${WORKSPACE}/openstack/ansible-collections-openstack"
fi fi
ANSIBLE_COLLECTION_REQ=${ANSIBLE_COLLECTION_REQ:-$(dirname $0)/../ansible-collection-requirements.yml} ANSIBLE_INSTALL_ROOT=${ANSIBLE_INSTALL_ROOT:-/opt/stack}
BIFROST_COLLECTIONS_PATHS=${ANSIBLE_COLLECTIONS_PATHS:-} ANSIBLE_PIP_VERSION=${ANSIBLE_PIP_VERSION:-${DEFAULT_PIP_ANSIBLE}}
ANSIBLE_SOURCE_PATH=${ANSIBLE_SOURCE_PATH:-ansible${ANSIBLE_PIP_VERSION}}
if [ -n "${VENV-}" ]; then BIFROST_COLLECTIONS_PATHS=${ANSIBLE_COLLECTIONS_PATHS:-}
PLAYBOOKS_LIBRARY_PATH=$(dirname $0)/../playbooks/library
if [[ -n "${VENV-}" ]]; then
${PIP} install "${ANSIBLE_SOURCE_PATH}" ${PIP} install "${ANSIBLE_SOURCE_PATH}"
ANSIBLE=${VENV}/bin/ansible ANSIBLE=${VENV}/bin/ansible
ANSIBLE_GALAXY=${VENV}/bin/ansible-galaxy ANSIBLE_GALAXY=${VENV}/bin/ansible-galaxy
@ -35,21 +39,17 @@ else
ANSIBLE_GALAXY=${HOME}/.local/bin/ansible-galaxy ANSIBLE_GALAXY=${HOME}/.local/bin/ansible-galaxy
fi fi
PLAYBOOKS_LIBRARY_PATH=$(dirname $0)/../playbooks/library
# NOTE(pas-ha) the following is a temporary workaround for third-party CI # NOTE(pas-ha) the following is a temporary workaround for third-party CI
# scripts that try to source Ansible's hacking/env-setup # scripts that try to source Ansible's hacking/env-setup
# after running this very script # after running this very script
# TODO(pas-ha) remove after deprecation (in Pike?) and when third-party CIs # TODO(pas-ha) remove after deprecation (in Pike?) and when third-party CIs
# (in particular OPNFV) are fixed # (in particular OPNFV) are fixed
ANSIBLE_INSTALL_ROOT=${ANSIBLE_INSTALL_ROOT:-/opt/stack} ANSIBLE_USER=$(id -nu)
u=$(whoami) ANSIBLE_GROUP=$(id -ng)
g=$(groups | awk '{print $1}') if [[ ! -d ${ANSIBLE_INSTALL_ROOT} ]]; then
if [ ! -d ${ANSIBLE_INSTALL_ROOT} ]; then
mkdir -p ${ANSIBLE_INSTALL_ROOT} || (sudo mkdir -p ${ANSIBLE_INSTALL_ROOT}) mkdir -p ${ANSIBLE_INSTALL_ROOT} || (sudo mkdir -p ${ANSIBLE_INSTALL_ROOT})
fi fi
sudo -H chown -R $u:$g ${ANSIBLE_INSTALL_ROOT} sudo -H chown -R ${ANSIBLE_USER}:${ANSIBLE_GROUP} ${ANSIBLE_INSTALL_ROOT}
# Install Collections # Install Collections
if [[ -n "$ANSIBLE_COLLECTION_SOURCE_PATH" ]]; then if [[ -n "$ANSIBLE_COLLECTION_SOURCE_PATH" ]]; then
@ -72,7 +72,7 @@ fi
echo echo
echo "To use bifrost, do" echo "To use bifrost, do"
if [ -n "${VENV-}" ]; then if [[ -n "${VENV-}" ]]; then
echo "source ${VENV}/bin/activate" echo "source ${VENV}/bin/activate"
else else
echo "Prepend ~/.local/bin to your PATH if it is not that way already.." echo "Prepend ~/.local/bin to your PATH if it is not that way already.."