-
Notifications
You must be signed in to change notification settings - Fork 3
/
deployNsx.yml
409 lines (379 loc) · 14.1 KB
/
deployNsx.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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
---
- name: Deploy and Configure NSX-T
hosts: localhost
gather_facts: False
vars_files:
- answerfile.yml
tasks:
- name: deploy NSX Managers OVA
deploy_ova:
ovftool_path: "{{ ovfToolPath }}"
datacenter: "{{ item.value.dc }}"
datastore: "{{ item.value.datastore }}"
portgroup: "{{ item.value.portgroup }}"
cluster: "{{ item.value.cluster }}"
vmname: "{{ item.key }}"
hostname: "{{ item.value.hostname }}"
dns_server: "{{ dns_server }}"
dns_domain: "{{ dns_domain }}"
ntp_server: "{{ ntp_server }}"
gateway: "{{ item.value.gw }}"
ip_address: "{{ item.value.ip }}"
netmask: "{{ item.value.mask }}"
admin_password: "{{ item.value.password }}"
cli_password: "{{ item.value.password }}"
ssh_enabled: "{{ sshEnabled }}"
allow_ssh_root_login: "{{ allowSSHRootAccess }}"
path_to_ova: "{{ nsxOvaPath }}"
ova_file: "{{ managerOva }}"
vcenter: "{{ deployVcIPAddress }}"
vcenter_user: "{{ deployVcUser }}"
vcenter_passwd: "{{ deployVcPassword }}"
with_dict: "{{ nsxmanagers }}"
register: deploy_nsx_man
- name: Wait 3 minutes before start configuration
pause: minutes=3
- debug: var=nsxmanagers['nsx-manager'].ip
- name: NSX-T Compute Manager
nsxt_compute_manager:
display_name: "{{ compute_manager }}"
server: "{{ deployVcIPAddress }}"
username: "{{ deployVcUser }}"
passwd: "{{ deployVcPassword }}"
origin_type: "vCenter"
state: present
nsx_manager: "{{ nsxmanagers['nsx-manager'].ip }}"
nsx_username: 'admin'
nsx_passwd: "{{ nsxmanagers['nsx-manager'].password }}"
register: cmp_manager
- name: NSX-T Controller Cluster
nsxt_controller_cluster:
shared_secret: 'VMware1!'
vc_id: "{{ cmp_manager.id }}"
controllers: "{{ controllers }}"
state: present
nsx_manager: "{{ nsxmanagers['nsx-manager'].ip }}"
nsx_username: 'admin'
nsx_passwd: "{{ nsxmanagers['nsx-manager'].password }}"
register: ctrl_cluster
- name: NSX-T Transport Zone
nsxt_transport_zone:
display_name: "{{ item.key }}"
description: "{{ item.value.description }}"
host_switch_name: "{{ item.value.host_switch }}"
transport_type: "{{ item. value.type }}"
state: present
nsx_manager: "{{ nsxmanagers['nsx-manager'].ip }}"
nsx_username: 'admin'
nsx_passwd: "{{ nsxmanagers['nsx-manager'].password }}"
with_dict: "{{ transport_zones }}"
register: tzone
- name: NSX-T IP Pool
nsxt_ip_pool:
display_name: "{{ tep_pool_name }}"
description: "IP Pool for GENEVE Overlay Traffic"
subnets:
- cidr: "{{ tep_pool_cidr }}"
allocation_ranges:
- "{{ tep_pool_range }}"
dns_nameservers:
- "{{ tep_pool_nameserver }}"
dns_suffix: "{{ tep_pool_suffix }}"
gateway_ip: "{{ tep_pool_gw }}"
tags:
"{{ tag_scope }}": "{{ tag }}"
state: present
nsx_manager: "{{ nsxmanagers['nsx-manager'].ip }}"
nsx_username: 'admin'
nsx_passwd: "{{ nsxmanagers['nsx-manager'].password }}"
register: ippool
- name: NSX-T IP Block
nsxt_ip_block:
display_name: "{{ item.key }}"
description: "{{ item.value.description }}"
cidr: "{{ item.value.cidr }}"
tags:
"{{ tag_scope }}": "{{ tag }}"
state: present
nsx_manager: "{{ nsxmanagers['nsx-manager'].ip }}"
nsx_username: 'admin'
nsx_passwd: "{{ nsxmanagers['nsx-manager'].password }}"
with_dict: "{{ ipblocks }}"
register: ipblock
- name: NSX-T Edge Uplink Profile
nsxt_uplink_profile:
display_name: "{{ edge_uplink_profile_name }}"
description: "Edge Uplink Profile"
mtu: "{{ edge_uplink_profile_mtu }}"
active_list:
- uplink-1
policy: "FAILOVER_ORDER"
transport_vlan: "{{ edge_uplink_profile_vlan }}"
state: present
nsx_manager: "{{ nsxmanagers['nsx-manager'].ip }}"
nsx_username: 'admin'
nsx_passwd: "{{ nsxmanagers['nsx-manager'].password }}"
when: edge_uplink_profile_name is defined
register: edge_uplink_prof
- name: NSX-T Host Uplink Profile
nsxt_uplink_profile:
display_name: "{{ esxi_uplink_profile_name }}"
description: "Host Uplink Profile"
mtu: "{{ esxi_uplink_profile_mtu }}"
active_list:
- uplink-1
- uplink-2
policy: "LOADBALANCE_SRCID"
transport_vlan: "{{ esxi_uplink_profile_vlan }}"
state: present
nsx_manager: "{{ nsxmanagers['nsx-manager'].ip }}"
nsx_username: 'admin'
nsx_passwd: "{{ nsxmanagers['nsx-manager'].password }}"
when: esxi_uplink_profile_name is defined
register: edge_uplink_prof
- name: NSX-T Compute Manager Cluster
nsxt_cm_cluster:
display_name: "{{ item.key }}"
cm_name: "{{ compute_manager }}"
auto_install_nsx: "{{ item.value.auto_install_nsx }}"
create_transport_node: "{{ item.value.auto_create_transport_nodes }}"
transport_zone_endpoints:
- overlay_tz
host_switch:
- name: "nvds1"
static_ip_pool_id: "{{ ippool.id }}"
pnics: "{{ item.value.pnics }}"
uplink_profile: "{{ esxi_uplink_profile_name }}"
state: present
nsx_manager: "{{ nsxmanagers['nsx-manager'].ip }}"
nsx_username: 'admin'
nsx_passwd: "{{ nsxmanagers['nsx-manager'].password }}"
with_dict: "{{ cm_clusters }}"
register: cmcluster
- name: NSX-T Edge Node
nsxt_edge_node:
display_name: "{{ item.key }}"
description: 'Edge Node created by Ansible'
form_factor: "{{ item.value.form_factor }}"
vsphere_cluster: "{{ item.value.cluster }}"
data_network_ids:
- "{{ item.value.portgroupTransport }}"
- "{{ item.value.portgroupExt }}"
- "{{ item.value.portgroupTransport }}"
management_network_id: "{{ item.value.portgroup }}"
management_port_subnet: "{{ item.value.ip }}"
management_port_prefix: "{{ item.value.mask }}"
default_gateway_addresses:
- "{{ item.value.gw }}"
hostname: "{{ item.value.hostname }}"
storage_id: "{{ item.value.datastore }}"
vc_id: "{{ cmp_manager.id }}"
cli_password: "{{ item.value.cli_password }}"
root_password: "{{ item.value.root_password }}"
state: present
nsx_manager: "{{ nsxmanagers['nsx-manager'].ip }}"
nsx_username: 'admin'
nsx_passwd: "{{ nsxmanagers['nsx-manager'].password }}"
with_dict: "{{ nsxedges }}"
async: 7200
poll: 0
register: edgefnode
- name: Check if Edge Nodes are deployed
async_status:
jid: "{{ item.ansible_job_id }}"
register: job_result
until: job_result.finished
with_items: "{{ edgefnode.results }}"
retries: 80
- name: NSX-T Edge Transport Node
nsxt_transport_node:
display_name: "{{ item.key }}"
node_name: "{{ item.key }}"
transport_zone_endpoints:
- "overlay_tz"
- "edge_uplink_vlan_tz"
host_switch:
- name: "nvds1"
pnics:
uplink-1: "{{ item.value.overlay_interface }}"
uplink_profile: "{{ edge_uplink_profile_name }}"
static_ip_pool_id: "{{ ippool.id }}"
- name: "edge_uplink_nvds"
pnics:
uplink-1: "{{ item.value.uplink_interface }}"
uplink_profile: "{{ edge_uplink_profile_name }}"
state: present
nsx_manager: "{{ nsxmanagers['nsx-manager'].ip }}"
nsx_username: 'admin'
nsx_passwd: "{{ nsxmanagers['nsx-manager'].password }}"
with_dict: "{{ nsxedges }}"
register: edgetnode
- name: NSX-T Edge Cluster
nsxt_edge_cluster:
display_name: "{{ edge_cluster }}"
description: "Default Edge Cluster"
members:
- edge1
- edge2
tags:
"{{ tag_scope }}": "{{ tag }}"
state: present
nsx_manager: "{{ nsxmanagers['nsx-manager'].ip }}"
nsx_username: 'admin'
nsx_passwd: "{{ nsxmanagers['nsx-manager'].password }}"
when: edge_cluster is defined
register: edge_cluster
- name: NSX-T T0 Logical Router
nsxt_t0_logical_router:
display_name: "{{ t0_name }}"
description: "Default T0"
edge_cluster_id: "{{ edge_cluster.id }}"
high_availability_mode: "{{ t0_ha_mode }}"
tags:
"{{ tag_scope }}": "{{ tag }}"
state: present
nsx_manager: "{{ nsxmanagers['nsx-manager'].ip }}"
nsx_username: 'admin'
nsx_passwd: "{{ nsxmanagers['nsx-manager'].password }}"
when: t0_name is defined
register: t0
- name: NSX-T T1 Logical Router
nsxt_t1_logical_router:
display_name: "{{ t1_name }}"
description: "Management T1"
edge_cluster_id: "{{ edge_cluster.id }}"
connected_t0_id: "{{ t0.id }}"
state: present
nsx_manager: "{{ nsxmanagers['nsx-manager'].ip }}"
nsx_username: 'admin'
nsx_passwd: "{{ nsxmanagers['nsx-manager'].password }}"
when: t1_name is defined
register: t1
- name: NSX-T VLAN Logical Switch for t0 uplink
nsxt_logical_switch:
display_name: "uplink-{{ t0_vlan_uplink }}"
description: "T0 Uplink VLAN Logical Switch"
transport_zone_name: edge_uplink_vlan_tz
vlan: "{{ t0_vlan_uplink }}"
state: present
nsx_manager: "{{ nsxmanagers['nsx-manager'].ip }}"
nsx_username: 'admin'
nsx_passwd: "{{ nsxmanagers['nsx-manager'].password }}"
when: t0_vlan_uplink is defined
register: uplink_ls
- name: NSX-T Logical Switch Port for uplink1
nsxt_logical_switch_port:
display_name: "to_t0_uplink1"
description: "Logical Switch Port"
logical_switch_id: "{{ uplink_ls.id }}"
state: present
nsx_manager: "{{ nsxmanagers['nsx-manager'].ip }}"
nsx_username: 'admin'
nsx_passwd: "{{ nsxmanagers['nsx-manager'].password }}"
when: t0_vlan_uplink is defined
register: uplink_lsp
- name: NSX-T T0 Uplink 1
nsxt_t0_uplink:
display_name: "uplink-1"
description: "My Test T0 Uplink"
edge_cluster_member: "edge1"
urpf: 'NONE'
t0_router: "{{ t0_name }}"
logical_switch_port_id: "{{ uplink_lsp.id }}"
ip_address: "{{ t0_ip1 }}"
state: present
nsx_manager: "{{ nsxmanagers['nsx-manager'].ip }}"
nsx_username: 'admin'
nsx_passwd: "{{ nsxmanagers['nsx-manager'].password }}"
when: t0_vlan_uplink is defined
register: t0uplink1
- name: NSX-T Logical Switch Port for uplink2
nsxt_logical_switch_port:
display_name: "to_t0_uplink2"
description: "Logical Switch Port"
logical_switch_id: "{{ uplink_ls.id }}"
state: present
nsx_manager: "{{ nsxmanagers['nsx-manager'].ip }}"
nsx_username: 'admin'
nsx_passwd: "{{ nsxmanagers['nsx-manager'].password }}"
when: t0_vlan_uplink is defined
register: uplink_lsp2
- name: NSX-T T0 Uplink 2
nsxt_t0_uplink:
display_name: "uplink-2"
description: "My Test T0 Uplink"
edge_cluster_member: "edge2"
urpf: 'NONE'
t0_router: "{{ t0_name }}"
logical_switch_port_id: "{{ uplink_lsp2.id }}"
ip_address: "{{ t0_ip2 }}"
state: present
nsx_manager: "{{ nsxmanagers['nsx-manager'].ip }}"
nsx_username: 'admin'
nsx_passwd: "{{ nsxmanagers['nsx-manager'].password }}"
when: t0_vlan_uplink is defined
register: t0uplink2
- name: NSX-T T0 HA VIP
nsxt_t0_ha_vip:
vip_address: "{{ t0_vip}}"
enabled: True
t0_router: "{{ t0_name }}"
redundant_uplink_port_ids:
- "{{ t0uplink1.id }}"
- "{{ t0uplink2.id }}"
state: present
nsx_manager: "{{ nsxmanagers['nsx-manager'].ip }}"
nsx_username: 'admin'
nsx_passwd: "{{ nsxmanagers['nsx-manager'].password }}"
when: t0_vlan_uplink is defined
register: havip
- name: NSX-T T0 Default Static route
nsxt_static_route:
network: '0.0.0.0/0'
next_hops:
- "{{ t0_gw }}"
admin_distance: 1
description: "Default Static Route"
router_name: "{{ t0_name }}"
state: present
nsx_manager: "{{ nsxmanagers['nsx-manager'].ip }}"
nsx_username: 'admin'
nsx_passwd: "{{ nsxmanagers['nsx-manager'].password }}"
register: stroute
- name: NSX-T Logical Switch
nsxt_logical_switch:
display_name: "{{ ls_name }}"
description: "Management Logical Switch"
transport_zone_name: overlay_tz
state: present
nsx_manager: "{{ nsxmanagers['nsx-manager'].ip }}"
nsx_username: 'admin'
nsx_passwd: "{{ nsxmanagers['nsx-manager'].password }}"
when: ls_name is defined
register: lsswitch
- name: NSX-T Logical Switch Port
nsxt_logical_switch_port:
display_name: "LSPort"
description: "Logical Switch Port"
logical_switch_id: "{{ lsswitch.id }}"
state: present
nsx_manager: "{{ nsxmanagers['nsx-manager'].ip }}"
nsx_username: 'admin'
nsx_passwd: "{{ nsxmanagers['nsx-manager'].password }}"
when: ls_name is defined
register: lsp
- name: NSX-T Logical Router Downlink Port
nsxt_logical_router_downlink_port:
display_name: "DwnPort"
description: "Logical Router Downlink Port"
logical_router_id: "{{ t1.id }}"
linked_logical_switch_port_id: "{{ lsp.id }}"
subnets:
- ip_addresses: "{{ t1_ip }}"
prefix_length: "{{ t1_mask }}"
state: present
nsx_manager: "{{ nsxmanagers['nsx-manager'].ip }}"
nsx_username: 'admin'
nsx_passwd: "{{ nsxmanagers['nsx-manager'].password }}"
when: t1_ip is defined
register: lrdp