forked from CiscoDevNet/sdwan-devops
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig-vmware.yml
230 lines (207 loc) · 6.3 KB
/
config-vmware.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
- name: Check playbook requirements
hosts: localhost
connection: network_cli
tags:
- network
- CA
any_errors_fatal: true
gather_facts: no
tasks:
- name: Check for the license file
stat:
path: "{{ sdwan_serial_file }}"
register: stat_result
delegate_to: localhost
run_once: yes
- assert:
that:
- stat_result.stat.exists
- vmanage_org != ""
msg: "'vmanage_org' must be defined and {{ sdwan_serial_file }} must exist. Verify the requirements in README are met."
delegate_to: localhost
run_once: yes
- name: Push NETCONF template
hosts: sdwan_control
connection: netconf
tags:
- netconf
any_errors_fatal: true
gather_facts: no
tasks:
- netconf_config:
content: "{{ lookup('template', 'sdwan/netconf/system.j2') }}"
- name: Copy CA to controllers
hosts: vbond_hosts:vsmart_hosts
tags:
- control
- debug
any_errors_fatal: true
gather_facts: no
connection: network_cli
vars:
ansible_network_os: ios
tasks:
- name: Copy Root CA to controllers
net_put:
src: "{{ sdwan_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: Verify that vManage is fully operational
hosts: localhost
connection: local
tags:
- check_control
- check_all
- control
- CA
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 | default(hostvars[vmanage_host].sdwan_transport_ip) }}"
- name: Waiting for vManage API to start
uri:
url: "https://{{ vmanage_ip }}/dataservice/system/device/controllers"
method: POST
body:
j_username: "{{ vmanage_user }}"
j_password: "{{ vmanage_pass }}"
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: Configure vmanage
hosts: localhost
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 | default(hostvars[vmanage_host].sdwan_transport_ip) }}"
- set_fact:
vbond_controller: "{{ groups.vbond_hosts[0] }}"
- name: vManage Settings
vmanage_settings:
host: "{{ vmanage_ip }}"
user: "{{ vmanage_user }}"
password: "{{ vmanage_pass }}"
organization: "{{ vmanage_org }}"
vbond: "{{ sdwan_vbond }}"
register: result
retries: 10
delay: 10
until: result is not failed
- name: Add Control Hosts
vmanage_device:
host: "{{ vmanage_ip }}"
user: "{{ vmanage_user }}"
password: "{{ vmanage_pass }}"
device_username: admin
device_password: admin
name: "{{ item }}"
personality: "{{ hostvars[item].sdwan_personality }}"
transport_ip: "{{ hostvars[item].sdwan_transport_ip }}"
loop: "{{ groups.vbond_hosts + groups.vsmart_hosts }}"
register: result
retries: 10
delay: 10
until: result is not failed
- name: Add the Enterprise CA
vmanage_settings:
host: "{{ vmanage_ip }}"
user: "{{ vmanage_user }}"
password: "{{ vmanage_pass }}"
ca_type: enterprise
root_cert: "{{lookup('file', '{{ sdwan_cert_dir }}/myCA.pem')}}"
register: result
retries: 10
delay: 10
until: result is not failed
- name: Generate CSRs
vmanage_device_certificate:
host: "{{ vmanage_ip }}"
user: "{{ vmanage_user }}"
password: "{{ vmanage_pass }}"
name: "{{ item }}"
transport_ip: "{{ hostvars[item].sdwan_transport_ip }}"
state: csr
loop: "{{ groups.sdwan_control }}"
register: control_devices
retries: 10
delay: 10
until: control_devices is not failed
- name: Write out CSR
copy:
content: "{{ item.deviceCSR }}"
dest: "{{ sdwan_cert_dir }}/{{ item.item }}.csr"
loop: "{{ control_devices.results }}"
delegate_to: localhost
- name: Sign Controller Cert
openssl_certificate:
csr_path: "{{ sdwan_cert_dir }}/{{ item }}.csr"
path: "{{ sdwan_cert_dir }}/{{ item }}.crt"
provider: ownca
ownca_path: "{{ sdwan_cert_dir }}/myCA.pem"
ownca_privatekey_path: "{{ sdwan_cert_dir }}/myCA.key"
ownca_privatekey_passphrase: "{{ sdwan_CA_passphrase }}"
loop: "{{ groups.sdwan_control }}"
delegate_to: localhost
- name: Add Certificate to Control Hosts
vmanage_device_certificate:
host: "{{ vmanage_ip }}"
user: "{{ vmanage_user }}"
password: "{{ vmanage_pass }}"
name: "{{ item }}"
transport_ip: "{{ hostvars[item].sdwan_transport_ip }}"
cert: "{{lookup('file', '{{ sdwan_cert_dir }}/{{ item }}.crt')}}"
loop: "{{ groups.sdwan_control }}"
register: result
retries: 10
delay: 10
until: result is not failed
- name: Push Certs to Controllers
vmanage_device_certificate:
host: "{{ vmanage_ip }}"
user: "{{ vmanage_user }}"
password: "{{ vmanage_pass }}"
state: push
register: result
retries: 10
delay: 10
until: result is not failed
- name: Install Serial File
vmanage_fileupload:
host: "{{ vmanage_ip }}"
user: "{{ vmanage_user }}"
password: "{{ vmanage_pass }}"
file: "{{ sdwan_serial_file }}"
delegate_to: localhost
register: result
retries: 10
delay: 10
until: result is not failed
- debug:
msg: "vManage IP: {{ vmanage_ip }}"
- import_playbook: import-templates.yml
- import_playbook: import-policy.yml
- import_playbook: attach-template.yml passed=vsmart_hosts