forked from vmware-archive/nsxansible
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_topology_w_ospf.yml
205 lines (198 loc) · 8 KB
/
test_topology_w_ospf.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
---
- hosts: localhost
connection: local
gather_facts: False
vars:
dlr_networks:
app1: {name: 'App1-Net', ip: '172.16.8.1', network: '172.16.8.0/24', prefix_len: 24, logical_switch: 'app1', iftype: 'internal'}
app2: {name: 'App2-Net', ip: '172.16.9.1', network: '172.16.9.0/24', prefix_len: 24, logical_switch: 'app2', iftype: 'internal'}
db1: {name: 'Db1-Net', ip: '172.16.10.1', network: '172.16.10.0/24', prefix_len: 24, logical_switch: 'db1', iftype: 'internal'}
web1: {name: 'Web1-Net', ip: '172.16.11.1', network: '172.16.11.0/24', prefix_len: 24, logical_switch: 'web1', iftype: 'internal'}
web2: {name: 'Web2-Net', ip: '172.16.12.1', network: '172.16.12.0/24', prefix_len: 24, logical_switch: 'web2', iftype: 'internal'}
web3: {name: 'Web3-Net', ip: '172.16.13.1', network: '172.16.13.0/24', prefix_len: 24, logical_switch: 'web3', iftype: 'internal'}
transit_net: {name: 'transit_net', ip: '172.24.1.2', prefix_len: 29, logical_switch: 'transit_net', iftype: 'uplink'}
esg_networks:
uplink: {name: 'uplink', ip: '10.114.209.94', prefix_len: 27, portgroup_id: "{{ gather_moids_upl_pg.object_id }}", iftype: 'uplink'}
transit_net: {name: 'transit_net', ip: '172.24.1.1', prefix_len: 29, logical_switch: 'transit_net', iftype: 'internal'}
vars_files:
- answerfile_TPM_Lab.yml
tasks:
- name: gather moid for ds
vcenter_gather_moids:
hostname: "{{ vcenter }}"
username: "{{ vcenter_user }}"
password: "{{ vcenter_pwd }}"
datacenter_name: "{{ vcenter_dc }}"
datastore_name: "{{ vcenter_datastore }}"
validate_certs: False
register: gather_moids_ds
tags: moids
- name: gather moid for cl
vcenter_gather_moids:
hostname: "{{ vcenter }}"
username: "{{ vcenter_user }}"
password: "{{ vcenter_pwd }}"
datacenter_name: "{{ vcenter_dc }}"
cluster_name: "{{ vcenter_edge_cluster }}"
validate_certs: False
register: gather_moids_cl
tags: moids
- name: gather moid for uplink vnic
vcenter_gather_moids:
hostname: "{{ vcenter }}"
username: "{{ vcenter_user }}"
password: "{{ vcenter_pwd }}"
datacenter_name: "{{ vcenter_dc }}"
portgroup_name: 'vlan41'
validate_certs: False
register: gather_moids_upl_pg
tags: moids
- name: gather moid for mgmt portgroup
vcenter_gather_moids:
hostname: "{{ vcenter }}"
username: "{{ vcenter_user }}"
password: "{{ vcenter_pwd }}"
datacenter_name: "{{ vcenter_dc }}"
portgroup_name: 'vlan45'
validate_certs: False
register: gather_moids_pg
tags: moids
- name: create logical switches
nsx_logical_switch:
nsxmanager_spec: "{{ nsxmanager_spec }}"
state: present
transportzone: "TZ1"
name: "{{ item.key }}"
controlplanemode: "HYBRID_MODE"
description: "{{ item.value.name }}"
with_dict: "{{ dlr_networks }}"
register: logical_switch
tags: lswitch_create
- name: ESG creation
nsx_edge_router:
nsxmanager_spec: "{{ nsxmanager_spec }}"
state: present
name: 'ansibleESG'
description: 'This ESG is created by nsxansible'
resourcepool_moid: "{{ gather_moids_cl.object_id }}"
datastore_moid: "{{ gather_moids_ds.object_id }}"
datacenter_moid: "{{ gather_moids_cl.datacenter_moid }}"
interfaces:
vnic0:
ip: "{{ esg_networks.uplink.ip }}"
prefix_len: "{{ esg_networks.uplink.prefix_len }}"
portgroup_id: "{{ esg_networks.uplink.portgroup_id }}"
name: "{{ esg_networks.uplink.name }}"
iftype: "{{ esg_networks.uplink.iftype }}"
vnic1:
ip: "{{ esg_networks.transit_net.ip }}"
prefix_len: "{{ esg_networks.transit_net.prefix_len }}"
logical_switch: "{{ esg_networks.transit_net.logical_switch }}"
name: "{{ esg_networks.transit_net.name }}"
iftype: "{{ esg_networks.transit_net.iftype }}"
default_gateway: '10.114.209.65'
remote_access: 'true'
username: 'admin'
password: 'VMware1!VMware1!'
firewall: 'false'
ha_enabled: 'true'
register: create_esg
tags: esg_create
- name: DLR creation
nsx_dlr:
nsxmanager_spec: "{{ nsxmanager_spec }}"
state: present
name: 'ansibleDLR'
description: 'This DLR is created by nsxansible'
resourcepool_moid: "{{ gather_moids_cl.object_id }}"
datastore_moid: "{{ gather_moids_ds.object_id }}"
datacenter_moid: "{{ gather_moids_cl.datacenter_moid }}"
mgmt_portgroup_moid: "{{ gather_moids_pg.object_id }}"
interfaces:
- name: "{{ dlr_networks.app1.name }}"
ip: "{{ dlr_networks.app1.ip }}"
prefix_len: "{{ dlr_networks.app1.prefix_len }}"
logical_switch: "{{ dlr_networks.app1.logical_switch }}"
iftype: "{{ dlr_networks.app1.iftype }}"
- name: "{{ dlr_networks.app2.name }}"
ip: "{{ dlr_networks.app2.ip }}"
prefix_len: "{{ dlr_networks.app2.prefix_len }}"
logical_switch: "{{ dlr_networks.app2.logical_switch }}"
iftype: "{{ dlr_networks.app2.iftype }}"
- name: "{{ dlr_networks.db1.name }}"
ip: "{{ dlr_networks.db1.ip }}"
prefix_len: "{{ dlr_networks.db1.prefix_len }}"
logical_switch: "{{ dlr_networks.db1.logical_switch }}"
iftype: "{{ dlr_networks.db1.iftype }}"
- name: "{{ dlr_networks.web1.name }}"
ip: "{{ dlr_networks.web1.ip }}"
prefix_len: "{{ dlr_networks.web1.prefix_len }}"
logical_switch: "{{ dlr_networks.web1.logical_switch }}"
iftype: "{{ dlr_networks.web1.iftype }}"
- name: "{{ dlr_networks.web2.name }}"
ip: "{{ dlr_networks.web2.ip }}"
prefix_len: "{{ dlr_networks.web2.prefix_len }}"
logical_switch: "{{ dlr_networks.web2.logical_switch }}"
iftype: "{{ dlr_networks.web2.iftype }}"
- name: "{{ dlr_networks.web3.name }}"
ip: "{{ dlr_networks.web3.ip }}"
prefix_len: "{{ dlr_networks.web3.prefix_len }}"
logical_switch: "{{ dlr_networks.web3.logical_switch }}"
iftype: "{{ dlr_networks.web3.iftype }}"
- name: "{{ dlr_networks.transit_net.name }}"
ip: "{{ dlr_networks.transit_net.ip }}"
prefix_len: "{{ dlr_networks.transit_net.prefix_len }}"
logical_switch: "{{ dlr_networks.transit_net.logical_switch }}"
iftype: "{{ dlr_networks.transit_net.iftype }}"
remote_access: 'true'
username: 'admin'
password: 'VMware1!VMware1!'
ha_enabled: 'true'
register: create_dlr
tags: dlr_create
# Setting the bellow fact is needed as the DLR OSPF module needs the DLR uplink vnic index in the OSPF Area Map
- set_fact:
dlr_uplink_index: "{{ item.index }}"
when: item.name == dlr_networks.transit_net.name
with_items: "{{ create_dlr.interfaces }}"
tags: dlr_create
- name: Configure OSPF ESG
nsx_ospf:
nsxmanager_spec: "{{ nsxmanager_spec }}"
state: present
edge_name: 'ansibleESG'
router_id: '10.114.209.94'
default_originate: True
ecmp: True
areas:
- { area_id: 0 }
- { area_id: 10 }
area_map:
- { area_id: 0, vnic: 0}
- { area_id: 10, vnic: 1}
register: ospf_esg
tags: ospf_esg
- name: Configure OSPF DLR
nsx_ospf:
nsxmanager_spec: "{{ nsxmanager_spec }}"
state: present
edge_name: 'ansibleDLR'
router_id: '172.24.1.3'
forwarding_address: '172.24.1.2'
protocol_address: '172.24.1.3'
areas:
- { area_id: 10 }
area_map:
- { area_id: 10, vnic: "{{ dlr_uplink_index }}" }
register: ospf_dlr
tags: ospf_dlr
- name: Configure OSPF Redistribution DLR
nsx_redistribution:
ospf_state: present
bgp_state: absent
nsxmanager_spec: "{{ nsxmanager_spec }}"
edge_name: 'ansibleDLR'
rules:
- {learner: 'ospf', priority: 0, static: false, connected: true, bgp: false, ospf: false, action: 'permit'}
register: redist
tags: redist