Victor Morales | 4ab71c1 | 2017-11-08 07:28:28 -0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | source /var/onap/functions |
| 4 | |
Victor Morales | 80f144b | 2018-01-10 07:20:54 -0800 | [diff] [blame] | 5 | kolla_config=/etc/kolla |
| 6 | kolla_build=$kolla_config/kolla-build.conf |
| 7 | kolla_passwords=$kolla_config/passwords.yml |
| 8 | kolla_globals=$kolla_config/globals.yml |
| 9 | kolla_inventory=/var/onap/files/all-in-one |
Victor Morales | 4ab71c1 | 2017-11-08 07:28:28 -0800 | [diff] [blame] | 10 | |
Victor Morales | 80f144b | 2018-01-10 07:20:54 -0800 | [diff] [blame] | 11 | # install_dependencies() - Function that installs Kolla-Ansible requirements |
| 12 | function install_dependencies { |
Victor Morales | 4ab71c1 | 2017-11-08 07:28:28 -0800 | [diff] [blame] | 13 | install_docker |
Victor Morales | 80f144b | 2018-01-10 07:20:54 -0800 | [diff] [blame] | 14 | |
Victor Morales | 4ab71c1 | 2017-11-08 07:28:28 -0800 | [diff] [blame] | 15 | mkdir -p /etc/systemd/system/docker.service.d |
| 16 | tee /etc/systemd/system/docker.service.d/kolla.conf <<-'EOF' |
| 17 | [Service] |
| 18 | MountFlags=shared |
| 19 | EOF |
Victor Morales | 80f144b | 2018-01-10 07:20:54 -0800 | [diff] [blame] | 20 | systemctl daemon-reload |
| 21 | systemctl restart docker |
Victor Morales | 4ab71c1 | 2017-11-08 07:28:28 -0800 | [diff] [blame] | 22 | |
| 23 | install_python_package ansible docker kolla-ansible python-openstackclient |
Victor Morales | 80f144b | 2018-01-10 07:20:54 -0800 | [diff] [blame] | 24 | } |
Victor Morales | 4ab71c1 | 2017-11-08 07:28:28 -0800 | [diff] [blame] | 25 | |
Victor Morales | 80f144b | 2018-01-10 07:20:54 -0800 | [diff] [blame] | 26 | # configure_deploy() - Function that modifies configuration files |
| 27 | function configure_deploy { |
| 28 | local network_id=$1 |
| 29 | local enable_opendaylight=${2-False} |
| 30 | local openstack_services="main = ceilometer,cinder,glance,heat,horizon,isci,keystone,neutron,nova-,swift" |
| 31 | nic=$(ip route get $network_id | awk '{ print $4; exit }') |
| 32 | ip_address=$(ip route get $network_id | awk '{ print $6; exit }') |
| 33 | internal_vip_address=$(get_next_ip $ip_address) |
Victor Morales | 4ab71c1 | 2017-11-08 07:28:28 -0800 | [diff] [blame] | 34 | |
Victor Morales | 80f144b | 2018-01-10 07:20:54 -0800 | [diff] [blame] | 35 | mkdir -p $kolla_config |
| 36 | cp /var/onap/files/globals.yml $kolla_globals |
| 37 | cp /var/onap/files/passwords.yml $kolla_passwords |
| 38 | cp /var/onap/files/kolla-build.conf $kolla_build |
Victor Morales | 4ab71c1 | 2017-11-08 07:28:28 -0800 | [diff] [blame] | 39 | kolla-genpwd |
Victor Morales | 80f144b | 2018-01-10 07:20:54 -0800 | [diff] [blame] | 40 | echo "network_interface: \"$nic\"" >> $kolla_globals |
| 41 | echo "kolla_internal_vip_address: \"$internal_vip_address\"" >> $kolla_globals |
| 42 | echo "api_interface: \"{{ network_interface }}\"" >> $kolla_globals |
| 43 | if [[ $enable_opendaylight == True ]]; then |
| 44 | echo "enable_opendaylight: \"yes\"" >> $kolla_globals |
| 45 | openstack_services+=",opendaylight" |
| 46 | fi |
| 47 | echo $openstack_services >> $kolla_build |
Victor Morales | 4ab71c1 | 2017-11-08 07:28:28 -0800 | [diff] [blame] | 48 | |
Victor Morales | 4ab71c1 | 2017-11-08 07:28:28 -0800 | [diff] [blame] | 49 | echo "$ip_address $(hostname)" >> /etc/hosts |
Victor Morales | 80f144b | 2018-01-10 07:20:54 -0800 | [diff] [blame] | 50 | } |
Victor Morales | 4ab71c1 | 2017-11-08 07:28:28 -0800 | [diff] [blame] | 51 | |
Victor Morales | 80f144b | 2018-01-10 07:20:54 -0800 | [diff] [blame] | 52 | # get_openstack_images() - Function that retrieves or builds docker images |
| 53 | function get_openstack_images { |
| 54 | if [[ "$build_image" == "True" ]]; then |
| 55 | install_python_package kolla |
| 56 | kolla-build --config-file $kolla_build |
| 57 | else |
| 58 | kolla-ansible pull -i $kolla_inventory |
| 59 | fi |
| 60 | } |
| 61 | |
| 62 | # deploy_openstack() - Function that provisions an OpenStack deployment |
| 63 | function deploy_openstack { |
| 64 | install_dependencies |
| 65 | configure_deploy ${1:-"192.168.53.0"} "True" |
| 66 | |
| 67 | get_openstack_images |
| 68 | kolla-ansible deploy -i $kolla_inventory |
Victor Morales | 4ab71c1 | 2017-11-08 07:28:28 -0800 | [diff] [blame] | 69 | kolla-ansible post-deploy |
| 70 | echo "source /etc/kolla/admin-openrc.sh" >> ${HOME}/.bashrc |
| 71 | } |