Install OpenStack with Kolla-ansible under Ubuntu

Docu
https://docs.openstack.org/releasenotes/kolla-ansible/
https://docs.openstack.org/project-deploy-guide/kolla-ansible/latest/quickstart.html
https://docs.openstack.org/kolla-ansible/latest/reference/index.html

Repository
https://github.com/openstack/kolla-ansible
# global kolla-ansible configuration file
https://github.com/openstack/kolla-ansible/blob/master/etc/kolla/globals.yml

Install all-in-one

apt-get install python-dev libffi-dev gcc libssl-dev python-selinux python-setuptools ansible pip
pip install kolla-ansible
#pip install -r requirements.txt
#python setup.py install
cp -r /usr/local/share/kolla-ansible/etc_examples/kolla /etc/
cp /usr/local/share/kolla-ansible/ansible/inventory/* .
kolla-genpwd
cp /etc/kolla/globals.yml{,org}
vi /etc/kolla/globals.yml
sed -i 's|#kolla_base_distro: "centos"|kolla_base_distro: "ubuntu"|g' /etc/kolla/globals.yml
sed -i 's|#kolla_install_type: "binary"|kolla_install_type: "source"|g' /etc/kolla/globals.yml
sed -i 's|#openstack_release: ""|openstack_release: "queens"|g' /etc/kolla/globals.yml
sed -i 's|kolla_internal_vip_address: "10.10.10.254"|kolla_internal_vip_address: "192.168.1.111"|g' /etc/kolla/globals.yml
sed -i 's|#network_interface: "eth0"|network_interface: "eth0"|g' /etc/kolla/globals.yml
sed -i 's|#neutron_external_interface: "eth1"|neutron_external_interface: "eth1"|g' /etc/kolla/globals.yml
cp /usr/local/share/kolla-ansible/ansible/roles/baremetal/defaults/main.yml{,org}
vi /usr/local/share/kolla-ansible/ansible/roles/baremetal/defaults/main.yml
diff /usr/local/share/kolla-ansible/ansible/roles/baremetal/defaults/main.yml{,org}
kolla-ansible -i ./all-in-one bootstrap-servers
kolla-ansible -i ./all-in-one prechecks

Credentials

host: http://192.168.1.111/
user: admin
pass:
grep keystone_admin_password /etc/kolla/passwords.yml
 
# grep : /etc/kolla/passwords.yml | cut -d" " -f1 > /etc/kolla/passwords2.yml
grep : /opt/kolla-ansible/etc/kolla/passwords.yml > /etc/kolla/passwords.yml
kolla-genpwd -p /etc/kolla/passwords.yml
sed -i "s/keystone_admin_password: .*/keystone_admin_password: os-lab_1234/g" /etc/kolla/passwords.yml

QuickStart
https://docs.openstack.org/kolla-ansible/latest/user/quickstart.html

Directories

/usr/local/share/kolla-ansible

Log directory

/var/lib/docker/volumes/kolla_logs/_data
find /var/lib/docker/volumes/kolla_logs/ -ctime -1 | xargs tail -f {} \; | egrep -i "error|fail"

Ceph
https://docs.openstack.org/kolla-ansible/latest/reference/ceph-guide.html

docker exec -it ceph_mon ceph -s
docker exec -it ceph_mon ceph osd lspools
docker exec -it ceph_mon rados -p gnocchi ls

CLI

./kolla-ansible deploy-bifrost
/opt/stack/kolla-ansible/tools/cleanup-containers
/opt/stack/kolla-ansible/tools/cleanup-host
/opt/stack/kolla-ansible/cleanup-images

kolla-build

configuration file:
https://github.com/openstack/kolla/blob/master/kolla/common/config.py
 
# list pip application versions inside conatiner
CONTAINERS="
gnocchi_statsd
gnocchi_metricd
gnocchi_api
"
 
for CONTAINER in ${CONTAINERS}; do
    echo ${CONTAINER}
    docker exec -it ${CONTAINER} pip list | grep gnocchi
