forked from scoop206/ursula
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbranch-validation.yml
More file actions
332 lines (293 loc) · 10.4 KB
/
branch-validation.yml
File metadata and controls
332 lines (293 loc) · 10.4 KB
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
# playbook for validating a branch for release tagging
# interactive, may prompt runner to affirm things have completed
---
- name: Run rally and validate
hosts: localhost
gather_facts: false
tasks:
- name: run rally
pause: prompt="Was rally validation run successful? (yes/no)"
register: rally
- name: assert rally successful
assert:
that: rally.user_input|bool
- name: test instance connectivity
hosts: controller[0]
tasks:
### Build up
- name: create keypair
os_keypair:
auth:
username: admin
project_name: admin
password: "{{ secrets.admin_password }}"
auth_url: "http://127.0.0.1:{{ endpoints.keystone_admin.port.backend_api }}/{{ endpoints.keystone.version }}"
name: validate
state: present
register: keypair
- name: persist private key
copy:
content: "{{ keypair.key.private_key }}"
dest: /root/validate-key
mode: 0600
when: keypair.changed
- name: create security group
os_security_group:
auth:
username: admin
project_name: admin
password: "{{ secrets.admin_password }}"
auth_url: "http://127.0.0.1:{{ endpoints.keystone_admin.port.backend_api }}/{{ endpoints.keystone.version }}"
name: validate_ssh
description: "validate group allowing ssh, icmp ipv4 ingress"
state: present
- name: create security group rules
os_security_group_rule:
auth:
username: admin
project_name: admin
password: "{{ secrets.admin_password }}"
auth_url: "http://127.0.0.1:{{ endpoints.keystone_admin.port.backend_api }}/{{ endpoints.keystone.version }}"
security_group: validate_ssh
protocol: "{{ item.ip_protocol }}"
port_range_min: "{{ item.from_port }}"
port_range_max: "{{ item.to_port }}"
remote_ip_prefix: "{{ item.cidr }}"
state: present
with_items:
- ip_protocol: tcp
from_port: 22
to_port: 22
cidr: 0.0.0.0/0
- ip_protocol: icmp
from_port: -1
to_port: -1
cidr: 0.0.0.0/0
state: present
- name: launch instances in each host az
os_server:
auth:
username: admin
project_name: admin
password: "{{ secrets.admin_password }}"
auth_url: "http://127.0.0.1:{{ endpoints.keystone_admin.port.backend_api }}/{{ endpoints.keystone.version }}"
flavor: 1
image: cirros
key_name: validate
auto_floating_ip: no
security_groups: default,validate_ssh
#floating_ip_pools:
# - external
nics:
- net-name: internal
availability_zone: "nova:{{ item }}"
name: validate-{{ item }}
wait: "yes"
with_items: groups['compute']
register: instances
- name: associate a floating ip
os_floating_ip:
auth:
username: admin
project_name: admin
password: "{{ secrets.admin_password }}"
auth_url: "http://127.0.0.1:{{ endpoints.keystone_admin.port.backend_api }}/{{ endpoints.keystone.version }}"
network: external
server: validate-{{ groups['compute'][0] }}
reuse: true
register: fip
- name: wait for instances to be reachable
wait_for:
port: 22
delay: 5
timeout: 300
host: "{{ fip.floating_ip.floating_ip_address }}"
### Node connectivity tests
- name: cross-node inter-instance connectivity test
command: ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no
-o IdentityFile=/root/validate-key
cirros@{{ fip.floating_ip.floating_ip_address }}
ping -c 5 {{ item.private_ip }}
changed_when: false
register: pings
until: pings|success
delay: 1
retries: 5
with_items: instances.results
- name: instance internet connectivity test w/ floating-ip
command: ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no
-o IdentityFile=/root/validate-key
cirros@{{ fip.floating_ip.floating_ip_address }}
ping -c 5 google.com
changed_when: false
register: pings
until: pings|success
delay: 1
retries: 5
- name: wait for user to login
pause: prompt="From {{ groups['controller'][0] }} ssh -o
UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no
-o IdentityFile=/root/validate-key
cirros@{{ fip.floating_ip.floating_ip_address }}
(press enter when done)"
- name: disassociate the floating ip
os_floating_ip:
auth:
username: admin
project_name: admin
password: "{{ secrets.admin_password }}"
auth_url: "http://127.0.0.1:{{ endpoints.keystone_admin.port.backend_api }}/{{ endpoints.keystone.version }}"
network: external
server: validate-{{ groups['compute'][0] }}
floating_ip_address: "{{ fip.floating_ip.floating_ip_address }}"
state: absent
- name: instance internet connectivity test w/out floating-ip
pause: prompt="Can you ping -c 5 google.com ? (yes/no)"
register: ping
- name: assert ping
assert:
that: ping.user_input|bool
### HA testing
- name: add floating IPs to instances on controllers
os_floating_ip:
auth:
username: admin
project_name: admin
password: "{{ secrets.admin_password }}"
auth_url: "http://127.0.0.1:{{ endpoints.keystone_admin.port.backend_api }}/{{ endpoints.keystone.version }}"
network: external
server: validate-{{ item }}
reuse: true
register: fip_controllers
with_items: groups['controller']
- name: add floating ip to a non-controller instance
os_floating_ip:
auth:
username: admin
project_name: admin
password: "{{ secrets.admin_password }}"
auth_url: "http://127.0.0.1:{{ endpoints.keystone_admin.port.backend_api }}/{{ endpoints.keystone.version }}"
network: external
server: validate-{{ item }}
reuse: true
register: fip_compute
with_items:
- "{{ (groups['compute']|difference(groups['controller']))[0] }}"
- name: floating ips are reachable
command: ping -c 5 {{ item.floating_ip.floating_ip_address }}
with_items: fip_controllers.results + fip_compute.results
changed_when: false
register: pings
until: pings|success
delay: 1
retries: 5
delegate_to: localhost
- name: define ha master
set_fact: master=true
when: floating_ip in ansible_all_ipv4_addresses
# initiate hard reboot on the current master controller
- name: initiate a failover on controller 0
shell: echo 'b' | tee /proc/sysrq-trigger
when: master is defined
- name: initiate a failover on controller 1
delegate_to: "{{ groups['controller'][1] }}"
shell: echo 'b' | tee /proc/sysrq-trigger
when: master is not defined
- name: wait for the panic
wait_for: host={{ inventory_hostname }} port=22 state=stopped delay=10
timeout=30
when: master is defined
delegate_to: localhost
- name: wait for the panic
wait_for: host={{ groups['controller'][1] }} port=22 state=stopped
delay=10 timeout=30
when: master is not defined
delegate_to: localhost
- name: wait for the node to boot
pause: seconds=30
- name: check non-controller instance connectivity by way of floating IPs
command: ping -c 5
{{ fip_compute.results[0].floating_ip.floating_ip_address }}
changed_when: false
register: pings
until: pings|success
delay: 1
retries: 5
delegate_to: localhost
- name: check remaining controller instance connectivity
command: ping -c 5
{{ fip_controllers.results[0].floating_ip.floating_ip_address }}
changed_when: false
register: pings
until: pings|success
delay: 1
retries: 5
when: master is not defined
delegate_to: localhost
- name: check remaining controller instance connectivity
command: ping -c 5
{{ fip_controllers.results[1].floating_ip.floating_ip_address }}
changed_when: false
register: pings
until: pings|success
delay: 1
retries: 5
delegate_to: localhost
when: master is defined
- name: wait for the reboot
wait_for: host={{ inventory_hostname }} port=22 delay=10
timeout=300
delegate_to: localhost
when: master is defined
- name: wait for the reboot
wait_for: host={{ groups['controller'][1] }} port=22 delay=10
timeout=300
delegate_to: localhost
when: master is not defined
- name: floating ips are reachable
command: ping -c 5 {{ item.floating_ip.floating_ip_address }}
with_items: fip_controllers.results + fip_compute.results
changed_when: false
register: pings
until: pings|success
delay: 1
retries: 5
delegate_to: localhost
### Tear down
- name: delete instances
os_server:
auth:
username: admin
project_name: admin
password: "{{ secrets.admin_password }}"
auth_url: "http://127.0.0.1:{{ endpoints.keystone_admin.port.backend_api }}/{{ endpoints.keystone.version }}"
name: validate-{{ item }}
state: absent
wait: "yes"
with_items: groups['compute']
tags: delete
- name: delete security group
os_security_group:
auth:
username: admin
project_name: admin
password: "{{ secrets.admin_password }}"
auth_url: "http://127.0.0.1:{{ endpoints.keystone_admin.port.backend_api }}/{{ endpoints.keystone.version }}"
name: validate_ssh
state: absent
tags: delete
- name: delete private key file
file:
dest: /root/validate-key
state: absent
tags: delete
- name: delete keypair
os_keypair:
auth:
username: admin
project_name: admin
password: "{{ secrets.admin_password }}"
auth_url: "http://127.0.0.1:{{ endpoints.keystone_admin.port.backend_api }}/{{ endpoints.keystone.version }}"
name: validate
state: absent
tags: delete