Tatyana Leontovich | eae3205 | 2018-10-24 22:28:18 +0300 | [diff] [blame] | 1 | {% set REPOSITORY_SUITE = os_env('REPOSITORY_SUITE', 'proposed') %} |
| 2 | {% set OPENSTACK_PIKE_REPOSITORY = os_env('OPENSTACK_PIKE_REPOSITORY', "deb [arch=amd64] http://mirror.mirantis.local.test/" + REPOSITORY_SUITE + "/openstack-pike/xenial/ xenial main") %} |
| 3 | {% set UBUNTU_KEY_SERVER = os_env('UBUNTU_KEY_SERVER', 'keyserver.ubuntu.com') %} |
| 4 | {% set UBUNTU_KEY_ID = os_env('UBUNTU_KEY_ID', '0E08A149DE57BFBE') %} |
| 5 | |
Tatyana Leontovich | d34f410 | 2018-04-03 17:49:24 +0300 | [diff] [blame] | 6 | |
| 7 | {%- macro MACRO_CONFIGURE_VSWITCH(NODE_NAME, IP) %} |
| 8 | {#################################################} |
Tatyana Leontovich | eae3205 | 2018-10-24 22:28:18 +0300 | [diff] [blame] | 9 | - description: 'Enable openstack repo for needed packages ' |
| 10 | cmd: | |
| 11 | apt-key adv --keyserver "{{UBUNTU_KEY_SERVER}}" --recv-keys "{{ UBUNTU_KEY_ID}}" |
| 12 | echo "{{ OPENSTACK_PIKE_REPOSITORY }}" > /etc/apt/sources.list.d/openstack.list |
| 13 | eatmydata apt-get clean; |
| 14 | apt-get update; |
| 15 | sync; |
| 16 | node_name: {{ NODE_NAME }} |
| 17 | retry: {count: 1, delay: 5} |
| 18 | skip_fail: false |
Tatyana Leontovich | d34f410 | 2018-04-03 17:49:24 +0300 | [diff] [blame] | 19 | |
| 20 | - description: 'Install openvswitch-vtep package and configure it' |
| 21 | cmd: | |
| 22 | ip addr add {{ IP }}/24 dev ens4 |
| 23 | ifconfig ens4 up |
| 24 | |
| 25 | apt-get update |
Tatyana Leontovich | eae3205 | 2018-10-24 22:28:18 +0300 | [diff] [blame] | 26 | apt-get -y install openvswitch-switch --allow-unauthenticated |
Tatyana Leontovich | d34f410 | 2018-04-03 17:49:24 +0300 | [diff] [blame] | 27 | service openvswitch-switch stop |
Tatyana Leontovich | eae3205 | 2018-10-24 22:28:18 +0300 | [diff] [blame] | 28 | apt-get -y install openvswitch-vtep bridge-utils --allow-unauthenticated |
Tatyana Leontovich | d34f410 | 2018-04-03 17:49:24 +0300 | [diff] [blame] | 29 | |
| 30 | ovsdb-tool create /etc/openvswitch/vtep.db /usr/share/openvswitch/vtep.ovsschema |
| 31 | ovsdb-tool create /etc/openvswitch/vswitch.db /usr/share/openvswitch/vswitch.ovsschema |
| 32 | ovsdb-server --pidfile --detach --log-file --remote ptcp:6632:{{ IP }} --remote punix:/var/run/openvswitch/db.sock --remote=db:hardware_vtep,Global,managers /etc/openvswitch/vswitch.db /etc/openvswitch/vtep.db |
| 33 | ovs-vswitchd --log-file --detach --pidfile unix:/var/run/openvswitch/db.sock |
| 34 | ovs-vsctl add-br v-switch |
| 35 | vtep-ctl add-ps v-switch |
| 36 | vtep-ctl set Physical_Switch v-switch tunnel_ips={{ IP }} |
| 37 | ovs-vsctl add-port v-switch port0 -- set interface port0 type=internal |
| 38 | vtep-ctl add-port v-switch port0 |
| 39 | /usr/share/openvswitch/scripts/ovs-vtep --log-file=/var/log/openvswitch/ovs-vtep.log --pidfile=/var/run/openvswitch/ovs-vtep.pid --detach v-switch |
| 40 | node_name: {{ NODE_NAME }} |
| 41 | retry: {count: 1, delay: 5} |
| 42 | skip_fail: false |
| 43 | |
| 44 | {%- endmacro %} |
| 45 | |
| 46 | {%- macro MACRO_CHECK_BGPVPN_ENABLED_BY_DEFAULT() %} |
| 47 | {#####################################################} |
| 48 | |
| 49 | - description: 'Check BGPVPN extension is enabled by default' |
| 50 | cmd: salt 'cmp*' pillar.get neutron:compute:bgp_vpn:enabled | grep True |
| 51 | node_name: {{ HOSTNAME_CFG01 }} |
| 52 | retry: {count: 1, delay: 5} |
| 53 | skip_fail: false |
| 54 | |
| 55 | {%- endmacro %} |
| 56 | |
| 57 | {%- macro MACRO_ENABLE_L2GW(CLUSTER_NAME, VSWITCH_IP) %} |
| 58 | {#####################################################} |
| 59 | |
| 60 | - description: 'Check L2GW is disabled by default' |
| 61 | cmd: salt 'gtw01*' pillar.get neutron:gateway:l2gw:enabled | grep False |
| 62 | node_name: {{ HOSTNAME_CFG01 }} |
| 63 | retry: {count: 1, delay: 5} |
| 64 | skip_fail: false |
| 65 | |
| 66 | - description: 'Enable L2GW' |
| 67 | cmd: | |
| 68 | set -e; |
| 69 | set -x; |
| 70 | {%- set CLUSTER_PATH = '/srv/salt/reclass/classes/cluster/' + CLUSTER_NAME %} |
| 71 | |
| 72 | echo "Setting 'enable: true' for L2gw feature to gateway.yml file" |
| 73 | L2GW_LINE=$(sed -n '/l2gw/=' {{ CLUSTER_PATH }}/openstack/gateway.yml) |
| 74 | L2GW_ENABLE_LINE=$((L2GW_LINE + 1)) |
| 75 | sed -i "${L2GW_ENABLE_LINE}s/enabled: false/enabled: true/1" {{ CLUSTER_PATH }}/openstack/gateway.yml |
| 76 | |
| 77 | echo "Setting 'ovsdb_hosts' ips for L2gw feature to gateway.yml file" |
| 78 | sed -i "s/ovsdbx: 127.0.0.1:6632/ovsdbx: {{VSWITCH_IP}}:6632/1" {{ CLUSTER_PATH }}/openstack/gateway.yml |
| 79 | |
| 80 | node_name: {{ HOSTNAME_CFG01 }} |
| 81 | retry: {count: 1, delay: 5} |
| 82 | skip_fail: false |
| 83 | |
| 84 | - description: 'Refresh pillar data after L2GW enablement' |
Tatyana Leontovich | eae3205 | 2018-10-24 22:28:18 +0300 | [diff] [blame] | 85 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.refresh_pillar; sleep 15 |
| 86 | node_name: {{ HOSTNAME_CFG01 }} |
| 87 | retry: {count: 1, delay: 5} |
| 88 | skip_fail: false |
| 89 | |
| 90 | - description: 'Sync all' |
| 91 | cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.sync_all && sleep 5 |
Tatyana Leontovich | d34f410 | 2018-04-03 17:49:24 +0300 | [diff] [blame] | 92 | node_name: {{ HOSTNAME_CFG01 }} |
| 93 | retry: {count: 1, delay: 5} |
| 94 | skip_fail: false |
| 95 | |
| 96 | - description: 'Check L2GW is enabled' |
| 97 | cmd: salt 'gtw01*' pillar.get neutron:gateway:l2gw:enabled | grep True |
| 98 | node_name: {{ HOSTNAME_CFG01 }} |
Tatyana Leontovich | eae3205 | 2018-10-24 22:28:18 +0300 | [diff] [blame] | 99 | retry: {count: 3, delay: 5} |
Tatyana Leontovich | d34f410 | 2018-04-03 17:49:24 +0300 | [diff] [blame] | 100 | skip_fail: false |
| 101 | |
| 102 | {%- endmacro %} |