Skip to content

Commit 4650b27

Browse files
committed
Install ansible inside a venv instead of globally
Help reducing potential conflicts with metal3-dev-env.
1 parent 3c655f4 commit 4650b27

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

01_install_requirements.sh

+9-5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ if [ -z "${METAL3_DEV_ENV}" ]; then
2323
popd
2424
fi
2525

26+
ANSIBLE_VENV="${WORKING_DIR}/venv"
27+
2628
# This must be aligned with the metal3-dev-env pinned version above, see
2729
# https://github.com/metal3-io/metal3-dev-env/blob/master/lib/common.sh
2830
export ANSIBLE_VERSION=${ANSIBLE_VERSION:-"5.9.0"}
@@ -110,16 +112,18 @@ elif [[ $GOARCH == "x86_64" ]]; then
110112
GOARCH="amd64"
111113
fi
112114

115+
sudo python -m venv --system-site-packages "${ANSIBLE_VENV}"
116+
113117
# Also need the 3.9 version of netaddr for ansible.netcommon
114118
# and lxml for the pyxpath script
115-
sudo python -m pip install netaddr lxml
119+
"${ANSIBLE_VENV}/bin/pip" install netaddr lxml
116120

117-
sudo python -m pip install ansible=="${ANSIBLE_VERSION}"
121+
"${ANSIBLE_VENV}/bin/pip" install ansible=="${ANSIBLE_VERSION}"
118122

119123
pushd ${METAL3_DEV_ENV_PATH}
120-
ansible-galaxy install -r vm-setup/requirements.yml
121-
ansible-galaxy collection install --upgrade ansible.netcommon ansible.posix ansible.utils community.general
122-
ANSIBLE_FORCE_COLOR=true ansible-playbook \
124+
"${ANSIBLE_VENV}/bin/ansible-galaxy" install -r vm-setup/requirements.yml
125+
"${ANSIBLE_VENV}/bin/ansible-galaxy" install --upgrade ansible.netcommon ansible.posix ansible.utils community.general
126+
ANSIBLE_FORCE_COLOR=true "${ANSIBLE_VENV}/bin/ansible-playbook" \
123127
-e "working_dir=$WORKING_DIR" \
124128
-e "virthost=$HOSTNAME" \
125129
-e "go_version=$GO_VERSION" \

0 commit comments

Comments
 (0)