Initial import

This commit is contained in:
Glenn Y. Rolland 2023-04-04 08:51:02 +02:00
commit 8fcff30122
11 changed files with 248 additions and 0 deletions

4
.gitignore vendored Normal file
View file

@ -0,0 +1,4 @@
.vagrant
/slides/autoslide.md
tmp
/_*

View file

@ -0,0 +1,4 @@
zip:
zip -r kubernetes--lab.zip Vagrantfile provision.sh

View file

@ -0,0 +1,5 @@
# Other
* https://opendev.org/openstack/devstack-vagrant

36
vagrant--devstack/Vagrantfile vendored Normal file
View file

@ -0,0 +1,36 @@
# vim: set ts=2 sw=2 et ft=ruby:
# frozen_string_literal: true
Vagrant.configure('2') do |config|
config.vm.box = 'debian/bullseye64'
config.vm.provider 'libvirt' do |domain|
domain.memory = 18_000
domain.nested = true
domain.cpus = 2
end
config.vm.provider 'virtualbox' do |vb|
vb.gui = false
vb.memory = 18_000.to_s
# vb.nested = true
vb.customize ['modifyvm', :id, '--nested-hw-virt', 'on']
end
# config.vm.synced_folder "..", "/vagrant" #, type: "nfs", mount_options: ['actimeo=2']
# config.vm.synced_folder "../../exercises", "/vagrant/exercises" #, type: "nfs", mount_options: ['actimeo=2']
# config.vm.synced_folder "../../config", "/vagrant/config" #, type: "nfs", mount_options: ['actimeo=2']
config.vm.define 'control' do |machine|
machine.vm.hostname = 'control'
[3000, 4000, 5000, 8000, 8080].each do |port|
machine.vm.network 'forwarded_port', guest: port, host: port, host_ip: '127.0.0.1'
end
machine.vm.network 'forwarded_port', guest: 80, host: 1080, host_ip: '127.0.0.1'
end
config.vm.provision 'shell', name: 'provision/base', path: 'provision/base.sh', privileged: true
config.vm.provision 'shell', name: 'provision/openstack', path: 'provision/openstack.sh', privileged: false
config.vm.provision 'shell', inline: 'echo "SUCCESS"'
end

View file

@ -0,0 +1,15 @@
#!/bin/sh
echo "Installing required system packages"
apt-get update -qq --allow-releaseinfo-change
apt-get install -qq -y \
apt-transport-https \
ca-certificates \
git \
curl \
wget \
vim \
gnupg2 \
fzf \
software-properties-common

View file

@ -0,0 +1,37 @@
#!/bin/sh
# 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
##
## Install prerequisites
##
sudo apt-get install -y git
##
## Get openstack
##
git clone https://opendev.org/openstack/devstack
cd devstack || exit 1
##
## Create configuration
##
cat > local.conf <<-MARK
[[local|localrc]]
FLOATING_RANGE=192.168.1.224/27
FIXED_RANGE=10.11.12.0/24
ADMIN_PASSWORD=admin1pass
DATABASE_PASSWORD=database2pass
RABBIT_PASSWORD=rabbit3pass
SERVICE_PASSWORD=service4pass
MARK
##
## Run devstack
##
./stack.sh

View file

@ -0,0 +1,4 @@
zip:
zip -r kubernetes--lab.zip Vagrantfile provision.sh

View file

@ -0,0 +1,5 @@
# Other
* https://opendev.org/openstack/devstack-vagrant

36
vagrant--kolla-ansible/Vagrantfile vendored Normal file
View file

@ -0,0 +1,36 @@
# vim: set ts=2 sw=2 et ft=ruby:
# frozen_string_literal: true
Vagrant.configure('2') do |config|
config.vm.box = 'debian/bullseye64'
config.vm.provider 'libvirt' do |domain|
domain.memory = 18_000
domain.nested = true
domain.cpus = 2
end
config.vm.provider 'virtualbox' do |vb|
vb.gui = false
vb.memory = 18_000.to_s
# vb.nested = true
vb.customize ['modifyvm', :id, '--nested-hw-virt', 'on']
end
# config.vm.synced_folder "..", "/vagrant" #, type: "nfs", mount_options: ['actimeo=2']
# config.vm.synced_folder "../../exercises", "/vagrant/exercises" #, type: "nfs", mount_options: ['actimeo=2']
# config.vm.synced_folder "../../config", "/vagrant/config" #, type: "nfs", mount_options: ['actimeo=2']
config.vm.define 'control' do |machine|
machine.vm.hostname = 'control'
[3000, 4000, 5000, 8000, 8080].each do |port|
machine.vm.network 'forwarded_port', guest: port, host: port, host_ip: '127.0.0.1'
end
machine.vm.network 'forwarded_port', guest: 80, host: 1080, host_ip: '127.0.0.1'
end
config.vm.provision 'shell', name: 'provision/base', path: 'provision/base.sh', privileged: true
config.vm.provision 'shell', name: 'provision/openstack-kolla', path: 'provision/openstack-kolla.sh', privileged: false
config.vm.provision 'shell', inline: 'echo "SUCCESS"'
end

View file

@ -0,0 +1,15 @@
#!/bin/sh
echo "Installing required system packages"
apt-get update -qq --allow-releaseinfo-change
apt-get install -qq -y \
apt-transport-https \
ca-certificates \
git \
curl \
wget \
vim \
gnupg2 \
fzf \
software-properties-common

View file

@ -0,0 +1,87 @@
#!/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
#