Skip to content

Commit

Permalink
Install ansible inside a venv instead of globally
Browse files Browse the repository at this point in the history
Help reducing potential conflicts with metal3-dev-env.
  • Loading branch information
dtantsur committed Jun 12, 2024
1 parent 3c655f4 commit 4650b27
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions 01_install_requirements.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Expand Down Expand Up @@ -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" \
Expand Down

0 comments on commit 4650b27

Please sign in to comment.