-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathplaybook.yml
267 lines (249 loc) · 5.35 KB
/
playbook.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
---
# Checks if the machines are up and rechable.
- hosts: all
gather_facts: no
any_errors_fatal: true
tasks:
- name: Wait for machines to come up
delegate_to: localhost
wait_for:
port: 22
host: "{{ hostvars[inventory_hostname].ansible_host }}"
search_regex: OpenSSH
tags:
- standup
- install
- test
- cleanup
# Allows gathering of ansible_facts to discover the internal IPs of the
# servers.
- hosts: all
tasks:
- name: Collect ansible_facts to discover internal IPs
debug:
msg: Discovering internal IP...
tags:
- standup
- install
- test
- cleanup
# Update packages on all servers.
- hosts: all
gather_facts: false
become: True
tasks:
- name: Update packages
package:
name: "*"
state: latest
update_cache: yes
tags:
- install
# Install docker on all servers.
- hosts: all
gather_facts: false
become: True
vars:
pip_install_packages:
- name: docker
roles:
- geerlingguy.pip
- geerlingguy.docker
tags:
- install
# Install htop on all servers (Optional)
- hosts: all
gather_facts: false
become: True
roles:
- htop
tags:
- htop
# Stand up upstream services.
- hosts: upstream
gather_facts: false
become: True
vars_files:
- ./vars/tests.yml
- ./vars/services.yml
roles:
- upstream
tags:
- standup
# Benchmark upstream service
- hosts: load-generator
gather_facts: false
become: True
vars_files:
- ./vars/tests.yml
- ./vars/services.yml
tasks:
- name: Include load-generator role
vars:
label: upstream
include_role:
name: load-generator
when: (query_type == 'REST') and ('upstream' in test_services)
tags:
- test
# Stand up Tyk gateway dependencies
- hosts: tyk_dependencies
gather_facts: false
become: True
tasks:
- name: Include tyk-dependencies role
include_role:
name: tyk-dependencies
when: ('kong' in test_services) and (not ('saas' in ansible_run_tags))
tags:
- install
# Stand up Tyk gateway
- hosts: "{% if 'saas' in ansible_run_tags %}localhost{% else %}tyk{% endif %}"
gather_facts: false
become: True
vars_files:
- ./vars/tests.yml
- ./vars/services.yml
tasks:
- name: Include tyk role
include_role:
name: tyk
when: ('tyk' in test_services)
tags:
- install
- standup
# Benchmark Tyk gateway
- hosts: load-generator
gather_facts: false
become: True
vars_files:
- ./vars/tests.yml
- ./vars/services.yml
tasks:
- name: Include load-generator role
vars:
label: "{% if 'saas' in ansible_run_tags %}saas-{% endif %}tyk"
include_role:
name: load-generator
when: ('tyk' in test_services)
tags:
- test
# Stand up Kong dependencies gateway
- hosts: kong_dependencies
gather_facts: false
become: True
tasks:
- name: Include kong role
include_role:
name: kong-dependencies
when: (query_type == 'REST') and ('kong' in test_services)
tags:
- standup
# Stand up Kong gateway
- hosts: kong
gather_facts: false
become: True
vars_files:
- ./vars/tests.yml
- ./vars/services.yml
tasks:
- name: Include kong role
include_role:
name: kong
when: (query_type == 'REST') and ('kong' in test_services)
tags:
- standup
# Benchmark Kong gateway
- hosts: load-generator
gather_facts: false
become: True
vars_files:
- ./vars/tests.yml
- ./vars/services.yml
tasks:
- name: Include load-generator role
vars:
label: kong
include_role:
name: load-generator
when: (query_type == 'REST') and ('kong' in test_services)
tags:
- test
# Stand up Apollo server
- hosts: apollo
gather_facts: false
become: True
vars_files:
- ./vars/tests.yml
- ./vars/services.yml
tasks:
- name: Include apollo-server role
include_role:
name: apollo-server
when: (query_type != 'REST') and ('apollo' in test_services)
tags:
- install
- standup
# Benchmark Apollo server
- hosts: load-generator
gather_facts: false
become: True
vars_files:
- ./vars/tests.yml
- ./vars/services.yml
tasks:
- name: Include load-generator role
vars:
label: apollo
include_role:
name: load-generator
when: (query_type != 'REST') and ('apollo' in test_services)
tags:
- test
# Clean up upstream services
- hosts: upstream
gather_facts: false
become: True
vars_files:
- ./vars/tests.yml
roles:
- upstream
tags:
- cleanup
# Clean up Tyk gateway services
- hosts: tyk
gather_facts: false
become: True
tasks:
- name: Include tyk role
include_role:
name: tyk
when: ('tyk' in test_services) and (not ('saas' in ansible_run_tags))
tags:
- cleanup
# Clean up Kong gateway services
- hosts: kong
gather_facts: false
become: True
vars_files:
- ./vars/tests.yml
tasks:
- name: Include kong role
include_role:
name: kong
when: (query_type == 'REST') and ('kong' in test_services)
tags:
- cleanup
# Clean up Apollo services
- hosts: apollo
gather_facts: false
become: True
vars_files:
- ./vars/tests.yml
tasks:
- name: Include apollo-server role
include_role:
name: apollo-server
when: (query_type != 'REST') and ('apollo' in test_services)
tags:
- cleanup