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

Install all-in-one
apt-get install python-dev libffi-dev gcc libssl-dev python-selinux python-setuptools ansible pip
pip install kolla-ansible
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

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"

Openvswitch
# create interface
echo docker exec openvswitch_vswitchd ovs-vsctl -- --may-exist add-port br-int my-if1 -- \
set Interface my-if1 type=internal -- \
set Interface my-if1 external-ids:iface-status=active -- \
set Interface my-if1 external-ids:attached-mac=${CTL_HOST_MAC} -- \
set Interface my-if1 external-ids:iface-id=${PORT_ID} -- \
set Interface my-if1 external-ids:skip_cleanup=true

# show interface
docker exec -it openvswitch_vswitchd ovs-vsctl show

# delete interface
docker exec openvswitch_vswitchd ovs-vsctl -- del-port br-int my-interface1

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
# 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

Octavia certificate
git clone https://github.com/openstack/octavia.git /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/
# grep octavia_ca_password /etc/kolla/passwords.yml
octavia_ca_password: foobar
cd /opt/kolla-ansible/tools/
./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

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