done

Openstack CLI

source foo-openrc.sh
openstack network list

Network namespaces / OpenSwitch

for ROUTER in $(ip netns | cut -d" " -f1 | sort); do
    echo ${ROUTER}
    ip netns exec ${ROUTER} ip a
#    ip netns exec ${ROUTER} ip r
#    ip netns exec ${ROUTER} ping -c 3 8.8.8.8
done
 
ip netns exec   qrouter-5e9b6862-8e5e-4ba8-9f03-064c5d938d27 ping 10.0.1.10

Default values kolla-ansible

/opt/stack/kolla-ansible/ansible/group_vars/all.yml

Deploy ceph keys

# ceph server
for i in $(ls /etc/ceph/*.keyring); do
    echo $i
    cat $i
    echo
done
 
# kolla-ansible server
find /etc/kolla -name *keyring
 
# copy keys
scp cephexample.com:/etc/ceph/client.cinder.keyring /etc/kolla/config/stage/cinder/cinder-volume/ceph.client.cinder.keyring
scp cephexample.com:/etc/ceph/client.cinder.keyring /etc/kolla/config/stage/cinder/cinder-backup/ceph.client.cinder.keyring
scp cephexample.com:/etc/ceph/client.client.cinder-backup.keyring /etc/kolla/config/stage/cinder/cinder-backup/ceph.client.cinder-backup.keyring
scp cephexample.com:/etc/ceph/client.cinder.keyring /etc/kolla/config/stage/nova/ceph.client.cinder.keyring
scp cephexample.com:/etc/ceph/client.nova.keyring /etc/kolla/config/stage/nova/ceph.client.nova.keyring
scp cephexample.com:/etc/ceph/client.gnocchi.keyring /etc/kolla/config/stage/gnocchi/ceph.client.gnocchi.keyring
scp cephexample.com:/etc/ceph/client.glance.keyring /etc/kolla/config/stage/glance/ceph.client.glance.keyring

config marge

/opt/stack/kolla-ansible/ansible/roles/glance/tasks/config.yml
...
- name: Copying over glance-*.conf
...
  merge_configs:
    sources:
      - "{{ role_path }}/templates/{{ item.key }}.conf.j2"
      - "{{ node_custom_config }}/global.conf"
      - "{{ node_custom_config }}/glance.conf"
      - "{{ node_custom_config }}/glance/{{ item.key }}.conf"
      - "{{ node_custom_config }}/glance/{{ inventory_hostname }}/{{ item.key }}.conf"
    dest: "{{ node_config_directory }}/{{ item.key }}/{{ item.key }}.conf"

RabbitMQ
http://ctl1.example.com:15672
Credentials:
ssh ctl1.example.com cat /etc/kolla/rabbitmq/definitions.json

Reconfigure

# get tags:
egrep -r neutro.*_tag /opt/stack/kolla-ansible/ | cut -d ":" -f2 | grep tag | sort
 
# https://docs.openstack.org/kolla-ansible/queens/user/operating-kolla.html
cd /etc/kolla/config/MY
kolla-ansible reconfigure -i inventory-dev -t octavia
 
# coe
openstack coe service list

Deploy specific service

cd /opt/kolla-ansible/tools
./kolla-ansible -i ../ansible/inventory/all-in-one deploy -t ceph

ceph
https://docs.openstack.org/kolla-ansible/rocky/reference/ceph-guide.html

cd /opt/kolla-ansible/tools
ansible -i ../ansible/inventory/all-in-one     -a 'docker volume rm ceph_mon_config'     ceph-mon
./kolla-ansible -i ../ansible/inventory/all-in-one deploy -t ceph
 
/etc/kolla/config/ceph.conf
[global]
osd pool default size = 1
osd pool default min size = 1
 
/sbin/parted /dev/sdc -s -- mklabel gpt mkpart KOLLA_CEPH_OSD_BOOTSTRAP_BS 1 -1
 
docker exec ceph_mon ceph -s
 
ls -l /dev/disk/by-partlabel/KOLLA_CEPH_OSD_BOOTSTRAP

configure networks

openstack network create --share --provider-physical-network physnet1 --external --default --disable-port-security --provider-network-type flat public
openstack subnet create --network public --allocation-pool start=10.0.4.100,end=10.0.4.200 --dns-nameserver 8.8.8.8 --gateway 10.0.4.1 --subnet-range 10.0.4.0/24 public-subnet
# --no-dhcp

Create Octavia certificate

#git clone https://github.com/openstack/octavia.git --branch "stable/stein" /opt/octavia/
git clone https://github.com/openstack/octavia.git --branch "stein-eol" /opt/octavia/
 
mkdir -p /etc/kolla/config/octavia
/opt/octavia/bin/create_certificates.sh /etc/kolla/config/octavia /opt/octavia/etc/certificates/openssl.cnf
ln -s /etc/kolla/config/octavia/private/cakey.pem /etc/kolla/config/octavia/
 
cd /opt/kolla-ansible/tools/
OCTAVIA_CA_PASSWORD=$(grep octavia_ca_password /etc/kolla/passwords.yml | cut -d" " -f2)
 
./kolla-ansible -i ../ansible/inventory/all-in-one deploy -t octavia

Kolla container
https://docs.openstack.org/kolla/newton/image-building.html
https://hub.docker.com/u/kolla

libvirt

ssh compute_node_x
docker exec -it nova_libvirt virsh list

openvswitch
http://www.panticz.de/openvswitch

Connect to libvirt console

docker exec -it nova_libvirt virsh console instance-00001234

List libvirt id and OpenStack UUID

for VM in $(docker exec -it nova_libvirt virsh list --name | sed "s/[^[:alnum:]-]//g"); do
    docker exec -it nova_libvirt virsh dominfo ${VM}
    echo
done

Adding compute node to an existing OpenStack installation

# List existing compute nodes
openstack compute service list
 
# Add compute node to inventory
vi /etc/kolla/inventory
[external-compute]
com4
...
 
# Deploy container on compute node
cd /etc/kolla/config/FOO
kolla-ansible -i inventory deploy --limit com4

Logrotate

# /var/lib/docker/volumes/kolla_logs/_data/
docker exec -t cron /usr/sbin/logrotate -f /etc/logrotate.conf

Run test

EXTRA_OPTS='--check --diff'
kolla-ansible -i /etc/kolla/inventory genconfig -t neutron

redis

docker ps -a | grep -v Up
mv redis-staging-ao.aof redis-staging-ao.aof.off
docker restart redis
 
tail -f /var/lib/docker/volumes/kolla_logs/_data/redis/redis.log

Snippents

# get all nodes
NODES=$(eval echo $(egrep "^dev-(ctl|com)" /etc/kolla/inventory | sed 's/\[/{/g;s/\]/}/g;s/\:/../g')  | xargs -n1 | sort -u)

Adding and removing hosts
https://review.opendev.org/plugins/gitiles/openstack/kolla-ansible/+/refs/changes/85/758085/1/doc/source/user/adding-and-removing-hosts.rst

Deploy with specific python version

export ANSIBLE_FORCE_COLOR=True
EXTRA_OPTS='--diff' kolla-ansible -i inventory reconfigure -t nova --limit com2-stage -e '{"ansible_python_interpreter":"python2","openvswitch_tag":"15.1.0.evw7"}' | tee -a ./log/com2-stage.nova.$(date -I).log 

Links
http://egonzalez.org/deploy-openstack-designate-with-kolla-ansible/
https://marcelwiget.wordpress.com/2016/08/14/kolla-openstack-in-docker-containers-with-ansible-playbooks/
http://egonzalez.org/
https://www.b1-systems.de/fileadmin/content/artikel/iX-2017-11_OpenStack-deployment-mit-Kolla.pdf