This commit is contained in:
Eliezer Croitoru 2026-02-25 01:04:36 +02:00
commit 3b30ae7d1c
3 changed files with 188 additions and 0 deletions

18
cleanup-local.sh Normal file
View File

@ -0,0 +1,18 @@
#!/usr/bin/env bash
bash clear_docker.sh
# Remove Open vSwitch bridges
ovs-vsctl list-br | xargs -L1 ovs-vsctl del-br 2>/dev/null
# Remove any remaining veth pairs or bridges
ip link delete neutron-filter 2>/dev/null
ip link delete br-ex 2>/dev/null
ip link delete br-int 2>/dev/null
rm -rvf /etc/kolla
rm -rvf /etc/systemd/system/kolla-*
rm -rvf /opt/ansible-kolla
rm -rvf /opt/ansible-kolla-venv
systemctl daemon-reload

73
clear_docker.sh Normal file
View File

@ -0,0 +1,73 @@
#!/bin/bash
#Function to check if there are containers running
function check_containers() {
if [ "$(docker ps -q)" ]; then
return 0 # Containers found
else
return 1 # No containers found
fi
}
#Function to check if there are images available
function check_images() {
if [ "$(docker images -q)" ]; then
return 0 # Images found
else
return 1 # No images found
fi
}
#Function to check if there are volumes
function check_volumes() {
if [ "$(docker volume ls -q)" ]; then
return 0 # Volumes found
else
return 1 # No volumes found
fi
}
# Stopping and removing containers
if check_containers; then
echo "Stopping and removing containers..."
docker stop $(docker ps -qa)
docker rm $(docker ps -qa)
else
echo "No containers to remove."
fi
echo "*************************************************"
#Removing images
if check_images; then
echo "Removing images..."
docker rmi $(docker images -qa)
else
echo "No images to remove."
fi
echo "*************************************************"
#Removing volumes
if check_volumes; then
echo "Removing volumes..."
docker volume rm $(docker volume ls -q)
else
echo "No volumes to remove."
fi
echo "*************************************************"
docker_dir="/var/lib/docker"
if ls "$docker_dir"/*/ > /dev/null 2>&1; then
echo "Removing contents of directories under $docker_dir"
for dir in "$docker_dir"/*/; do
# Skip if the entry is not a directory
if [[ ! -d "$dir" ]]; then
continue
fi
echo "Removing contents of $dir"
rm -rf "$dir"*
done
else
echo "No directories to remove contents from."
fi
echo "*************************************************"
#Remove temporary files
rm -rf /tmp/*
echo "Removed temporary files"
#Stop and start docker daemon to prevent this error "failed to register layer"
service docker stop
service docker start
echo "Docker Daemon restarted"

97
install.sh Executable file
View File

@ -0,0 +1,97 @@
#!/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
echo "Deployment Complete. Credentials located in /etc/kolla/admin-openrc.sh"
deactivate
pip install -U pip
pip install python-openstackclient
set +xe