devops--openstack--lab/vm-1.kolla-ansible/provision/openstack-kolla.sh

88 lines
2.2 KiB
Bash
Raw Normal View History

2023-04-04 06:51:02 +00:00
#!/bin/sh
# Ref. https://docs.openstack.org/kolla-ansible/latest/user/quickstart.html
# Paranoia mode
set -e
set -u
##
## Install prerequisites
##
sudo apt install -y git python3-dev libffi-dev gcc libssl-dev ufw
sudo apt install -y git python3-pip python3-venv
# Create sudo user for openstack -- not needed (vagrant is the same)
# useradd -s /bin/bash -d /opt/stack -m stack
# chmod +x /opt/stack
# apt-get install sudo -y
# echo "stack ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/stack
##
## Create the virtual environment
##
KOLLA_VENV_PATH=$HOME/kolla-venv
python3 -m venv "$KOLLA_VENV_PATH"
. "$KOLLA_VENV_PATH/bin/activate"
pip install -U pip
pip install 'ansible>=4,<6'
##
## Install Kolla-ansible
##
pip install git+https://opendev.org/openstack/kolla-ansible@master
sudo mkdir -p /etc/kolla
sudo mkdir -p /etc/kolla/globals.d
sudo chown -R "$USER:$USER" /etc/kolla
cp -r "$KOLLA_VENV_PATH/share/kolla-ansible/etc_examples/kolla"/* /etc/kolla
cp "$KOLLA_VENV_PATH/share/kolla-ansible/ansible/inventory/all-in-one" .
kolla-ansible install-deps
kolla-genpwd
##
## Configure globals
##
IP_ADDR="$(ip addr show dev eth0 |sed -n '/inet / { s,.*inet ,, ; s,/.*,, ; s,\.[0-9]\+$,.250, ; p }')"
cat > /etc/kolla/globals.d/default.yml <<-MARK
kolla_base_distro: "debian"
openstack_tag_suffix: ""
network_interface: "eth0"
neutron_external_interface: "ext0"
kolla_internal_vip_address: "$IP_ADDR"
#
MARK
##
## Deploy
##
# create fake network interface
IFACE_FILE="$(mktemp)"
cat > "$IFACE_FILE"<<-MARK
auto ext0
iface ext0 inet manual
## Keep unconfigured for kolla
pre-up ip link add dev ext0 type dummy
pre-up ip link set state up dev ext0
pre-up ip link set state down dev ext0
post-down ip link del dev ext0
MARK
sudo chown root:root "$IFACE_FILE"
sudo mv "$IFACE_FILE" /etc/network/interfaces.d/ext0
sudo ifup ext0 || true
## systemctl restart networking
echo "== boostrap"
kolla-ansible -i ./all-in-one bootstrap-servers
echo "== prechecks"
kolla-ansible -i ./all-in-one prechecks
echo "== deploy"
kolla-ansible -i ./all-in-one deploy
pip install python-openstackclient -c https://releases.openstack.org/constraints/upper/master
# FIMXE: generate & show password
#