-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmidonet_static.yml
163 lines (134 loc) · 6.98 KB
/
midonet_static.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
---
### Fake UplinkBridge Setup
- hosts: NEU-SVR
tasks:
- name: MidoNet CLI | Tunnel Zone | Create tunnel zone
shell: midonet-cli -e tunnel-zone create name tz type vxlan
register: mido_zone
run_once: true
- name: MidoNet CLI | Tunnel Zone | Add Members
shell: midonet-cli -A -e list host | awk -F' ' '{print $2 " " $4}'| while read id host; do ip=$(awk '/'$host'/ {print $1}' /etc/hosts); midonet-cli -A -e tunnel-zone {{ mido_zone.stdout }} add member host $id address $ip;done
run_once: true
- name: MidoNet Static Route | Interfaces Global | Create Type veth and iveth interfaces
shell: '{{ item }}'
sudo: yes
with_items:
- ip link add type veth
- ip link set dev veth0 up
- ip link set dev veth1 up
- brctl addbr uplinkbridge
- brctl addif uplinkbridge veth0
- name: MidoNet Static Route | Interfaces Global | Sysctl Ipv4 Forwarding
shell: sysctl -w net.ipv4.ip_forward=1
sudo: yes
- name: MidoNet Static Route | Interfaces Global | IPtables Rules
shell: '{{ item }}'
sudo: yes
with_items:
- iptables -t nat -I POSTROUTING -o eth1 -s {{ ext_subnet }} -j MASQUERADE
- iptables -I FORWARD -s {{ ext_subnet }} -j ACCEPT
- name: MidoNet Static Route | Interfaces Gateway 1 | Setup UplinkBridge and IP Route
shell: '{{ item }}'
sudo: yes
with_items:
- ip addr add 172.19.0.1/30 dev uplinkbridge
- ip link set dev uplinkbridge up
- ip route add 10.246.77.0/24 via 172.19.0.2
when: "'c1-m1-mgmt' in '{{ inventory_hostname }}'"
- name: MidoNet Static Route | Interfaces Gateway 2 | Setup UplinkBridge and IP Route
shell: '{{ item }}'
sudo: yes
with_items:
- ip addr add 172.19.0.5/30 dev uplinkbridge
- ip link set dev uplinkbridge up
- ip route add 10.246.77.0/24 via 172.19.0.6
when: "'c1-m2-mgmt' in '{{ inventory_hostname }}'"
- name: MidoNet Static Route | Interfaces Gateway 3 | Setup UplinkBridge and IP Route
shell: '{{ item }}'
sudo: yes
with_items:
- ip addr add 172.19.0.9/30 dev uplinkbridge
- ip link set dev uplinkbridge up
- ip route add 10.246.77.0/24 via 172.19.0.10
when: "'c1-m3-mgmt' in '{{ inventory_hostname }}'"
- name: Neutron | Edge Router Setup
shell: '{{ item }}'
with_items:
- '. ~/service.osrc && neutron router-create edge_router'
- '. ~/service.osrc && neutron router-interface-add edge_router ext-subnet'
- '. ~/service.osrc && neutron net-create uplink_network --tenant_id admin --provider:network_type uplink'
run_once: true
- name: MidoNet CLI | EXT NET | Controller 1 ID
shell: midonet-cli -e list host|awk '/c1-m1/ {print $2}'
register: m1_host
run_once: true
- name: MidoNet CLI | EXT NET | Controller 2 ID
shell: midonet-cli -e list host|awk '/c1-m2/ {print $2}'
register: m2_host
run_once: true
- name: MidoNet CLI | EXT NET | Controller 3 ID
shell: midonet-cli -e list host|awk '/c1-m3/ {print $2}'
register: m3_host
run_once: true
- name: MidoNet CLI | Edge Router | Edge Router ID
shell: midonet-cli -A -e router list|awk '/edge_router/ {print $2}'
register: edge_router_id
run_once: true
- name: MidoNet CLI | Edge Router | Fake Port ID 1
shell: midonet-cli -A -e router {{ edge_router_id.stdout }} add port address 172.19.0.2 net 172.19.0.0/30
register: fake_m1
run_once: true
- name: MidoNet CLI | Edge Router | Edge Router Fake Routing 1
shell: midonet-cli -A -e router {{ edge_router_id.stdout }} add route src 0.0.0.0/0 dst 0.0.0.0/0 type normal port router {{ edge_router_id.stdout }} port {{ fake_m1.stdout}} gw 172.19.0.1
run_once: true
- name: MidoNet CLI | Edge Router | Fake Port Binding 1
shell: midonet-cli -A -e host {{ m1_host.stdout }} add binding port router {{ edge_router_id.stdout }} port {{ fake_m1.stdout }} interface veth1
run_once: true
- name: MidoNet CLI | Edge Router | Fake Port ID 2
shell: midonet-cli -A -e router {{ edge_router_id.stdout }} add port address 172.19.0.6 net 172.19.0.4/30
register: fake_m2
run_once: true
- name: MidoNet CLI | Edge Router | Edge Router Fake Routing 2
shell: midonet-cli -A -e router {{ edge_router_id.stdout }} add route src 0.0.0.0/0 dst 0.0.0.0/0 type normal port router {{ edge_router_id.stdout }} port {{ fake_m2.stdout}} gw 172.19.0.5
run_once: true
- name: MidoNet CLI | Edge Router | Fake Port Binding 2
shell: midonet-cli -A -e host {{ m2_host.stdout }} add binding port router {{ edge_router_id.stdout }} port {{ fake_m2.stdout }} interface veth1
run_once: true
- name: MidoNet CLI | Edge Router | Fake Port ID 3
shell: midonet-cli -A -e router {{ edge_router_id.stdout }} add port address 172.19.0.10 net 172.19.0.8/30
register: fake_m3
run_once: true
- name: MidoNet CLI | Edge Router | Edge Router Fake Routing 3
shell: midonet-cli -A -e router {{ edge_router_id.stdout }} add route src 0.0.0.0/0 dst 0.0.0.0/0 type normal port router {{ edge_router_id.stdout }} port {{ fake_m3.stdout}} gw 172.19.0.9
run_once: true
- name: MidoNet CLI | Edge Router | Fake Port Binding 3
shell: midonet-cli -A -e host {{ m3_host.stdout }} add binding port router {{ edge_router_id.stdout }} port {{ fake_m3.stdout }} interface veth1
run_once: true
- name: Nova | Create New Sec Group
shell: '{{ item }}'
with_items:
- '. ~/service.osrc && nova secgroup-create midonet_sg "Midonet Security Group After Deployment"'
- '. ~/service.osrc && nova secgroup-add-rule midonet_sg icmp -1 -1 0.0.0.0/0'
- '. ~/service.osrc && nova secgroup-add-rule midonet_sg tcp 22 22 0.0.0.0/0'
run_once: true
- hosts: NEU-SVR[0]
tasks:
- name: MidoNet CLI | EXT NET | Get bridge ID
shell: midonet-cli -e bridge list|awk '/ext-net/ {print $2}'
register: ext_bridge
- name: MidoNet CLI | EXT NET | Add M2 Vlan
shell: midonet-cli -e bridge {{ ext_bridge.stdout }} add port
register: m2_vlan_id
- name: MidoNet CLI | EXT NET | Controller 2 ID
shell: midonet-cli -e list host|awk '/c1-m2/ {print $2}'
register: m2_host
- name: MidoNet CLI | EXT NET | Controller 2 Binding
shell: midonet-cli -e host {{ m2_host.stdout }} add binding port bridge {{ ext_bridge.stdout }} port {{ m2_vlan_id.stdout }} interface vlan{{ ext_vlan }}
- name: MidoNet CLI | EXT NET | Add M3 Vlan
shell: midonet-cli -e bridge {{ ext_bridge.stdout }} add port
register: m3_vlan_id
- name: MidoNet CLI | EXT NET | Controller 3 ID
shell: midonet-cli -e list host|awk '/c1-m3/ {print $2}'s
register: m3_host
- name: MidoNet CLI | EXT NET | Controller 3 Binding
shell: midonet-cli -e host {{ m3_host.stdout }} add binding port bridge {{ ext_bridge.stdout }} port {{ m3_vlan_id.stdout }} interface vlan{{ ext_vlan }}