blob: 5e5189086ac01cd8f671d07cfe8de294a2d09d51 [file] [log] [blame]
Victor Morales4ab71c12017-11-08 07:28:28 -08001#!/bin/bash
2
3source /var/onap/functions
4
Victor Morales80f144b2018-01-10 07:20:54 -08005kolla_config=/etc/kolla
6kolla_build=$kolla_config/kolla-build.conf
7kolla_passwords=$kolla_config/passwords.yml
8kolla_globals=$kolla_config/globals.yml
9kolla_inventory=/var/onap/files/all-in-one
Victor Morales4ab71c12017-11-08 07:28:28 -080010
Victor Morales80f144b2018-01-10 07:20:54 -080011# install_dependencies() - Function that installs Kolla-Ansible requirements
12function install_dependencies {
Victor Morales4ab71c12017-11-08 07:28:28 -080013 install_docker
Victor Morales80f144b2018-01-10 07:20:54 -080014
Victor Morales4ab71c12017-11-08 07:28:28 -080015 mkdir -p /etc/systemd/system/docker.service.d
16 tee /etc/systemd/system/docker.service.d/kolla.conf <<-'EOF'
17[Service]
18MountFlags=shared
19EOF
Victor Morales80f144b2018-01-10 07:20:54 -080020 systemctl daemon-reload
21 systemctl restart docker
Victor Morales4ab71c12017-11-08 07:28:28 -080022
23 install_python_package ansible docker kolla-ansible python-openstackclient
Victor Morales80f144b2018-01-10 07:20:54 -080024}
Victor Morales4ab71c12017-11-08 07:28:28 -080025
Victor Morales80f144b2018-01-10 07:20:54 -080026# configure_deploy() - Function that modifies configuration files
27function 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 Morales4ab71c12017-11-08 07:28:28 -080034
Nate Potterfdf88f32018-01-17 09:29:35 -080035 if [[ `env | grep -i "proxy"` ]]; then
36 add_no_proxy_value $internal_vip_address
37 fi
38
Victor Morales80f144b2018-01-10 07:20:54 -080039 mkdir -p $kolla_config
40 cp /var/onap/files/globals.yml $kolla_globals
41 cp /var/onap/files/passwords.yml $kolla_passwords
42 cp /var/onap/files/kolla-build.conf $kolla_build
Victor Morales4ab71c12017-11-08 07:28:28 -080043 kolla-genpwd
Victor Morales80f144b2018-01-10 07:20:54 -080044 echo "network_interface: \"$nic\"" >> $kolla_globals
45 echo "kolla_internal_vip_address: \"$internal_vip_address\"" >> $kolla_globals
46 echo "api_interface: \"{{ network_interface }}\"" >> $kolla_globals
47 if [[ $enable_opendaylight == True ]]; then
48 echo "enable_opendaylight: \"yes\"" >> $kolla_globals
49 openstack_services+=",opendaylight"
50 fi
51 echo $openstack_services >> $kolla_build
Victor Morales4ab71c12017-11-08 07:28:28 -080052
Victor Morales4ab71c12017-11-08 07:28:28 -080053 echo "$ip_address $(hostname)" >> /etc/hosts
Victor Morales80f144b2018-01-10 07:20:54 -080054}
Victor Morales4ab71c12017-11-08 07:28:28 -080055
Victor Morales80f144b2018-01-10 07:20:54 -080056# get_openstack_images() - Function that retrieves or builds docker images
57function get_openstack_images {
58 if [[ "$build_image" == "True" ]]; then
59 install_python_package kolla
60 kolla-build --config-file $kolla_build
61 else
62 kolla-ansible pull -i $kolla_inventory
63 fi
64}
65
66# deploy_openstack() - Function that provisions an OpenStack deployment
67function deploy_openstack {
68 install_dependencies
69 configure_deploy ${1:-"192.168.53.0"} "True"
70
71 get_openstack_images
72 kolla-ansible deploy -i $kolla_inventory
Victor Morales4ab71c12017-11-08 07:28:28 -080073 kolla-ansible post-deploy
74 echo "source /etc/kolla/admin-openrc.sh" >> ${HOME}/.bashrc
75}