From 4650b270a083aee447332a31ebf8bc95bf6ccab5 Mon Sep 17 00:00:00 2001 From: Dmitry Tantsur Date: Wed, 12 Jun 2024 19:05:36 +0200 Subject: [PATCH] Install ansible inside a venv instead of globally Help reducing potential conflicts with metal3-dev-env. --- 01_install_requirements.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/01_install_requirements.sh b/01_install_requirements.sh index a300c5e80..25ca09b66 100755 --- a/01_install_requirements.sh +++ b/01_install_requirements.sh @@ -23,6 +23,8 @@ if [ -z "${METAL3_DEV_ENV}" ]; then popd fi +ANSIBLE_VENV="${WORKING_DIR}/venv" + # This must be aligned with the metal3-dev-env pinned version above, see # https://github.com/metal3-io/metal3-dev-env/blob/master/lib/common.sh export ANSIBLE_VERSION=${ANSIBLE_VERSION:-"5.9.0"} @@ -110,16 +112,18 @@ elif [[ $GOARCH == "x86_64" ]]; then GOARCH="amd64" fi +sudo python -m venv --system-site-packages "${ANSIBLE_VENV}" + # Also need the 3.9 version of netaddr for ansible.netcommon # and lxml for the pyxpath script -sudo python -m pip install netaddr lxml +"${ANSIBLE_VENV}/bin/pip" install netaddr lxml -sudo python -m pip install ansible=="${ANSIBLE_VERSION}" +"${ANSIBLE_VENV}/bin/pip" install ansible=="${ANSIBLE_VERSION}" pushd ${METAL3_DEV_ENV_PATH} -ansible-galaxy install -r vm-setup/requirements.yml -ansible-galaxy collection install --upgrade ansible.netcommon ansible.posix ansible.utils community.general -ANSIBLE_FORCE_COLOR=true ansible-playbook \ +"${ANSIBLE_VENV}/bin/ansible-galaxy" install -r vm-setup/requirements.yml +"${ANSIBLE_VENV}/bin/ansible-galaxy" install --upgrade ansible.netcommon ansible.posix ansible.utils community.general +ANSIBLE_FORCE_COLOR=true "${ANSIBLE_VENV}/bin/ansible-playbook" \ -e "working_dir=$WORKING_DIR" \ -e "virthost=$HOSTNAME" \ -e "go_version=$GO_VERSION" \