-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathconfigure.yml
377 lines (345 loc) · 10.2 KB
/
configure.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
- name: Check playbook reqiurements
hosts: localhost
connection: network_cli
tags:
- control
- edge
- CA
any_errors_fatal: true
gather_facts: no
tasks:
- name: Check for the license file
stat:
path: "{{ serial_number_file }}"
register: stat_result
delegate_to: localhost
run_once: yes
- assert:
that:
- stat_result.stat.exists
- organization_name != ""
msg: "'organization_name' must be defined and {{ serial_number_file }} must exist. Verify the requirements in README are met."
delegate_to: localhost
run_once: yes
- name: Check initial topology connectivity
hosts: internet
connection: network_cli
tags:
- check_control
- check_all
- control
- edge
- CA
any_errors_fatal: true
gather_facts: no
tasks:
- name: Ping outside interface of Internet routers
ios_ping:
dest: "{{ hostvars[item].interfaces.GigabitEthernet2.ip.primary | ipaddr('address') }}"
loop: "{{ groups.internet_routers | intersect(groups.virl_hosts) }}"
register: result
retries: 60
delay: 10
until: result is not failed
- name: Ping inside interface of Internet routers
ios_ping:
dest: "{{ hostvars[item].interfaces.GigabitEthernet3.ip.primary | ipaddr('address') }}"
loop: "{{ groups.internet_routers | intersect(groups.virl_hosts) }}"
register: result
retries: 60
delay: 10
until: result is not failed
- name: Verify that vManage is fully operational
hosts: localhost
connection: local
tags:
- check_control
- check_all
- control
- edge
- CA
any_errors_fatal: true
gather_facts: no
tasks:
- name: Waiting for vManage API to start
uri:
url: "https://{{ hostvars['vmanage1'].ansible_host }}/dataservice/system/device/controllers"
method: POST
body:
j_username: "{{ viptela_api_username }}"
j_password: "{{ viptela_api_password }}"
body_format: form-urlencoded
return_content: yes
validate_certs: no
no_log: true
register: uri_results
delegate_to: localhost
failed_when: false
until: uri_results.msg.find("OK") != -1
retries: 60
delay: 10
- name: Create local CA
hosts: localhost
connection: local
tags:
- control
- CA
any_errors_fatal: true
gather_facts: no
tasks:
- name: Ensure directory exists for local self-signed TLS certs.
file:
path: "{{ viptela_cert_dir }}"
state: directory
- name: Generate an OpenSSL private key.
openssl_privatekey:
cipher: des3
passphrase: "{{ viptela_CA_passphrase }}"
path: "{{ viptela_cert_dir }}/myCA.key"
- name: Generate an OpenSSL CSR.
openssl_csr:
path: "{{ viptela_cert_dir }}/myCA.csr"
privatekey_path: "{{ viptela_cert_dir }}/myCA.key"
privatekey_passphrase: "{{ viptela_CA_passphrase }}"
common_name: viptelaCA.local
- name: Generate a Self Signed OpenSSL certificate.
openssl_certificate:
path: "{{ viptela_cert_dir }}/myCA.pem"
privatekey_path: "{{ viptela_cert_dir }}/myCA.key"
privatekey_passphrase: "{{ viptela_CA_passphrase }}"
csr_path: "{{ viptela_cert_dir }}/myCA.csr"
# select_crypto_backend: pyopenssl
provider: selfsigned
- name: Configuring Viptela components
hosts: viptela_control:&virl_hosts
connection: netconf
tags:
- control
- netconf
any_errors_fatal: true
gather_facts: no
tasks:
- name: Push NETCONF template
netconf_config:
content: "{{ lookup('template', 'viptela/netconf.j2') }}"
- name: Check connetivty to Viptela control plane
hosts: internet_routers:&virl_hosts
connection: network_cli
tags:
- control
- edge
- check_control
- check_all
any_errors_fatal: true
gather_facts: no
tasks:
- ios_ping:
dest: "{{ hostvars[item].vpn_instances[0].interfaces[0].ip.address | ipaddr('address') }}"
loop: "{{ groups.viptela_control }}"
register: result
retries: 60
delay: 10
until: result is not failed
- name: Verify that vManage is fully operational
hosts: localhost
connection: local
tags:
- check_control
- check_all
- control
- edge
- CA
any_errors_fatal: true
gather_facts: no
tasks:
- name: Waiting for vManage API to start
uri:
url: "https://{{ hostvars['vmanage1'].ansible_host }}/dataservice/system/device/controllers"
method: POST
body:
j_username: "{{ viptela_api_username }}"
j_password: "{{ viptela_api_password }}"
body_format: form-urlencoded
return_content: yes
validate_certs: no
no_log: true
register: uri_results
delegate_to: localhost
failed_when: false
until: uri_results.msg.find("OK") != -1
retries: 60
delay: 10
- name: Copy CA to controllers
hosts: vbond1:vsmart1
tags:
- control
- debug
any_errors_fatal: true
gather_facts: no
vars:
ansible_network_os: ios
tasks:
- name: Copy Root CA to controllers
copy:
src: "{{ viptela_cert_dir }}/myCA.pem"
dest: /home/admin
register: copy_results
- name: Install RootCA
cli_command:
command: "request root-cert-chain install /home/admin/myCA.pem"
register: command_result
connection: network_cli
failed_when: "'Failed' in command_result.stdout"
- name: Configure vmanage
hosts: vmanage1
connection: local
roles:
- ansible-viptela
tags:
- control
- vmanage
any_errors_fatal: true
gather_facts: no
tasks:
- set_fact:
vmanage_host: "{{ groups.vmanage_hosts | first }}"
- set_fact:
vmanage_ip: "{{ hostvars[vmanage_host].ansible_host }}"
- debug:
msg: "vManage IP: {{ vmanage_ip }}"
- name: Set organization
include_role:
name: ansible-viptela
tasks_from: set-org
vars:
org_name: "{{ organization_name }}"
- set_fact:
vbond_controller: "{{ groups.vbond_hosts[0] }}"
- name: Set vBond
include_role:
name: ansible-viptela
tasks_from: set-vbond
vars:
vbond_ip: "{{ hostvars[vbond_controller].viptela.transport_ip }}"
- name: Set Enterprise Root CA
include_role:
name: ansible-viptela
tasks_from: set-rootca
vars:
root_cert: "{{lookup('file', '{{ viptela_cert_dir }}/myCA.pem')}}"
- name: Add vBond Hosts
include_role:
name: ansible-viptela
tasks_from: add-controller
vars:
device_hostname: "{{ item }}"
device_ip: "{{ hostvars[item].viptela.transport_ip }}"
device_personality: vbond
loop: "{{ groups.vbond_hosts }}"
- name: Add vSmart Hosts
include_role:
name: ansible-viptela
tasks_from: add-controller
vars:
device_hostname: "{{ item }}"
device_ip: "{{ hostvars[item].viptela.transport_ip }}"
device_personality: vsmart
loop: "{{ groups.vsmart_hosts }}"
- name: Get Controler CSR
include_role:
name: ansible-viptela
tasks_from: get-csr
vars:
device_ip: "{{ hostvars[item].viptela.transport_ip }}"
device_hostname: "{{ item }}"
csr_filename: "{{ viptela_cert_dir }}/{{ item }}.csr"
loop: "{{ groups.viptela_control }}"
- name: Sign Controller Cert
openssl_certificate:
csr_path: "{{ viptela_cert_dir }}/{{ item }}.csr"
path: "{{ viptela_cert_dir }}/{{ item }}.crt"
provider: ownca
ownca_path: "{{ viptela_cert_dir }}/myCA.pem"
ownca_privatekey_path: "{{ viptela_cert_dir }}/myCA.key"
ownca_privatekey_passphrase: "{{ viptela_CA_passphrase }}"
# select_crypto_backend: pyopenssl
loop: "{{ groups.viptela_control }}"
delegate_to: localhost
- name: Install Controller Certificate
include_role:
name: ansible-viptela
tasks_from: install-cert
vars:
device_cert: "{{lookup('file', '{{ viptela_cert_dir }}/{{ item }}.crt')}}"
loop: "{{ groups.viptela_control }}"
- name: Install Serial File
vmanage_fileupload:
host: "{{ vmanage_ip }}"
user: "{{ ansible_user }}"
password: "{{ ansible_password }}"
file: "{{ serial_number_file }}"
delegate_to: localhost
- name: Configuring vEdges
hosts: viptela_vedge:&virl_hosts
connection: netconf
tags:
- edge
- netconf
any_errors_fatal: true
gather_facts: no
tasks:
- name: Push NETCONF template
netconf_config:
content: "{{ lookup('template', 'viptela/netconf.j2') }}"
- name: Check connetivty to edges
hosts: colo_routers:&virl_hosts
tags:
- edge
- check_all
- check_edge
any_errors_fatal: true
connection: network_cli
gather_facts: no
tasks:
- ios_ping:
dest: "{{ hostvars[item].vpn_instances[0].interfaces[0].ip.address | ipaddr('address') }}"
loop: "{{ groups.viptela_vedge | intersect(groups.virl_hosts) }}"
when: hostvars[item].vpn_instances is defined
register: result
retries: 60
delay: 10
until: result is not failed
- name: Bootstrap vEdges
hosts: viptela_vedge:&virl_hosts
tags:
- edge
any_errors_fatal: true
gather_facts: no
serial: 1
vars:
viptela_api_username: admin
viptela_api_password: admin
viptela_cert_dir: "{{ lookup('env', 'PWD') }}/myCA"
ansible_network_os: ios
tasks:
- set_fact:
vmanage_host: "{{ groups.vmanage_hosts | first }}"
- set_fact:
vmanage_ip: "{{ hostvars[vmanage_host].ansible_host }}"
- name: Bootstrap vEdge
include_role:
name: ansible-viptela
tasks_from: bootstrap-vedge
vars:
device_ip: "{{ hostvars[item].ansible_host }}"
root_ca_file: "{{ viptela_cert_dir }}/myCA.pem"
- name: Do the thing
uri:
url: "https://{{ hostvars['vmanage1'].ansible_host }}/dataservice/system/device/sync/rootcertchain"
method: GET
headers:
Cookie: "{{ viptela_api_cookie }}"
validate_certs: no
return_content: yes
register: uri_results
delegate_to: localhost