# Kolla-Ansible

# What is kolla-ansible ?


It’s a script who permit to create openstack “stack” in docker containers. It uses ansible to setup things.


# Setup


## Requirements


* 2 network interfaces (one configured and the other one not configured)
* 16G memory
* 120G HDD


## Install dependencies


```bash
sudo apt update && sudo apt install python3-dev git libffi-dev gcc libssl-dev && sudo apt install python3-pip && sudo pip3 install -U pip && sudo pip install 'ansible>=6,<8'
```

## Install Kolla-Ansible


```bash
sudo pip3 install git+https://opendev.org/openstack/kolla-ansible@master && sudo mkdir -p /etc/kolla && sudo chown $USER:$USER /etc/kolla && cp -r /usr/local/share/kolla-ansible/etc_examples/kolla/* /etc/kolla && cp /usr/local/share/kolla-ansible/ansible/inventory/* .
```


## Install Ansible dependencies


```bash
kolla-ansible install-deps
```


## Configure Ansible (deprecated)


```bash
sudo mkdir /etc/ansible && sudo vim /etc/ansible/ansible.cfg
```


Insert in **ansible.cfg:**


```bash
[defaults]
host_key_checking=False

pipelining=True

forks=100
```


## Prepare installation


* For multinode

  If you use multinode, modify the configuration in the `multinode` file:

  ```bash
  [control]
  10.0.0.[10:12] ansible_user=ubuntu ansible_password=foobar ansible_become=true
  # Ansible supports syntax like [10:12] - that means 10, 11 and 12.
  # Become clause means "use sudo".
  
  [network:children]
  control
  # when you specify group_name:children, it will use contents of group specified.
  
  [compute]
  10.0.0.[13:14] ansible_user=ubuntu ansible_password=foobar ansible_become=true
  
  [monitoring]
  10.0.0.10
  # This group is for monitoring node.
  # Fill it with one of the controllers' IP address or some others.
  
  [storage:children]
  compute
  
  [deployment]
  localhost       ansible_connection=local become=true
  # use localhost and sudo
  ```

  Check if your configuration is right by:

  ```bash
  ansible -i multinode all -m ping
  ```


### Generate the password


```bash
kolla-genpwd
```


### globals.yml (/etc/kolla/globals.yml)


Edit these lines:


```bash
kolla_base_distro: "ubuntu"
network_interface: "eth0"
neutron_external_interface: "ens19"
kolla_internal_vip_address: "10.1.1.250"
```


You can enable services manually by typing `yes` on `enable_*` lines.


## Deployment


* Multinode

  ```bash
  kolla-ansible -i ./multinode bootstrap-servers && kolla-ansible -i ./multinode prechecks && kolla-ansible -i ./multinode deploy
  ```
* All-in-one

  ```bash
  kolla-ansible -i ./all-in-one bootstrap-servers && kolla-ansible -i ./all-in-one prechecks && kolla-ansible -i ./all-in-one deploy
  ```


## Setup openstack cli


```bash
sudo pip install python-openstackclient -c https://releases.openstack.org/constraints/upper/master
```


```bash
kolla-ansible post-deploy && sudo cp /etc/kolla/clouds.yaml /etc/openstack/ && sudo cp /etc/kolla/clouds.yaml ~/.config/openstack
```


## Setup network


Run this:


```bash
openstack router create router && openstack network create local-net && openstack subnet create --subnet-range 10.0.0.0/24 --network local-net --gateway 10.0.0.1 --dns-nameserver 8.8.8.8 local-subnet && openstack router add subnet router local-subnet && openstack network create --external --provider-physical-network physnet1 --provider-network-type flat public1 && openstack subnet create --allocation-pool start=10.1.2.150,end=10.1.2.199 --network public1 --subnet-range 10.1.2.0/24 --gateway 10.1.2.1 public1-subnet && openstack router set --external-gateway public1 router
```


### Enable packet forwarding


Edit /etc/sysctl.conf


```bash
net.ipv4.ip_forward=1
net.ipv4.conf.default.rp_filter=0
net.ipv4.conf.all.rp_filter=0
```


Run:


```bash
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
```


:::warning
DON’T FORGET TO ENABLE ENS19 INET

:::

```bash
sudo ip link set dev ens19 up
```

## Network config file

```yaml
network:
  ethernets:
    ens18:
      dhcp4: true
    ens19:
      dhcp4: false
      dhcp6: false
  version: 2
```

# Use openstack


## Import Cirros image (for testing purpose)


```bash
wget https://download.cirros-cloud.net/0.6.0/cirros-0.6.0-x86_64-disk.img
openstack image create --container-format bare \
--disk-format qcow2 --file cirros-0.6.0-x86_64-disk.img cirros
```


## Import Ubuntu 22.04 image


```bash
wget https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img
openstack image create --container-format bare \
--disk-format qcow2 --file jammy-server-cloudimg-amd64.img ubuntu-22.04
```

## Create “default” flavors

```bash
openstack flavor create --vcpus 1 --ram 512 --disk 1 m1.tiny && \
    openstack flavor create --vcpus 1 --ram 2048 --disk 20 m1.small && \
    openstack flavor create --vcpus 2 --ram 4096 --disk 40 m1.medium && \
    openstack flavor create --vcpus 4 --ram 8192 --disk 80 m1.large && \
    openstack flavor create --vcpus 8 --ram 16384 --disk 160 m1.xlarge
```

## Create security group allowing ssh

```bash
openstack security group create test && \
openstack security group rule create --protocol tcp --remote-ip 0.0.0.0/0 --ingress --dst-port 22 test
```

# Advanced configuration

<https://docs.openstack.org/kolla-ansible/latest/admin/advanced-configuration.html>

---

**Documents**

- [AS205126](https://docs.legodard.fr/s/bc661677-ac7d-4fe7-984e-e1f43ddf6287/doc/as205126-UD37o91h51)
- [Kubernetes](https://docs.legodard.fr/s/bc661677-ac7d-4fe7-984e-e1f43ddf6287/doc/kubernetes-AYsNjQV7SW)
- [Proxmox](https://docs.legodard.fr/s/bc661677-ac7d-4fe7-984e-e1f43ddf6287/doc/proxmox-TnNEgoRFwj)
- [DN42](https://docs.legodard.fr/s/bc661677-ac7d-4fe7-984e-e1f43ddf6287/doc/dn42-oTEE68Qn7n)
- [Openshift](https://docs.legodard.fr/s/bc661677-ac7d-4fe7-984e-e1f43ddf6287/doc/openshift-428FG3kMtg)
- [Openstack](https://docs.legodard.fr/s/bc661677-ac7d-4fe7-984e-e1f43ddf6287/doc/openstack-KJmz0J0klm)