-
Notifications
You must be signed in to change notification settings - Fork 1
/
new-vpx.yml
305 lines (251 loc) · 7.72 KB
/
new-vpx.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
---
- hosts: localhost
collections:
- citrix.adc
- citrix.adm
########################################################
#
# VARIABLES
#
vars_files:
- ./vars/CitrixCloud.yml # CitrixCloud
- ./vars/xen.yml # Hypervisor Credentials
#
# VPX informations need to be specified in extra var
# file at CLI
#
########################################################
########################################################
#
# TASKS
#
tasks:
- name: Create VPX from a template
xenserver_guest:
hostname: "{{ xen.ip }}"
username: "{{ xen.user }}"
password: "{{ xen.pw }}"
validate_certs: no
folder: "/adc"
name: "{{ adc.name }}"
state: poweredon
template: "{{ adc.vmTemplate }}"
disks:
- size_gb: 20
hardware:
num_cpus: 2
num_cpu_cores_per_socket: 1
memory_mb: 2048
networks:
- name: ADC-CNN-Demo-Network
wait_for_ip_address: yes
custom_params:
- key: xenstore_data
value: { "vm-data/ip" : "{{ adc.nsip }}" ,"vm-data/netmask" : "{{ adc.netmask }}", "vm-data/gateway" : "{{ adc.gateway }}" }
delegate_to: localhost
register: deploy
- name: Wait VPX coming up
uri:
url: "http://{{ adc.nsip }}"
status_code: 200
register: adc_http
until: adc_http.status == 200
retries: 60
delay: 1
- name: ADC VPX Password reset
delegate_to: localhost
ignore_errors: true
citrix_adc_password_reset:
nsip: "{{ adc.nsip }}"
username: "{{ adc.user }}"
nitro_protocol: https
validate_certs: no
password: nsroot
new_password: "{{ adc.password }}"
# ------------------------------------------------------
# do basic config stuff
# alternative: build jinja2 nsconf template and upload
# see: https://github.com/citrix/citrix-adc-ansible-modules/blob/master/docs/generic_modules/template_ns_conf.rst
#
- name: configure SNIP
delegate_to: localhost
citrix_adc_nitro_resource:
nsip: "{{ adc.nsip }}"
nitro_user: "{{ adc.user }}"
nitro_pass: "{{ adc.password }}"
nitro_protocol: https
validate_certs: no
# object check
state: present
workflow:
lifecycle: 'object'
endpoint: "nsip"
resource_missing_errorcode: 258
primary_id_attribute: "ipaddress"
resource:
ipaddress: "{{ adc.snip }}"
netmask: "{{ adc.netmask }}"
td: "0"
- name: configure DNS on ADC
delegate_to: localhost
citrix_adc_nitro_resource:
nsip: "{{ adc.nsip }}"
nitro_user: "{{ adc.user }}"
nitro_pass: "{{ adc.password }}"
nitro_protocol: https
validate_certs: no
# object check
state: present
workflow:
lifecycle: 'object'
endpoint: "dnsnameserver"
resource_missing_errorcode: 258
resource:
ip: "{{ adc.dns }}"
- name: configure NTP on ADC
delegate_to: localhost
citrix_adc_nitro_resource:
nsip: "{{ adc.nsip }}"
nitro_user: "{{ adc.user }}"
nitro_pass: "{{ adc.password }}"
nitro_protocol: https
validate_certs: no
# object check
state: present
workflow:
lifecycle: 'object'
endpoint: "ntpserver"
resource_missing_errorcode: 258
resource:
servername: "{{ adc.ntp }}"
# ------------------------------------------------------
# register in ADM service
#
- name: get Citrix Cloud token for ADM Service login
delegate_to: localhost
register: citrixcloud_login
citrix_citrixcloud_login:
id: "{{ citrixcloud.client_id }}"
secret: "{{ citrixcloud.client_secret }}"
customerid: "{{ citrixcloud.customer_id }}"
- name: get agent information
uri:
url: https://adm.cloud.com/massvc/CNCE94/nitro/v2/config/mps_agent?filter=Host%20Name%3Aadm-agent-cnce
method: GET
return_content: yes
status_code: 200
validate_certs: true
headers:
Content-Type: application/json
Authorization: "CwsAuth bearer={{ citrixcloud_login.token }}"
customerid: "{{ citrixcloud.customer_id }}"
isCloud: true
register: adm_agent
- name: add VPX to ADM
delegate_to: localhost
citrix_adm_managed_device:
adm_ip: "adm.cloud.com"
customerid: "{{ citrixcloud.customer_id }}"
cc_token: "{{ citrixcloud_login.token }}"
is_cloud: true
# set base information
agent_id: "{{ adm_agent['json']['mps_agent'][0]['id'] }}"
profile_name: "nsroot_helgeb"
ip_address: "{{ adc.nsip }}"
name: "{{ adc.name }}"
- name: wait for processing
pause:
seconds: 5
- name: get ADC device information
delegate_to: localhost
register: adm
citrix_adm_managed_device:
adm_ip: "adm.cloud.com"
customerid: "{{ citrixcloud.customer_id }}"
cc_token: "{{ citrixcloud_login.token }}"
is_cloud: true
# set base information
ip_address: "{{ adc.nsip }}"
name: "{{ adc.name }}"
# ------------------------------------------------------
# assign license from pool
#
- name: configure licenseserver on ADC
delegate_to: localhost
citrix_adc_nitro_resource:
nsip: "{{ adc.nsip }}"
nitro_user: "{{ adc.user }}"
nitro_pass: "{{ adc.password }}"
nitro_protocol: https
validate_certs: no
# object check
state: present
workflow:
lifecycle: 'object'
endpoint: "nslicenseserver"
resource_missing_errorcode: 258
primary_id_attribute: "licenseserverip"
resource:
licenseserverip: "{{ adm_agent['json']['mps_agent'][0]['name'] }}"
port: "27000"
- name: allocate license to VPX
uri:
url: "https://adm.cloud.com/massvc/{{ citrixcloud.customer_id }}/nitro/v2/config/managed_device?action=allocate_license"
method: POST
return_content: yes
status_code: 200
validate_certs: true
body_format: json
body: |
{
"managed_device" : {
"id": "{{ adm.managed_device.id }}",
"agent_id" : "{{ adm_agent['json']['mps_agent'][0]['id'] }}",
"license_edition": "Platinum",
"plt_bw_config" : "{{ adc.bandwidth }}"
}
}
headers:
Content-Type: application/json
Authorization: "CwsAuth bearer={{ citrixcloud_login.token }}"
customerid: "{{ citrixcloud.customer_id }}"
isCloud: true
register: adm_inventory
# ------------------------------------------------------
# SSL CERT files copy
#
- name: copy cert to ADC
delegate_to: localhost
citrix.adc.citrix_adc_system_file:
nsip: "{{ adc.nsip }}"
nitro_user: "{{ adc.user }}"
nitro_pass: "{{ adc.password }}"
validate_certs: no
state: present
filelocation: /nsconfig/ssl/
filename: wildcard_demo.local.crt
filecontent: "{{ lookup('file','wildcard_demo.local.crt') }}"
- name: copy key to ADC
delegate_to: localhost
citrix.adc.citrix_adc_system_file:
nsip: "{{ adc.nsip }}"
nitro_user: "{{ adc.user }}"
nitro_pass: "{{ adc.password }}"
validate_certs: no
state: present
filelocation: /nsconfig/ssl/
filename: wildcard_demo.local.key
filecontent: "{{ lookup('file','wildcard_demo.local.key') }}"
- name: Setup ssl certkey
delegate_to: localhost
citrix_adc_ssl_certkey:
nsip: "{{ adc.nsip }}"
nitro_user: "{{ adc.user }}"
nitro_pass: "{{ adc.password }}"
validate_certs: no
certkey: wildcard_demo_local
cert: wildcard_demo.local.crt
key: wildcard_demo.local.key
expirymonitor: enabled
notificationperiod: 30
inform: DER