install-kolla-openstack-roc.../deploy-multinode.sh
2026-06-13 13:34:20 +03:00

135 lines
4.2 KiB
Bash
Executable File

#!/usr/bin/env bash
set -xe # Added -e to stop execution if a command fails
# Defaults
FIRST_INTERFACE="${1:-enp1s0}"
# enentually will be physnet1 in open stack networks
EXTERNAL_INTERFACE="${2:-enp3s0}"
# this should not be pingable in the installtion
INTERNAL_IP="${3:-192.168.1.210}"
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
# 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 ---"
KOLLA_VENV="/opt/ansible-kolla-venv"
KOLLA_WORKING="/opt/ansible-kolla"
# 2. Virtual Environment Setup
source "${KOLLA_VENV}/bin/activate"
cd "${KOLLA_WORKING}"
# Install Ansible and Galaxy roles
kolla-ansible install-deps
kolla-genpwd
# 4. Patch globals.yml
GLOBALS_FILENAME="/etc/kolla/globals.yml"
enable_kolla_options() {
local globals_file="$1"
shift # Remove the first argument, leaving only the option names
local options=("$@")
for option in "${options[@]}"; do
echo "Enabling ${option}..."
# This regex looks for lines starting with #option: and replaces
# the entire line with the enabled version.
sed -i "s@^#${option}:.*@${option}: \"yes\"@g" "${globals_file}"
done
}
#openstack_release: "master"
sed -i "s@^#openstack_release:.*@openstack_release: \"2025.2\"@g" "${GLOBALS_FILENAME}"
# 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}"
# Define the services you want to toggle
SERVICES_TO_ENABLE=(
"enable_horizon"
"enable_neutron_fwaas"
"enable_neutron_qos"
"enable_cinder"
"enable_mariadb"
"enable_valkey"
"skip_cinder_backend_check"
"enable_cinder_backend_nfs"
"enable_cinder_backup"
)
# Call the function
enable_kolla_options "${GLOBALS_FILENAME}" "${SERVICES_TO_ENABLE[@]}"
#sed -i "s@^#enable_cinder_backend_nfs:.*@enable_cinder_backend_nfs: true@g" "${GLOBALS_FILENAME}"
#sed -i "s@^#enable_cinder_backend_lvm:.*@enable_cinder_backend_lvm: true@g" "${GLOBALS_FILENAME}"
#sed -i "s@^#cinder_volume_group:.*@cinder_volume_group: \"cinder-volumes\"@g" "${GLOBALS_FILENAME}"
#sed -i "s@^#enable_octavia:.*@enable_octavia: true@g" "${GLOBALS_FILENAME}"
sed -i "s@^cinder_backup_driver:.*@cinder_backup_driver: \"nfs\"@g" "${GLOBALS_FILENAME}"
sed -i "s@^cinder_backup_share:.*@cinder_backup_share: \"192.168.1.21:/os_data\"@g" "${GLOBALS_FILENAME}"
OCTAVIE_CERT_CONF=$(grep "octavia_certs_organizational_unit: Octavia" "${GLOBALS_FILENAME}" |wc -l)
if [ "${OCTAVIE_CERT_CONF}"-eq "0" ]
then
cat <<EOF >> "${GLOBALS_FILENAME}"
octavia_certs_country: IL
octavia_certs_state: Shomron
octavia_certs_organization: NgTech LTD
octavia_certs_organizational_unit: Octavia
EOF
fi
# 5. Deployment
kolla-ansible bootstrap-servers -i ./multinode
kolla-ansible octavia-certificates -i ./multinode
kolla-ansible prechecks -i ./multinode
# Since 2026.2
#kolla-ansible prechecks -i ./all-in-one --use-test-images
kolla-ansible deploy -i ./multinode
# 6. Post-Install
pip install python-openstackclient
kolla-ansible post-deploy -i ./multinode
echo "Deployment Complete. Credentials located in /etc/kolla/admin-openrc.sh"
deactivate
pip install -U pip
pip install python-openstackclient
set +xe