Skip to content

Commit e4ce1b8

Browse files
committed
Install ansible inside a venv instead of globally
Help reducing potential conflicts with metal3-dev-env.
1 parent 94fc4df commit e4ce1b8

8 files changed

+19
-15
lines changed

01_install_requirements.sh

+10-8
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ if [ -z "${METAL3_DEV_ENV}" ]; then
1919
# TODO -- come up with a plan for continuously updating this
2020
# Note we only do this in the case where METAL3_DEV_ENV is
2121
# unset, to enable developer testing of local checkouts
22-
git reset a994b1447f89e20ec9cc161700a9e829fd5d4b89 --hard
22+
git reset d9fc324e8a37935b6c1b4555b5a8724b29626259 --hard
2323
popd
2424
fi
2525

@@ -113,16 +113,15 @@ elif [[ $GOARCH == "x86_64" ]]; then
113113
GOARCH="amd64"
114114
fi
115115

116-
# Also need the 3.9 version of netaddr for ansible.netcommon
117-
# and lxml for the pyxpath script
118-
sudo python -m pip install netaddr lxml
116+
sudo python -m venv --system-site-packages "${ANSIBLE_VENV}"
119117

120-
sudo python -m pip install ansible=="${ANSIBLE_VERSION}"
118+
# Also need the 3.9 version of netaddr for ansible.netcommon
119+
"${ANSIBLE_VENV}/bin/pip" install netaddr ansible=="${ANSIBLE_VERSION}"
121120

122121
pushd ${METAL3_DEV_ENV_PATH}
123-
ansible-galaxy install -r vm-setup/requirements.yml
124-
ansible-galaxy collection install --upgrade ansible.netcommon ansible.posix ansible.utils community.general
125-
ANSIBLE_FORCE_COLOR=true ansible-playbook \
122+
"${ANSIBLE}-galaxy" install -r vm-setup/requirements.yml
123+
"${ANSIBLE}-galaxy" collection install --upgrade ansible.netcommon ansible.posix ansible.utils community.general
124+
ANSIBLE_FORCE_COLOR=true "${ANSIBLE}-playbook" \
126125
-e "working_dir=$WORKING_DIR" \
127126
-e "virthost=$HOSTNAME" \
128127
-e "go_version=$GO_VERSION" \
@@ -146,6 +145,9 @@ if [[ "${NODES_PLATFORM}" == "baremetal" ]] ; then
146145
sudo dnf -y install ipmitool
147146
fi
148147

148+
# lxml is needed for our pyxpath tool
149+
sudo dnf -y install python3-lxml
150+
149151
# We use yq in a few places for processing YAML but it isn't packaged
150152
# for CentOS/RHEL so we have to install from pip. We do not want to
151153
# overwrite an existing installation of the golang version, though,

02_configure_host.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ if [[ $(uname -m) == "aarch64" ]]; then
127127
echo "libvirt_cdrombus: scsi" >> vm_setup_vars.yml
128128
fi
129129

130-
ansible-playbook \
130+
"${ANSIBLE}-playbook" \
131131
-e @vm_setup_vars.yml \
132132
-e "ironic_prefix=${CLUSTER_NAME}_" \
133133
-e "cluster_name=${CLUSTER_NAME}" \
@@ -327,7 +327,7 @@ if [[ "$(ipversion $PROVISIONING_HOST_IP)" == "6" ]]; then
327327
IPTABLES=ip6tables
328328
fi
329329

330-
ANSIBLE_FORCE_COLOR=true ansible-playbook \
330+
ANSIBLE_FORCE_COLOR=true "${ANSIBLE}-playbook" \
331331
-e "{use_firewalld: True}" \
332332
-e "provisioning_interface=$PROVISIONING_NETWORK_NAME" \
333333
-e "external_interface=$BAREMETAL_NETWORK_NAME" \

agent/05_agent_configure.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ function generate_cluster_manifests() {
263263
set -x
264264

265265
# Create manifests
266-
ansible-playbook -vvv \
266+
"${ANSIBLE}-playbook" -vvv \
267267
-e install_path=${SCRIPTDIR}/${INSTALL_CONFIG_PATH} \
268268
"${SCRIPTDIR}/agent/create-manifests-playbook.yaml"
269269
}

common.sh

+2
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ export PROVISIONING_HOST_USER=${PROVISIONING_HOST_USER:-$USER}
9494
# The dev-scripts working directory
9595
export WORKING_DIR=${WORKING_DIR:-"/opt/dev-scripts"}
9696
OCP_DIR=${OCP_DIR:-ocp/${CLUSTER_NAME}}
97+
ANSIBLE_VENV=${ANSIBLE_VENV:-"${WORKING_DIR}/venv"}
98+
ANSIBLE="${ANSIBLE_VENV}/bin/ansible"
9799

98100
# The DNS name for the registry that this cluster should use.
99101
export LOCAL_REGISTRY_DNS_NAME=${LOCAL_REGISTRY_DNS_NAME:-"virthost.${CLUSTER_NAME}.${BASE_DOMAIN}"}

host_cleanup.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fi
1515

1616
export ANSIBLE_FORCE_COLOR=true
1717

18-
ansible-playbook \
18+
"${ANSIBLE}-playbook" \
1919
-e @vm_setup_vars.yml \
2020
-e "ironic_prefix=${CLUSTER_NAME}_" \
2121
-e "cluster_name=${CLUSTER_NAME}" \

network.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function nth_ip() {
66
network=$1
77
idx=$2
88

9-
python -c "from ansible_collections.ansible.utils.plugins.filter import nthhost; print(nthhost.nthhost('"$network"', $idx))"
9+
"${ANSIBLE_VENV}/bin/python" -c "from ansible_collections.ansible.utils.plugins.filter import nthhost; print(nthhost.nthhost('"$network"', $idx))"
1010
}
1111

1212
function ipversion(){

remote_nodes.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function playbook() {
6868
VIRTBMC_ACTION="ignore"
6969
fi
7070

71-
ansible-playbook \
71+
"${ANSIBLE}-playbook" \
7272
-e @vm_setup_vars.yml \
7373
-e "ironic_prefix=${REMOTE_CLUSTER_NAME}_" \
7474
-e "cluster_name=${REMOTE_CLUSTER_NAME}" \

utils.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ function write_pull_secret() {
787787

788788
function switch_to_internal_dns() {
789789
sudo mkdir -p /etc/NetworkManager/conf.d/
790-
ansible localhost -b -m ini_file -a "path=/etc/NetworkManager/conf.d/dnsmasq.conf section=main option=dns value=dnsmasq"
790+
"${ANSIBLE}" localhost -b -m ini_file -a "path=/etc/NetworkManager/conf.d/dnsmasq.conf section=main option=dns value=dnsmasq"
791791
if [ "$ADDN_DNS" ] ; then
792792
echo "server=$ADDN_DNS" | sudo tee /etc/NetworkManager/dnsmasq.d/upstream.conf
793793
fi

0 commit comments

Comments
 (0)