|
| 1 | +#!/bin/bash -ex |
| 2 | +# |
| 3 | + |
| 4 | +source config.cfg |
| 5 | +source functions.sh |
| 6 | + |
| 7 | +apt-get -y install python-pip |
| 8 | +pip install \ |
| 9 | + https://pypi.python.org/packages/source/c/crudini/crudini-0.7.tar.gz |
| 10 | + |
| 11 | +# |
| 12 | + |
| 13 | +cat << EOF >> /etc/sysctl.conf |
| 14 | +net.ipv4.conf.all.rp_filter=0 |
| 15 | +net.ipv4.conf.default.rp_filter=0 |
| 16 | +net.bridge.bridge-nf-call-iptables=1 |
| 17 | +net.bridge.bridge-nf-call-ip6tables=1 |
| 18 | +EOF |
| 19 | + |
| 20 | +echocolor "Install python openstack client" |
| 21 | +apt-get -y install python-openstackclient |
| 22 | + |
| 23 | +echocolor "Install and config NTP" |
| 24 | +sleep 3 |
| 25 | + |
| 26 | + |
| 27 | +apt-get -y install chrony |
| 28 | +ntpfile=/etc/chrony/chrony.conf |
| 29 | +cp $ntpfile $ntpfile.orig |
| 30 | + |
| 31 | +sed -i "s/server 0.debian.pool.ntp.org offline minpoll 8/ \ |
| 32 | +server $CTL_MGNT_IP iburst/g" $ntpfile |
| 33 | + |
| 34 | + |
| 35 | +sed -i 's/server 1.debian.pool.ntp.org offline minpoll 8/ \ |
| 36 | +# server 1.debian.pool.ntp.org offline minpoll 8/g' $ntpfile |
| 37 | + |
| 38 | +sed -i 's/server 2.debian.pool.ntp.org offline minpoll 8/ \ |
| 39 | +# server 2.debian.pool.ntp.org offline minpoll 8/g' $ntpfile |
| 40 | + |
| 41 | +sed -i 's/server 3.debian.pool.ntp.org offline minpoll 8/ \ |
| 42 | +# server 3.debian.pool.ntp.org offline minpoll 8/g' $ntpfile |
| 43 | + |
| 44 | + |
| 45 | +sleep 5 |
| 46 | +echocolor "Installl package for NOVA" |
| 47 | + |
| 48 | +apt-get -y install nova-compute |
| 49 | +# echo "libguestfs-tools libguestfs/update-appliance boolean true" \ |
| 50 | +# | debconf-set-selections |
| 51 | +# apt-get -y install libguestfs-tools sysfsutils guestfsd python-guestfs |
| 52 | + |
| 53 | +# Fix KVM bug when injecting password |
| 54 | +# update-guestfs-appliance |
| 55 | +# chmod 0644 /boot/vmlinuz* |
| 56 | +# usermod -a -G kvm root |
| 57 | + |
| 58 | + |
| 59 | +echocolor "Configuring in nova.conf" |
| 60 | +sleep 5 |
| 61 | +######## |
| 62 | +#/* Backup nova.conf |
| 63 | +nova_com=/etc/nova/nova.conf |
| 64 | +test -f $nova_com.orig || cp $nova_com $nova_com.orig |
| 65 | + |
| 66 | +## [DEFAULT] Section |
| 67 | +ops_edit $nova_com DEFAULT rpc_backend rabbit |
| 68 | +ops_edit $nova_com DEFAULT auth_strategy keystone |
| 69 | +ops_edit $nova_com DEFAULT my_ip $COM1_MGNT_IP |
| 70 | +ops_edit $nova_com DEFAULT use_neutron True |
| 71 | +ops_edit $nova_com DEFAULT \ |
| 72 | + firewall_driver nova.virt.firewall.NoopFirewallDriver |
| 73 | +#ops_edit $nova_com DEFAULT \ |
| 74 | +# linuxnet_interface_driver nova.network.linux_net.LinuxOVSInterfaceDriver |
| 75 | + |
| 76 | +# ops_edit $nova_com DEFAULT network_api_class nova.network.neutronv2.api.API |
| 77 | +# ops_edit $nova_com DEFAULT security_group_api neutron |
| 78 | + |
| 79 | + |
| 80 | +# ops_edit $nova_com DEFAULT enable_instance_password True |
| 81 | + |
| 82 | +## [oslo_messaging_rabbit] section |
| 83 | +ops_edit $nova_com oslo_messaging_rabbit rabbit_host $CTL_MGNT_IP |
| 84 | +ops_edit $nova_com oslo_messaging_rabbit rabbit_userid openstack |
| 85 | +ops_edit $nova_com oslo_messaging_rabbit rabbit_password $RABBIT_PASS |
| 86 | + |
| 87 | + |
| 88 | +## [keystone_authtoken] section |
| 89 | +ops_edit $nova_com keystone_authtoken auth_uri http://$CTL_MGNT_IP:5000 |
| 90 | +ops_edit $nova_com keystone_authtoken auth_url http://$CTL_MGNT_IP:35357 |
| 91 | +ops_edit $nova_com keystone_authtoken memcached_servers $CTL_MGNT_IP:11211 |
| 92 | +ops_edit $nova_com keystone_authtoken auth_type password |
| 93 | +ops_edit $nova_com keystone_authtoken project_domain_name default |
| 94 | +ops_edit $nova_com keystone_authtoken user_domain_name default |
| 95 | +ops_edit $nova_com keystone_authtoken project_name service |
| 96 | +ops_edit $nova_com keystone_authtoken username nova |
| 97 | +ops_edit $nova_com keystone_authtoken password $NOVA_PASS |
| 98 | + |
| 99 | +## [vnc] section |
| 100 | +ops_edit $nova_com vnc enabled True |
| 101 | +ops_edit $nova_com vnc vncserver_listen 0.0.0.0 |
| 102 | +ops_edit $nova_com vnc vncserver_proxyclient_address \$my_ip |
| 103 | +ops_edit $nova_com vnc vncserver_proxyclient_address \$my_ip |
| 104 | +ops_edit $nova_com vnc \ |
| 105 | + novncproxy_base_url http://$CTL_EXT_IP:6080/vnc_auto.html |
| 106 | + |
| 107 | + |
| 108 | +## [glance] section |
| 109 | +ops_edit $nova_com glance api_servers http://$CTL_MGNT_IP:9292 |
| 110 | + |
| 111 | + |
| 112 | +## [oslo_concurrency] section |
| 113 | +ops_edit $nova_com oslo_concurrency lock_path /var/lib/nova/tmp |
| 114 | + |
| 115 | +## [neutron] section |
| 116 | +ops_edit $nova_com neutron url http://$CTL_MGNT_IP:9696 |
| 117 | +ops_edit $nova_com neutron auth_url http://$CTL_MGNT_IP:35357 |
| 118 | +ops_edit $nova_com neutron auth_type password |
| 119 | +ops_edit $nova_com neutron project_domain_name default |
| 120 | +ops_edit $nova_com neutron user_domain_name default |
| 121 | +ops_edit $nova_com neutron region_name RegionOne |
| 122 | +ops_edit $nova_com neutron project_name service |
| 123 | +ops_edit $nova_com neutron username neutron |
| 124 | +ops_edit $nova_com neutron password $NEUTRON_PASS |
| 125 | + |
| 126 | +echocolor "Restart nova-compute" |
| 127 | +sleep 5 |
| 128 | +service nova-compute restart |
| 129 | + |
| 130 | +# Remove default nova db |
| 131 | +rm /var/lib/nova/nova.sqlite |
| 132 | + |
| 133 | +echocolor "Install openvswitch-agent (neutron) on COMPUTE NODE" |
| 134 | +sleep 5 |
| 135 | + |
| 136 | +apt-get -y install neutron-server neutron-plugin-ml2 \ |
| 137 | +neutron-openvswitch-agent python-neutronclient ipset |
| 138 | + |
| 139 | + |
| 140 | +echocolor "Config file neutron.conf" |
| 141 | +neutron_com=/etc/neutron/neutron.conf |
| 142 | +test -f $neutron_com.orig || cp $neutron_com $neutron_com.orig |
| 143 | + |
| 144 | +## [DEFAULT] section |
| 145 | +ops_edit $neutron_com DEFAULT core_plugin ml2 |
| 146 | +ops_edit $neutron_com DEFAULT rpc_backend rabbit |
| 147 | +ops_edit $neutron_com DEFAULT auth_strategy keystone |
| 148 | +ops_edit $neutron_com DEFAULT service_plugins router |
| 149 | + |
| 150 | +## [keystone_authtoken] section |
| 151 | +ops_edit $neutron_com keystone_authtoken auth_uri http://$CTL_MGNT_IP:5000 |
| 152 | +ops_edit $neutron_com keystone_authtoken auth_url http://$CTL_MGNT_IP:35357 |
| 153 | +ops_edit $neutron_com keystone_authtoken memcached_servers $CTL_MGNT_IP:11211 |
| 154 | +ops_edit $neutron_com keystone_authtoken auth_type password |
| 155 | +ops_edit $neutron_com keystone_authtoken project_domain_name default |
| 156 | +ops_edit $neutron_com keystone_authtoken user_domain_name default |
| 157 | +ops_edit $neutron_com keystone_authtoken project_name service |
| 158 | +ops_edit $neutron_com keystone_authtoken username neutron |
| 159 | +ops_edit $neutron_com keystone_authtoken password $NEUTRON_PASS |
| 160 | + |
| 161 | + |
| 162 | +## [database] section |
| 163 | +ops_del $neutron_com database connection |
| 164 | + |
| 165 | +## [oslo_messaging_rabbit] section |
| 166 | +ops_edit $neutron_com oslo_messaging_rabbit rabbit_host $CTL_MGNT_IP |
| 167 | +ops_edit $neutron_com oslo_messaging_rabbit rabbit_userid openstack |
| 168 | +ops_edit $neutron_com oslo_messaging_rabbit rabbit_password $RABBIT_PASS |
| 169 | + |
| 170 | +######## Backup configuration of ML2 ##################" |
| 171 | +echocolor "Configuring ML2" |
| 172 | +sleep 7 |
| 173 | + |
| 174 | +ml2_com=/etc/neutron/plugins/ml2/ml2_conf.ini |
| 175 | +test -f $ml2_com.orig || cp $ml2_com $ml2_com.orig |
| 176 | + |
| 177 | +## [ml2] section |
| 178 | +ops_edit $ml2_com ml2 type_drivers flat,vlan |
| 179 | +ops_edit $ml2_com ml2 tenant_network_types |
| 180 | +ops_edit $ml2_com ml2 mechanism_drivers openvswitch |
| 181 | +ops_edit $ml2_com ml2 extension_drivers port_security |
| 182 | + |
| 183 | + |
| 184 | +## [ml2_type_flat] section |
| 185 | +ops_edit $ml2_com ml2_type_flat flat_networks external |
| 186 | + |
| 187 | +## [ml2_type_gre] section |
| 188 | +ops_edit $ml2_com ml2_type_gre tunnel_id_ranges 300:400 |
| 189 | + |
| 190 | +## [ml2_type_vxlan] section |
| 191 | +# ops_edit $ml2_com ml2_type_vxlan vni_ranges 201:300 |
| 192 | + |
| 193 | + |
| 194 | +## [ml2_type_vlan] section |
| 195 | +ops_edit $ml2_com ml2_type_vlan network_vlan_ranges external |
| 196 | + |
| 197 | +## [securitygroup] section |
| 198 | +ops_edit $ml2_com securitygroup enable_ipset True |
| 199 | +ops_edit $ml2_com securitygroup firewall_driver \ |
| 200 | + neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver |
| 201 | + |
| 202 | +ops_edit $ml2_com securitygroup enable_security_group True |
| 203 | + |
| 204 | + |
| 205 | +echocolor "Configuring openvswitch_agent" |
| 206 | +sleep 5 |
| 207 | +ovsfile=/etc/neutron/plugins/ml2/openvswitch_agent.ini |
| 208 | +test -f $ovsfile.orig || cp $ovsfile $ovsfile.orig |
| 209 | + |
| 210 | +## [agent] section |
| 211 | +ops_edit $ovsfile agent tunnel_types gre |
| 212 | +ops_edit $ovsfile agent l2_population True |
| 213 | + |
| 214 | +## [ovs] section |
| 215 | +ops_edit $ovsfile ovs local_ip $CTL_MGNT_IP |
| 216 | +ops_edit $ovsfile ovs bridge_mappings external:br-ex |
| 217 | + |
| 218 | +# [securitygroup] section |
| 219 | +ops_edit $ovsfile securitygroup firewall_driver \ |
| 220 | + neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver |
| 221 | + |
| 222 | +echocolor "Reset service nova-compute,openvswitch_agent" |
| 223 | +sleep 5 |
| 224 | +service neutron-openvswitch-agent restart |
| 225 | + |
| 226 | +echocolor "Config IP address for br-ex" |
| 227 | +ifaces=/etc/network/interfaces |
| 228 | +test -f $ifaces.orig1 || cp $ifaces $ifaces.orig1 |
| 229 | +rm $ifaces |
| 230 | +cat << EOF > $ifaces |
| 231 | +# The loopback network interface |
| 232 | +auto lo |
| 233 | +iface lo inet loopback |
| 234 | +
|
| 235 | +# The primary network interface |
| 236 | +auto br-ex |
| 237 | +iface br-ex inet static |
| 238 | +address $COM1_EXT_IP |
| 239 | +netmask $NETMASK_ADD_EXT |
| 240 | +gateway $GATEWAY_IP_EXT |
| 241 | +dns-nameservers 8.8.8.8 |
| 242 | +
|
| 243 | +auto eth1 |
| 244 | +iface eth1 inet manual |
| 245 | + up ifconfig \$IFACE 0.0.0.0 up |
| 246 | + up ip link set \$IFACE promisc on |
| 247 | + down ip link set \$IFACE promisc off |
| 248 | + down ifconfig \$IFACE down |
| 249 | +
|
| 250 | +auto eth0 |
| 251 | +iface eth0 inet static |
| 252 | +address $COM1_MGNT_IP |
| 253 | +netmask $NETMASK_ADD_MGNT |
| 254 | +EOF |
| 255 | + |
| 256 | + |
| 257 | +echocolor "Config br-int and br-ex for OpenvSwitch" |
| 258 | +sleep 5 |
| 259 | +# ovs-vsctl add-br br-int |
| 260 | +ovs-vsctl add-br br-ex |
| 261 | +ovs-vsctl add-port br-ex eth1 |
| 262 | + |
| 263 | +echocolor "Finished install NEUTRON on CONTROLLER" |
| 264 | + |
| 265 | +sleep 5 |
| 266 | +echocolor "Reboot SERVER" |
| 267 | +init 6 |
0 commit comments