forked from redhat-cip/dci-openstack-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dci-openstack-agent.yml
381 lines (326 loc) · 10.9 KB
/
dci-openstack-agent.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
---
# Initial Step:
#
# Schedule a new job giving a specific topic and specifying the remote CI.
# The return of this action contains all the data associated with the job,
# we hence register those data for later consumptions
#
- hosts: localhost
tags:
- job
tasks:
- name: Schedule a new job
dci_job:
components: '{{ dci_components }}'
topic: '{{ dci_topic }}'
# id: '88fbd033-07b5-4cce-bb71-f320276cb0d0'
# embed: 'remoteci,topic,components'
register: job_info
- set_fact:
job_id: '{{ job_info.job.id }}'
job_informations: '{{ job_info }}'
- name: Notify about the job_informations deprecation
debug:
msg: |
The job_informations variable is deprecated.
Please use job_info instead in the hook files.
- name: Set the tags
dci_job:
id: "{{ job_id }}"
tags: '{{ dci_tags }}'
when: dci_tags
- name: 'Sanity check'
hosts: localhost
tags:
- new
vars:
dci_status: 'new'
tasks:
- block:
- name: Clean the files
include_tasks: plays/cleanup.yml
- name: Check the jumpbox sanity
include_tasks: plays/sanity_check.yml
- name: Purge old components
include_tasks: plays/purge_cache.yml
- name: Setup the http mirror
include_tasks: plays/prepare_local_mirror.yml
- name: Download and setup components
include_tasks: plays/fetch_bits.yml
rescue:
- name: Run the failure process
include_tasks: plays/failure.yml
# Pre-run state
#
# User is free to do whaterver she needs before entering pre-run state.
# Usually this is used to boot (not provision) the undercloud
#
- name: 'Spawning the environment'
hosts: localhost
tags:
- pre-run
vars:
dci_status: 'pre-run'
tasks:
- block:
- name: Run the pre-run process
include_tasks: '{{ dci_config_dir }}/hooks/pre-run.yml'
rescue:
- name: Run the teardown process
include_tasks: "{{ dci_config_dir }}/hooks/teardown.yml"
when: dci_teardown_on_failure|bool
- name: Run the failure process
include_tasks: plays/failure.yml
# Run state
#
# User is free to do whaterver she needs before entering running state.
# Usually this is used to provision both undercloud and the overcloud.
#
- name: 'Provision the undercloud and the overcloud'
hosts: localhost
tags:
- running
vars:
dci_status: 'running'
tasks:
- block:
- name: Retrieve information about the next topic
dci_topic:
id: '{{ job_info.job.topic.next_topic_id }}'
register: next
ignore_errors: yes
- set_fact:
next_topic_name: 'none'
- set_fact:
next_topic_name: "{{ next.topic.name }}"
when: "'topic' in next"
- set_fact:
# job_info may be redefined below. We need a set_fact here to
# store a static result.
update_playbook: '{{ dci_config_dir }}/hooks/update_{{ job_info.job.topic.name }}.yml'
upgrade_playbook: '{{ dci_config_dir }}/hooks/upgrade_from_{{ job_info.job.topic.name }}_to_{{ next_topic_name }}.yml'
# NOTE(Gonéri): Workaround for https://github.com/ansible/ansible/issues/23733
# tripleo-inventory depends on the common role, however the role is not include
# has it should when we use the include_role directive.
# Here we manually declare the deploy_supplemental_node variable to avoid an
# undefined value during the role execution
deploy_supplemental_node: No
- name: Test update case
stat:
path: '{{ update_playbook }}'
register: update_playbook_stat
- name: Test upgrade case
stat:
path: '{{ upgrade_playbook }}'
register: upgrade_playbook_stat
- name: Run the running process
include_tasks: '{{ dci_config_dir }}/hooks/running.yml'
- name: Add undercloud to inventory
include_tasks: plays/register_undercloud_host.yml
rescue:
# Included a second time in case of failure in hooks/running.yml,
# this is required for collect-logs to work
- name: Add undercloud to inventory
include_tasks: plays/register_undercloud_host.yml
- name: Run the collect logs process
include_tasks: plays/collect_logs.yml
- name: Run the upload logs process
include_tasks: plays/upload_logs.yml
- name: Run the teardown process
include_tasks: "{{ dci_config_dir }}/hooks/teardown.yml"
when: dci_teardown_on_failure|bool
- name: Clean the files
include_tasks: plays/cleanup.yml
- name: Run the failure process
include_tasks: plays/failure.yml
# Post-run state
#
# User is free to do whaterver she needs before entering post-run state.
# Usually this is used to run tests, certifications, etc...
#
- name: 'Openstack specific tests'
hosts: undercloud
tags:
- post-run
vars:
dci_status: 'post-run'
tasks:
- block:
- name: Run tests suite
include_tasks: plays/run_tests.yml
rescue:
- name: Run the collect logs process
include_tasks: plays/collect_logs.yml
- name: Run the upload logs process
include_tasks: plays/upload_logs.yml
- name: Run the teardown process
include_tasks: "{{ dci_config_dir }}/hooks/teardown.yml"
when: dci_teardown_on_failure|bool
- name: Clean the files
include_tasks: plays/cleanup.yml
- name: Run the failure process
include_tasks: plays/failure.yml
- name: 'Partner-specific tests'
hosts: undercloud
tags:
- post-run
vars:
dci_status: 'post-run'
tasks:
- name: Run the local tests process
include_tasks: "{{ dci_config_dir }}/hooks/local_tests.yml"
ignore_errors: yes
- name: 'Collect Openstack logs'
hosts: undercloud:overcloud
tags:
- post-run
vars:
dci_status: 'post-run'
undercloud_user: stack
working_dir: "/home/{{ undercloud_user }}"
local_working_dir: "{{ lookup('env', 'HOME') }}/.quickstart"
artcl_collect_dir: "{{ local_working_dir }}/collected_files"
artcl_gzip_only: false
artcl_tar_gz: true
roles:
- collect-logs
- name: 'Upload results and logs'
hosts: localhost
tags:
- post-run
vars:
dci_status: 'post-run'
tasks:
- name: Run the upload logs process
include_tasks: plays/upload_logs.yml
- name: 'Update the deployment'
hosts: localhost
tags:
- post-run
vars:
dci_status: 'post-run'
tasks:
- block:
- name: Schedule an update job
dci_job:
id: '{{ job_info.job.id }}'
update: True
register: new_job_info
# NOTE(Gonéri): avoid https://github.com/ansible/ansible/issues/4297
- set_fact:
job_info: '{{ new_job_info }}'
when: new_job_info.skipped is not defined
- name: Download and setup components
include_tasks: plays/fetch_bits.yml
- name: Run the update process
include_tasks: '{{ update_playbook }}'
when: update_playbook_stat.stat.exists
rescue:
- name: Run the collect logs process
include_tasks: plays/collect_logs.yml
- name: Run the upload logs process
include_tasks: plays/upload_logs.yml
- name: Run the teardown process
include_tasks: "{{ dci_config_dir }}/hooks/teardown.yml"
when: dci_teardown_on_failure|bool
- name: Clean the files
include_tasks: plays/cleanup.yml
- name: Run the failure process
include_tasks: plays/failure.yml
- name: 'Openstack specific tests after an Update'
hosts: undercloud
tags:
- post-run
vars:
dci_status: 'post-run'
tasks:
- block:
- name: Run tests suite
include_tasks: plays/run_tests.yml
when: hostvars.localhost.update_playbook_stat.stat.exists
rescue:
- name: Run the collect logs process
include_tasks: plays/collect_logs.yml
- name: Run the upload logs process
include_tasks: plays/upload_logs.yml
- name: Run the teardown process
include_tasks: "{{ dci_config_dir }}/hooks/teardown.yml"
when: dci_teardown_on_failure|bool
- name: Clean the files
include_tasks: plays/cleanup.yml
- name: Run the failure process
include_tasks: plays/failure.yml
- name: 'Upgrade the deployment'
hosts: localhost
tags:
- post-run
vars:
dci_status: 'post-run'
tasks:
- block:
- name: Schedule an upgrade job
dci_job:
id: '{{ job_info.job.id }}'
upgrade: True
register: new_job_info
- set_fact:
job_info: '{{ new_job_info }}'
when: new_job_info.skipped is not defined
- name: Download and setup components
include_tasks: plays/fetch_bits.yml
- name: Run the upgrade process
include_tasks: '{{ upgrade_playbook }}'
when: upgrade_playbook_stat.stat.exists
rescue:
- name: Run the collect logs process
include_tasks: plays/collect_logs.yml
- name: Run the upload logs process
include_tasks: plays/upload_logs.yml
- name: Run the teardown process
include_tasks: "{{ dci_config_dir }}/hooks/teardown.yml"
when: dci_teardown_on_failure|bool
- name: Clean the files
include_tasks: plays/cleanup.yml
- name: Run the failure process
include_tasks: plays/failure.yml
- name: 'Openstack specific tests after an Upgrade'
hosts: undercloud
tags:
- post-run
vars:
dci_status: 'post-run'
tasks:
- block:
- name: Run tests suite
include_tasks: plays/run_tests.yml
when: hostvars.localhost.upgrade_playbook_stat.stat.exists
rescue:
- name: Run the collect logs process
include_tasks: plays/collect_logs.yml
- name: Run the upload logs process
include_tasks: plays/upload_logs.yml
- name: Run the teardown process
include_tasks: "{{ dci_config_dir }}/hooks/teardown.yml"
when: dci_teardown_on_failure|bool
- name: Clean the files
include_tasks: plays/cleanup.yml
- name: Run the failure process
include_tasks: plays/failure.yml
# Success state
#
# User is free to do whaterver she needs before entering pre-run state.
# Usually this is used to teardown the plateform
#
- name: 'Successful installation'
hosts: localhost
tags:
- success
vars:
dci_status: 'success'
tasks:
- name: Run the success process
include_tasks: "{{ dci_config_dir }}/hooks/success.yml"
- name: Run the teardown process
include_tasks: "{{ dci_config_dir }}/hooks/teardown.yml"
- name: Clean the files
include_tasks: plays/cleanup.yml