98 lines
3.0 KiB
Bash
Executable File
98 lines
3.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -xe # Added -e to stop execution if a command fails
|
|
|
|
|
|
# Defaults
|
|
FIRST_INTERFACE="${1:-enp1s0}"
|
|
EXTERNAL_INTERFACE="${2:-enp3s0}"
|
|
|
|
# this should not be pingable in the installtion
|
|
INTERNAL_IP="${3:-192.168.220.245}"
|
|
|
|
echo "--- Running Pre-flight Checks ---"
|
|
|
|
# 1. Check if the user is root
|
|
if [[ $EUID -ne 0 ]]; then
|
|
echo "ERROR: This script must be run as root (use sudo)."
|
|
exit 1
|
|
fi
|
|
|
|
# 2. Check if the network interfaces actually exist
|
|
for iface in "$FIRST_INTERFACE" "$EXTERNAL_INTERFACE"; do
|
|
if ! ip link show "$iface" > /dev/null 2>&1; then
|
|
echo "ERROR: Interface $iface not found. Check your 'ip link' output."
|
|
exit 1
|
|
fi
|
|
done
|
|
|
|
# 3. Ensure the VIP is NOT pingable (must be free)
|
|
echo "Checking if VIP $INTERNAL_IP is available..."
|
|
if ping -c 1 -W 1 "$INTERNAL_IP" > /dev/null 2>&1; then
|
|
echo "ERROR: VIP $INTERNAL_IP is already responding to pings!"
|
|
echo "Choose an unused IP in the same subnet as $FIRST_INTERFACE."
|
|
exit 1
|
|
fi
|
|
|
|
# 4. Check for enough RAM (Kolla-Ansible usually needs 8GB+ for All-in-One)
|
|
TOTAL_RAM=$(free -g | awk '/^Mem:/{print $2}')
|
|
if [ "$TOTAL_RAM" -lt 8 ]; then
|
|
echo "WARNING: You only have ${TOTAL_RAM}GB of RAM. OpenStack might be very slow or fail to deploy."
|
|
fi
|
|
|
|
echo "--- Pre-flight Checks Passed! Starting Installation ---"
|
|
|
|
|
|
# 1. Install System Dependencies
|
|
dnf install -y git python3-devel libffi-devel gcc openssl-devel python3-libselinux
|
|
|
|
KOLLA_VENV="/opt/ansible-kolla-venv"
|
|
KOLLA_WORKING="/opt/ansible-kolla"
|
|
|
|
mkdir -p "${KOLLA_VENV}" "${KOLLA_WORKING}" /etc/kolla
|
|
|
|
# 2. Virtual Environment Setup
|
|
python3 -m venv "${KOLLA_VENV}"
|
|
source "${KOLLA_VENV}/bin/activate"
|
|
|
|
pip install -U pip
|
|
pip install git+https://opendev.org/openstack/kolla-ansible@master
|
|
|
|
# 3. Configuration Setup
|
|
cp -r ${KOLLA_VENV}/share/kolla-ansible/etc_examples/kolla/* /etc/kolla
|
|
cd "${KOLLA_WORKING}"
|
|
cp ${KOLLA_VENV}/share/kolla-ansible/ansible/inventory/all-in-one .
|
|
|
|
# Install Ansible and Galaxy roles
|
|
kolla-ansible install-deps
|
|
kolla-genpwd
|
|
|
|
# 4. Patch globals.yml
|
|
GLOBALS_FILENAME="/etc/kolla/globals.yml"
|
|
|
|
# Note: Using @ as delimiter to avoid issues with potential paths
|
|
sed -i "s@^#kolla_base_distro:.*@kolla_base_distro: \"rocky\"@g" "${GLOBALS_FILENAME}"
|
|
sed -i "s@^#network_interface:.*@network_interface: \"${FIRST_INTERFACE}\"@g" "${GLOBALS_FILENAME}"
|
|
sed -i "s@^#neutron_external_interface:.*@neutron_external_interface: \"${EXTERNAL_INTERFACE}\"@g" "${GLOBALS_FILENAME}"
|
|
sed -i "s@^#kolla_internal_vip_address:.*@kolla_internal_vip_address: \"${INTERNAL_IP}\"@g" "${GLOBALS_FILENAME}"
|
|
|
|
# Enable Keystone/Horizon by default (often needed for a working UI)
|
|
sed -i "s@^#enable_horizon:.*@enable_horizon: \"yes\"@g" "${GLOBALS_FILENAME}"
|
|
|
|
# 5. Deployment
|
|
kolla-ansible bootstrap-servers -i ./all-in-one
|
|
kolla-ansible prechecks -i ./all-in-one
|
|
kolla-ansible deploy -i ./all-in-one
|
|
|
|
# 6. Post-Install
|
|
pip install python-openstackclient
|
|
kolla-ansible post-deploy -i ./all-in-one
|
|
|
|
echo "Deployment Complete. Credentials located in /etc/kolla/admin-openrc.sh"
|
|
deactivate
|
|
|
|
pip install -U pip
|
|
pip install python-openstackclient
|
|
|
|
set +xe
|