Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install ansible inside a venv instead of globally #1663

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions 01_install_requirements.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if [ -z "${METAL3_DEV_ENV}" ]; then
# TODO -- come up with a plan for continuously updating this
# Note we only do this in the case where METAL3_DEV_ENV is
# unset, to enable developer testing of local checkouts
git reset a994b1447f89e20ec9cc161700a9e829fd5d4b89 --hard
git reset d9fc324e8a37935b6c1b4555b5a8724b29626259 --hard
popd
fi

Expand Down Expand Up @@ -113,16 +113,15 @@ elif [[ $GOARCH == "x86_64" ]]; then
GOARCH="amd64"
fi

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

sudo python -m pip install ansible=="${ANSIBLE_VERSION}"
# Also need the 3.9 version of netaddr for ansible.netcommon
"${ANSIBLE_VENV}/bin/pip" install netaddr 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}-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" \
-e "working_dir=$WORKING_DIR" \
-e "virthost=$HOSTNAME" \
-e "go_version=$GO_VERSION" \
Expand All @@ -146,6 +145,9 @@ if [[ "${NODES_PLATFORM}" == "baremetal" ]] ; then
sudo dnf -y install ipmitool
fi

# lxml is needed for our pyxpath tool
sudo dnf -y install python3-lxml

# We use yq in a few places for processing YAML but it isn't packaged
# for CentOS/RHEL so we have to install from pip. We do not want to
# overwrite an existing installation of the golang version, though,
Expand Down
4 changes: 2 additions & 2 deletions 02_configure_host.sh
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ if [[ $(uname -m) == "aarch64" ]]; then
echo "libvirt_cdrombus: scsi" >> vm_setup_vars.yml
fi

ansible-playbook \
"${ANSIBLE}-playbook" \
-e @vm_setup_vars.yml \
-e "ironic_prefix=${CLUSTER_NAME}_" \
-e "cluster_name=${CLUSTER_NAME}" \
Expand Down Expand Up @@ -327,7 +327,7 @@ if [[ "$(ipversion $PROVISIONING_HOST_IP)" == "6" ]]; then
IPTABLES=ip6tables
fi

ANSIBLE_FORCE_COLOR=true ansible-playbook \
ANSIBLE_FORCE_COLOR=true "${ANSIBLE}-playbook" \
-e "{use_firewalld: True}" \
-e "provisioning_interface=$PROVISIONING_NETWORK_NAME" \
-e "external_interface=$BAREMETAL_NETWORK_NAME" \
Expand Down
2 changes: 1 addition & 1 deletion agent/05_agent_configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ function generate_cluster_manifests() {
set -x

# Create manifests
ansible-playbook -vvv \
"${ANSIBLE}-playbook" -vvv \
-e install_path=${SCRIPTDIR}/${INSTALL_CONFIG_PATH} \
"${SCRIPTDIR}/agent/create-manifests-playbook.yaml"
}
Expand Down
2 changes: 2 additions & 0 deletions common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ export PROVISIONING_HOST_USER=${PROVISIONING_HOST_USER:-$USER}
# The dev-scripts working directory
export WORKING_DIR=${WORKING_DIR:-"/opt/dev-scripts"}
OCP_DIR=${OCP_DIR:-ocp/${CLUSTER_NAME}}
ANSIBLE_VENV=${ANSIBLE_VENV:-"${WORKING_DIR}/venv"}
ANSIBLE="${ANSIBLE_VENV}/bin/ansible"

# The DNS name for the registry that this cluster should use.
export LOCAL_REGISTRY_DNS_NAME=${LOCAL_REGISTRY_DNS_NAME:-"virthost.${CLUSTER_NAME}.${BASE_DOMAIN}"}
Expand Down
2 changes: 1 addition & 1 deletion host_cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fi

export ANSIBLE_FORCE_COLOR=true

ansible-playbook \
"${ANSIBLE}-playbook" \
-e @vm_setup_vars.yml \
-e "ironic_prefix=${CLUSTER_NAME}_" \
-e "cluster_name=${CLUSTER_NAME}" \
Expand Down
2 changes: 1 addition & 1 deletion network.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function nth_ip() {
network=$1
idx=$2

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

function ipversion(){
Expand Down
2 changes: 1 addition & 1 deletion remote_nodes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function playbook() {
VIRTBMC_ACTION="ignore"
fi

ansible-playbook \
"${ANSIBLE}-playbook" \
-e @vm_setup_vars.yml \
-e "ironic_prefix=${REMOTE_CLUSTER_NAME}_" \
-e "cluster_name=${REMOTE_CLUSTER_NAME}" \
Expand Down
2 changes: 1 addition & 1 deletion utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ function write_pull_secret() {

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