prima-twig 0.62.17 → 0.62.100
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/twig-build +1983 -0
- data/bin/twig-feature +15 -2219
- data/bin/twig-update-ami +9 -3
- data/lib/prima_aws_client.rb +23 -0
- data/lib/prima_twig.rb +3 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4fbf412cf1f60d4446fa04c6910f1596dc2a7ce8188034d7f7f4c4f52e1f645
|
4
|
+
data.tar.gz: aa3da5c56b02af736ad54129451d19da575bc4a8e8f3d53709b3cc1aef088a58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d09fdcccff7dd6c255c2897735366198d73a587d74d4e144354cb69223a579ab4322fb23170431cd52ab8077aebb40aef4cf915e96cb490dbad0f19d4b6953a1
|
7
|
+
data.tar.gz: '03825b2b84bc6240ddd4ca9e8ff829ce744986f22f8095fbe69549fb647ec8d1fc9fdaa5bb4d41a57bdb49603f81d5e5fb82d50e8a13482d8497278617bf701a'
|
data/bin/twig-build
ADDED
@@ -0,0 +1,1983 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require_relative '../lib/prima_twig.rb'
|
5
|
+
require_relative '../lib/prima_aws_client.rb'
|
6
|
+
require 'digest'
|
7
|
+
require 'json'
|
8
|
+
require 'launchy'
|
9
|
+
require 'pp'
|
10
|
+
require 'redis'
|
11
|
+
|
12
|
+
class Build
|
13
|
+
include Command
|
14
|
+
include PrimaAwsClient
|
15
|
+
|
16
|
+
def initialize()
|
17
|
+
@prima = Prima.new
|
18
|
+
@batch = Aws::Batch::Client.new
|
19
|
+
@s3 = Aws::S3::Client.new
|
20
|
+
@s3_bucket = 'prima-artifacts'
|
21
|
+
@artifact_path = '/tmp/prima-artifact.zip'
|
22
|
+
@import_db_task = 'arn:aws:ecs:eu-west-1:001575623345:task-definition/ecs-task-db-restore2-TaskDefinitionDbRestore-4UBHMCZBE5WM:1'
|
23
|
+
@cf_role = 'arn:aws:iam::001575623345:role/qainit-service-role-cloudformat-CloudformationRole-18KBZQIS148R9'
|
24
|
+
@ecs_cluster_name = nil
|
25
|
+
@deploy_update = false
|
26
|
+
@qainit = false
|
27
|
+
@qainit_host_folder = "/var/ci/#{ENV['DRONE_REPO']}/#{ENV['DRONE_BRANCH']}/#{ENV['DRONE_BUILD_NUMBER']}"
|
28
|
+
@qainit_folder = "/drone/src/github.com/project/primait/qainit"
|
29
|
+
@projects = {
|
30
|
+
'prima' => {},
|
31
|
+
'urania' => {},
|
32
|
+
'ermes' => {},
|
33
|
+
'bburago' => {},
|
34
|
+
'hal9000' => {},
|
35
|
+
'fidaty' => {},
|
36
|
+
'peano' => {},
|
37
|
+
# 'rogoreport' => {},
|
38
|
+
'assange' => {},
|
39
|
+
'borat' => {},
|
40
|
+
'crash' => {},
|
41
|
+
'activia' => {},
|
42
|
+
'skynet' => {},
|
43
|
+
'roger' => {},
|
44
|
+
'rachele' => {},
|
45
|
+
'leftorium' => {},
|
46
|
+
'pyxis-npm' => {},
|
47
|
+
'starsky' => {},
|
48
|
+
'hutch' => {},
|
49
|
+
'maia' => {}
|
50
|
+
}
|
51
|
+
@base_stack_name_alb = 'ecs-alb-http-public-qa-'
|
52
|
+
@base_stack_name_alb_ws = 'ecs-alb-ws-public-qa-'
|
53
|
+
@git_branch = ENV['DRONE_BRANCH']
|
54
|
+
@cloudflare = Rubyflare.connect_with(ENV['CLOUDFLARE_EMAIL'], ENV['CLOUDFLARE_APIKEY'])
|
55
|
+
end
|
56
|
+
|
57
|
+
def execute!(args)
|
58
|
+
qainit_read_config!
|
59
|
+
abort('Non sei nella cartella di qainit') unless Dir.pwd.match 'qainit$' or Dir.pwd.match '/drone/src'
|
60
|
+
case args[0]
|
61
|
+
when 'infrastructure'
|
62
|
+
create_infrastructure_stacks! unless is_shutdown?
|
63
|
+
when 'project'
|
64
|
+
set_tags()
|
65
|
+
proj_method = "create_#{args[1]}_stack"
|
66
|
+
self.send(proj_method.to_sym) unless is_shutdown?
|
67
|
+
when 'complete'
|
68
|
+
if is_shutdown?
|
69
|
+
output 'Shutting down'.green
|
70
|
+
qainit_drone_shutdown!
|
71
|
+
else
|
72
|
+
complete_qa_setup!
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def is_shutdown?
|
78
|
+
return ENV['DRONE_COMMIT_MESSAGE'] == 'shutdown'
|
79
|
+
end
|
80
|
+
|
81
|
+
def qainit_drone_shutdown!
|
82
|
+
output "Recupero le informazioni sui QA attivi..."
|
83
|
+
stack_list, envs = get_stacks
|
84
|
+
|
85
|
+
env_hash = "qa-" + get_deploy_id
|
86
|
+
|
87
|
+
cluster_stack_name = nil
|
88
|
+
stacks_to_delete = []
|
89
|
+
stack_list.each do |stack|
|
90
|
+
if stack.stack_name.match(/#{env_hash}$/)
|
91
|
+
if stack.stack_name.match(/ecs-cluster/)
|
92
|
+
cluster_stack_name = stack.stack_name
|
93
|
+
else
|
94
|
+
break unless stack.stack_name.match(/#{env_hash}$/)
|
95
|
+
stacks_to_delete.push(stack.stack_name)
|
96
|
+
delete_stack(stack.stack_name)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
cluster_stack_name = "ecs-cluster-#{env_hash}"
|
102
|
+
if stack_exists?(cluster_stack_name)
|
103
|
+
aggregator_enabled = get_stack_tags(cluster_stack_name).detect do |tag|
|
104
|
+
tag.key === "hostname_pattern_priority" and tag.value === "1"
|
105
|
+
end.is_a?(Aws::CloudFormation::Types::Tag)
|
106
|
+
|
107
|
+
if aggregator_enabled
|
108
|
+
dns_to_staging(env_hash)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
# Se non ha finito di cancellare le altre non si puo' cancellare il cluster
|
113
|
+
output "Attendo 10 secondi per poter eliminare il cluster ECS"
|
114
|
+
|
115
|
+
while stacks_to_delete.length > 0
|
116
|
+
sleep 13
|
117
|
+
stacks_to_delete.each do |stack_name|
|
118
|
+
stacks_to_delete = stacks_to_delete - [stack_name] unless stack_exists?(stack_name)
|
119
|
+
end
|
120
|
+
output "Stack ancora attivi: #{stacks_to_delete.length.to_s}. Attendo altri 10 secondi per eliminare il cluster ECS"
|
121
|
+
end
|
122
|
+
|
123
|
+
delete_stack(cluster_stack_name) if stack_exists?(cluster_stack_name)
|
124
|
+
delete_stack(@base_stack_name_alb + env_hash[3..8]) if stack_exists?(@base_stack_name_alb + env_hash[3..8])
|
125
|
+
delete_stack(@base_stack_name_alb_ws + env_hash[3..8]) if stack_exists?(@base_stack_name_alb_ws + env_hash[3..8])
|
126
|
+
`git checkout master && git push origin --delete ${DRONE_BRANCH}`
|
127
|
+
output "Cancello il record DNS utilizzato da Lighthouse"
|
128
|
+
delete_lighthouse_dns()
|
129
|
+
output "Finito!".green
|
130
|
+
|
131
|
+
if @qainit
|
132
|
+
qainit_write_output("QA #{ENV["DRONE_BRANCH"]} spento.", 'Indirizzi scritti su ')
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
def qainit_write_output(file_message, output_message)
|
137
|
+
`mkdir -p /etc/qainit-output`
|
138
|
+
qa_file_name = "/etc/qainit-output/url_qa"
|
139
|
+
File.open(qa_file_name + '.txt', 'w') { |file| file.write(file_message) }
|
140
|
+
output "#{output_message} #{qa_file_name}".green
|
141
|
+
end
|
142
|
+
|
143
|
+
def qainit_read_config!()
|
144
|
+
projects = ''
|
145
|
+
|
146
|
+
File.open('branch_names', 'r') do |file|
|
147
|
+
file.each_line do |line|
|
148
|
+
projects = JSON.parse(line)
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
projects.each do |key, project|
|
153
|
+
@projects[key] = project
|
154
|
+
end
|
155
|
+
|
156
|
+
get_s3_config_files
|
157
|
+
@qainit = true
|
158
|
+
end
|
159
|
+
|
160
|
+
def get_s3_config_files
|
161
|
+
# manteniamo la struttura per lanciarlo facilmente anche da locale
|
162
|
+
`mkdir -p cloudformation/stacks/task cloudformation/stacks/route53 cloudformation/stacks/asg cloudformation/stacks/elb`
|
163
|
+
@s3.get_object({bucket: "prima-deploy", key: 'cloudformation/stacks/task/db.yml', response_target: 'cloudformation/stacks/task/db.yml'})
|
164
|
+
@s3.get_object({bucket: "prima-deploy", key: 'cloudformation/stacks/task/otel-agent.yml', response_target: 'cloudformation/stacks/task/otel-agent.yml'})
|
165
|
+
@s3.get_object({bucket: "prima-deploy", key: 'cloudformation/stacks/route53/qa.yml', response_target: 'cloudformation/stacks/route53/qa.yml'})
|
166
|
+
@s3.get_object({bucket: "prima-deploy", key: 'cloudformation/stacks/asg/ecs-asg-allinone.yml', response_target: 'cloudformation/stacks/asg/ecs-asg-allinone.yml'})
|
167
|
+
@s3.get_object({bucket: "prima-deploy", key: 'cloudformation/stacks/ecs-cluster.yml', response_target: 'cloudformation/stacks/ecs-cluster.yml'})
|
168
|
+
@s3.get_object({bucket: "prima-deploy", key: 'cloudformation/stacks/elb/alb-public-qa.yml', response_target: 'cloudformation/stacks/elb/alb-public-qa.yml'})
|
169
|
+
end
|
170
|
+
|
171
|
+
def get_deploy_id
|
172
|
+
if @deploy_id
|
173
|
+
@deploy_id
|
174
|
+
else
|
175
|
+
@deploy_id = Digest::MD5.hexdigest(ENV['DRONE_BRANCH'])
|
176
|
+
@deploy_id
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
def get_ecs_cluster_name
|
181
|
+
if @ecs_cluster_name
|
182
|
+
@ecs_cluster_name
|
183
|
+
else
|
184
|
+
cluster_stack_name = "ecs-cluster-qa-#{get_deploy_id}"
|
185
|
+
resp = describe_stack_resource(cluster_stack_name, 'ECSCluster')
|
186
|
+
@ecs_cluster_name = resp.stack_resource_detail.physical_resource_id
|
187
|
+
@ecs_cluster_name
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
def get_asg_stack_name
|
192
|
+
"ecs-asg-allinone-qa-#{get_deploy_id}"
|
193
|
+
end
|
194
|
+
|
195
|
+
def get_stack_name(service)
|
196
|
+
"ecs-task-#{service}-qa-#{get_deploy_id}"
|
197
|
+
end
|
198
|
+
|
199
|
+
def set_tags()
|
200
|
+
@tags = [
|
201
|
+
{
|
202
|
+
key: "qainit",
|
203
|
+
value: @git_branch
|
204
|
+
},
|
205
|
+
{
|
206
|
+
key: "hostname_pattern_priority",
|
207
|
+
value: hostname_pattern_priority
|
208
|
+
}
|
209
|
+
]
|
210
|
+
@projects.each do |key, value|
|
211
|
+
@tags << { key: key, value: value['name'] }
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
def create_infrastructure_stacks!
|
216
|
+
`git pull && git submodule init && git submodule update`
|
217
|
+
@ami_id = "ami-0e8a6f9c5de68157f"
|
218
|
+
deploy_id = get_deploy_id
|
219
|
+
stack_name_alb = 'ecs-alb-http-public-qa-' + deploy_id[0..5]
|
220
|
+
stack_name_alb_ws = 'ecs-alb-ws-public-qa-' + deploy_id[0..5]
|
221
|
+
unless @qainit
|
222
|
+
@projects.each_key do |project_key|
|
223
|
+
if @projects[project_key]['revision']
|
224
|
+
git_checkout_version(project_key, @projects[project_key]['revision'])
|
225
|
+
end
|
226
|
+
end
|
227
|
+
end
|
228
|
+
hostname_pattern_priority = hostname_pattern_priority()
|
229
|
+
|
230
|
+
set_tags()
|
231
|
+
|
232
|
+
cluster_stack_name = "ecs-cluster-qa-#{deploy_id}"
|
233
|
+
|
234
|
+
if stack_exists?(cluster_stack_name)
|
235
|
+
@tags = get_stack_tags(cluster_stack_name)
|
236
|
+
hostname_pattern_priority = @tags.detect do |tag|
|
237
|
+
tag.key == 'hostname_pattern_priority'
|
238
|
+
end.value
|
239
|
+
end
|
240
|
+
|
241
|
+
create_cluster_stack(cluster_stack_name, @tags) unless stack_exists?(cluster_stack_name)
|
242
|
+
wait_for_stack_ready(cluster_stack_name) unless stack_ready?(cluster_stack_name)
|
243
|
+
|
244
|
+
create_alb_stack(stack_name_alb, "http", deploy_id) unless stack_exists?(stack_name_alb)
|
245
|
+
create_alb_stack(stack_name_alb_ws, "websocket", deploy_id) unless stack_exists?(stack_name_alb_ws)
|
246
|
+
|
247
|
+
create_asg_stack(get_asg_stack_name, @tags) unless stack_exists?(get_asg_stack_name)
|
248
|
+
|
249
|
+
stack_name_db = "ecs-task-db-qa-#{deploy_id}"
|
250
|
+
stack_body = IO.read('cloudformation/stacks/task/db.yml')
|
251
|
+
parameters = [
|
252
|
+
{
|
253
|
+
parameter_key: "Environment",
|
254
|
+
parameter_value: "qa"
|
255
|
+
},
|
256
|
+
{
|
257
|
+
parameter_key: "ECSClusterName",
|
258
|
+
parameter_value: get_ecs_cluster_name
|
259
|
+
}
|
260
|
+
]
|
261
|
+
create_stack(stack_name_db, stack_body, parameters, @tags, @cf_role) unless stack_exists?(stack_name_db) # creazione asincrona stack dei db (~4 min)
|
262
|
+
|
263
|
+
output "check pyxis \n".yellow
|
264
|
+
|
265
|
+
wait_for_stack_ready(stack_name_db) unless stack_ready?(stack_name_db) # dovrebbe essere istantaneo
|
266
|
+
db_task = ''
|
267
|
+
db_task = import_dbs(get_ec2_ip_address) unless stack_exists?("ecs-route53-qa-#{deploy_id}") # import asincrono dei dati
|
268
|
+
|
269
|
+
wait_for_db_import(db_task) unless stack_exists?("ecs-route53-qa-#{deploy_id}") # dovrebbe essere istantaneo
|
270
|
+
|
271
|
+
import_redis_crash(get_ec2_ip_address) if !stack_exists?("ecs-task-web-qa-#{deploy_id}")
|
272
|
+
|
273
|
+
wait_for_stack_ready(stack_name_alb) unless stack_ready?(stack_name_alb)
|
274
|
+
wait_for_stack_ready(stack_name_alb_ws) unless stack_ready?(stack_name_alb_ws)
|
275
|
+
|
276
|
+
stack_name_route53 = "ecs-route53-qa-#{deploy_id}"
|
277
|
+
stack_body = IO.read('cloudformation/stacks/route53/qa.yml')
|
278
|
+
parameters = [
|
279
|
+
{
|
280
|
+
parameter_key: "DnsRecordIdentifier",
|
281
|
+
parameter_value: get_deploy_id
|
282
|
+
},
|
283
|
+
{
|
284
|
+
parameter_key: "PrimaElbHostname",
|
285
|
+
parameter_value: get_alb_host(stack_name_alb)
|
286
|
+
},
|
287
|
+
{
|
288
|
+
parameter_key: "UraniaIp",
|
289
|
+
parameter_value: get_ec2_ip_address
|
290
|
+
},
|
291
|
+
{
|
292
|
+
parameter_key: "BburagoIp",
|
293
|
+
parameter_value: get_ec2_ip_address
|
294
|
+
},
|
295
|
+
{
|
296
|
+
parameter_key: "Hal9000Ip",
|
297
|
+
parameter_value: get_ec2_ip_address
|
298
|
+
},
|
299
|
+
{
|
300
|
+
parameter_key: "FidatyIp",
|
301
|
+
parameter_value: get_ec2_ip_address
|
302
|
+
},
|
303
|
+
{
|
304
|
+
parameter_key: "PeanoIp",
|
305
|
+
parameter_value: get_ec2_ip_address
|
306
|
+
},
|
307
|
+
{
|
308
|
+
parameter_key: "ErmesIp",
|
309
|
+
parameter_value: get_ec2_ip_address
|
310
|
+
},
|
311
|
+
{
|
312
|
+
parameter_key: "ActiviaIp",
|
313
|
+
parameter_value: get_ec2_ip_address
|
314
|
+
},
|
315
|
+
{
|
316
|
+
parameter_key: "SkynetIp",
|
317
|
+
parameter_value: get_ec2_ip_address
|
318
|
+
},
|
319
|
+
{
|
320
|
+
parameter_key: "RogerIp",
|
321
|
+
parameter_value: get_ec2_ip_address
|
322
|
+
},
|
323
|
+
{
|
324
|
+
parameter_key: "LeftoriumIp",
|
325
|
+
parameter_value: get_ec2_ip_address
|
326
|
+
},
|
327
|
+
{
|
328
|
+
parameter_key: "RacheleIp",
|
329
|
+
parameter_value: get_ec2_ip_address
|
330
|
+
},
|
331
|
+
{
|
332
|
+
parameter_key: "RedisIp",
|
333
|
+
parameter_value: get_ec2_ip_address
|
334
|
+
},
|
335
|
+
{
|
336
|
+
parameter_key: "AssangeElbHostname",
|
337
|
+
parameter_value: get_alb_host(stack_name_alb)
|
338
|
+
},
|
339
|
+
{
|
340
|
+
parameter_key: "BoratElbHostname",
|
341
|
+
parameter_value: get_alb_host(stack_name_alb_ws)
|
342
|
+
},
|
343
|
+
{
|
344
|
+
parameter_key: 'CrashElbHostname',
|
345
|
+
parameter_value: get_alb_host(stack_name_alb_ws)
|
346
|
+
},
|
347
|
+
{
|
348
|
+
parameter_key: 'StarskyElbHostname',
|
349
|
+
parameter_value: get_alb_host(stack_name_alb)
|
350
|
+
},
|
351
|
+
{
|
352
|
+
parameter_key: 'HutchElbHostname',
|
353
|
+
parameter_value: get_alb_host(stack_name_alb)
|
354
|
+
},
|
355
|
+
{
|
356
|
+
parameter_key: 'MaiaElbHostname',
|
357
|
+
parameter_value: get_alb_host(stack_name_alb)
|
358
|
+
}
|
359
|
+
]
|
360
|
+
|
361
|
+
create_stack(stack_name_route53, stack_body, parameters, @tags, @cf_role) unless stack_exists?(stack_name_route53)
|
362
|
+
wait_for_stack_ready(stack_name_route53) unless stack_ready?(stack_name_route53)
|
363
|
+
|
364
|
+
stack_name_otel_agent = "ecs-task-otel-agent-qa-#{deploy_id}"
|
365
|
+
stack_body = IO.read('cloudformation/stacks/task/otel-agent.yml')
|
366
|
+
parameters = [
|
367
|
+
{
|
368
|
+
parameter_key: "Environment",
|
369
|
+
parameter_value: "qa"
|
370
|
+
},
|
371
|
+
{
|
372
|
+
parameter_key: "ClusterId",
|
373
|
+
parameter_value: get_ecs_cluster_name
|
374
|
+
},
|
375
|
+
{
|
376
|
+
parameter_key: "ConfigVersion",
|
377
|
+
parameter_value: "3.7.0"
|
378
|
+
}
|
379
|
+
]
|
380
|
+
create_stack(stack_name_otel_agent, stack_body, parameters, @tags, @cf_role) unless stack_exists?(stack_name_otel_agent)
|
381
|
+
end
|
382
|
+
|
383
|
+
def create_skynet_stack()
|
384
|
+
wait_for_artifact('prima-artifacts-encrypted', "microservices/skynet/#{@projects["skynet"]['revision']}-qa.tar.gz")
|
385
|
+
stack_name_skynet = get_stack_name("skynet")
|
386
|
+
git_checkout_version('skynet', @projects["skynet"]['revision'])
|
387
|
+
stack_body = File.read('projects/skynet/deploy/task.yml')
|
388
|
+
parameters = [
|
389
|
+
{
|
390
|
+
parameter_key: "Environment",
|
391
|
+
parameter_value: "qa"
|
392
|
+
},
|
393
|
+
{
|
394
|
+
parameter_key: "ReleaseVersion",
|
395
|
+
parameter_value: @projects["skynet"]['revision']
|
396
|
+
},
|
397
|
+
{
|
398
|
+
parameter_key: "TaskDesiredCount",
|
399
|
+
parameter_value: "1"
|
400
|
+
},
|
401
|
+
{
|
402
|
+
parameter_key: "ECSClusterName",
|
403
|
+
parameter_value: get_ecs_cluster_name
|
404
|
+
},
|
405
|
+
{
|
406
|
+
parameter_key: "HostnamePattern",
|
407
|
+
parameter_value: "skynet-#{get_deploy_id}.qa.colaster.com"
|
408
|
+
},
|
409
|
+
{
|
410
|
+
parameter_key: "HostnamePatternPriority",
|
411
|
+
parameter_value: hostname_pattern_priority
|
412
|
+
}
|
413
|
+
]
|
414
|
+
if stack_exists?(stack_name_skynet)
|
415
|
+
cur_version = get_currently_deployed_version(stack_name_skynet)
|
416
|
+
update_stack(stack_name_skynet, stack_body, parameters, @tags, @cf_role) unless cur_version.include?(@projects["skynet"]['revision'])
|
417
|
+
else
|
418
|
+
create_stack(stack_name_skynet, stack_body, parameters, @tags, @cf_role)
|
419
|
+
end
|
420
|
+
end
|
421
|
+
|
422
|
+
def create_urania_stack()
|
423
|
+
wait_for_artifact('prima-artifacts-encrypted', "microservices/urania/#{@projects["urania"]['revision']}-qa.tar.gz")
|
424
|
+
stack_name_urania = get_stack_name("urania")
|
425
|
+
git_checkout_version('urania', @projects["urania"]['revision'])
|
426
|
+
stack_body = File.read('projects/urania/deploy/task.yml')
|
427
|
+
parameters = [
|
428
|
+
{
|
429
|
+
parameter_key: "Environment",
|
430
|
+
parameter_value: "qa"
|
431
|
+
},
|
432
|
+
{
|
433
|
+
parameter_key: "ReleaseVersion",
|
434
|
+
parameter_value: @projects["urania"]['revision']
|
435
|
+
},
|
436
|
+
{
|
437
|
+
parameter_key: "TaskDesiredCount",
|
438
|
+
parameter_value: "1"
|
439
|
+
},
|
440
|
+
{
|
441
|
+
parameter_key: "ECSClusterName",
|
442
|
+
parameter_value: get_ecs_cluster_name
|
443
|
+
},
|
444
|
+
{
|
445
|
+
parameter_key: "HostnamePattern",
|
446
|
+
parameter_value: "urania-#{get_deploy_id}.qa.colaster.com"
|
447
|
+
},
|
448
|
+
{
|
449
|
+
parameter_key: "HostnamePatternPriority",
|
450
|
+
parameter_value: hostname_pattern_priority
|
451
|
+
}
|
452
|
+
]
|
453
|
+
if stack_exists?(stack_name_urania)
|
454
|
+
cur_version = get_currently_deployed_version(stack_name_urania)
|
455
|
+
update_stack(stack_name_urania, stack_body, parameters, @tags, @cf_role) unless cur_version.include?(@projects["urania"]['revision'])
|
456
|
+
else
|
457
|
+
create_stack(stack_name_urania, stack_body, parameters, @tags, @cf_role)
|
458
|
+
end
|
459
|
+
end
|
460
|
+
|
461
|
+
def create_ermes_stack()
|
462
|
+
wait_for_artifact('prima-artifacts-encrypted', "microservices/ermes/#{@projects["ermes"]['revision']}-qa.tar.gz")
|
463
|
+
stack_name_ermes = get_stack_name("ermes")
|
464
|
+
git_checkout_version('ermes', @projects["ermes"]['revision'])
|
465
|
+
stack_body = File.read('projects/ermes/deploy/task.yml')
|
466
|
+
parameters = [
|
467
|
+
{
|
468
|
+
parameter_key: "Environment",
|
469
|
+
parameter_value: "qa"
|
470
|
+
},
|
471
|
+
{
|
472
|
+
parameter_key: "ReleaseVersion",
|
473
|
+
parameter_value: "#{@projects['ermes']['revision']}"
|
474
|
+
},
|
475
|
+
{
|
476
|
+
parameter_key: "TaskDesiredCount",
|
477
|
+
parameter_value: "1"
|
478
|
+
},
|
479
|
+
{
|
480
|
+
parameter_key: "ECSClusterName",
|
481
|
+
parameter_value: get_ecs_cluster_name
|
482
|
+
},
|
483
|
+
{
|
484
|
+
parameter_key: "HostnamePattern",
|
485
|
+
parameter_value: "ermes-#{get_deploy_id}.qa.colaster.com"
|
486
|
+
},
|
487
|
+
{
|
488
|
+
parameter_key: "HostnamePatternPriority",
|
489
|
+
parameter_value: hostname_pattern_priority
|
490
|
+
},
|
491
|
+
{
|
492
|
+
parameter_key: "WebHost",
|
493
|
+
parameter_value: get_route53_hostname('ecs-task-web-qa-notneeded')
|
494
|
+
},
|
495
|
+
{
|
496
|
+
parameter_key: "PeanoHost",
|
497
|
+
parameter_value: get_route53_hostname('ecs-task-peano-qa-notneeded')
|
498
|
+
}
|
499
|
+
]
|
500
|
+
if stack_exists?(stack_name_ermes)
|
501
|
+
cur_version = get_currently_deployed_version(stack_name_ermes)
|
502
|
+
update_stack(stack_name_ermes, stack_body, parameters, @tags, @cf_role) unless cur_version.include?(@projects["ermes"]['revision'])
|
503
|
+
else
|
504
|
+
create_stack(stack_name_ermes, stack_body, parameters, @tags, @cf_role)
|
505
|
+
end
|
506
|
+
|
507
|
+
stack_name_ermes = get_stack_name("worker-ermes")
|
508
|
+
stack_body = File.read('projects/ermes/deploy/task-worker.yml')
|
509
|
+
parameters = [
|
510
|
+
{
|
511
|
+
parameter_key: "Environment",
|
512
|
+
parameter_value: "qa"
|
513
|
+
},
|
514
|
+
{
|
515
|
+
parameter_key: "ReleaseVersion",
|
516
|
+
parameter_value: "#{@projects['ermes']['revision']}"
|
517
|
+
},
|
518
|
+
{
|
519
|
+
parameter_key: "TaskDesiredCount",
|
520
|
+
parameter_value: "1"
|
521
|
+
},
|
522
|
+
{
|
523
|
+
parameter_key: "ECSClusterName",
|
524
|
+
parameter_value: get_ecs_cluster_name
|
525
|
+
},
|
526
|
+
{
|
527
|
+
parameter_key: "WebHost",
|
528
|
+
parameter_value: get_route53_hostname('ecs-task-web-qa-notneeded')
|
529
|
+
},
|
530
|
+
{
|
531
|
+
parameter_key: "PeanoHost",
|
532
|
+
parameter_value: get_route53_hostname('ecs-task-peano-qa-notneeded')
|
533
|
+
}
|
534
|
+
]
|
535
|
+
if stack_exists?(stack_name_ermes)
|
536
|
+
cur_version = get_currently_deployed_version(stack_name_ermes)
|
537
|
+
update_stack(stack_name_ermes, stack_body, parameters, @tags, @cf_role) unless cur_version.include?(@projects["ermes"]['revision'])
|
538
|
+
else
|
539
|
+
create_stack(stack_name_ermes, stack_body, parameters, @tags, @cf_role)
|
540
|
+
end
|
541
|
+
end
|
542
|
+
|
543
|
+
def create_bburago_stack()
|
544
|
+
wait_for_artifact('prima-artifacts-encrypted', "microservices/bburago/#{@projects["bburago"]['revision']}-qa.tar.gz")
|
545
|
+
|
546
|
+
stack_name_bburago = get_stack_name("bburago")
|
547
|
+
git_checkout_version('bburago', @projects["bburago"]['revision'])
|
548
|
+
stack_body = File.read('projects/bburago/deploy/task.yml')
|
549
|
+
parameters = [
|
550
|
+
{
|
551
|
+
parameter_key: "Environment",
|
552
|
+
parameter_value: "qa"
|
553
|
+
},
|
554
|
+
{
|
555
|
+
parameter_key: "ReleaseVersion",
|
556
|
+
parameter_value: @projects["bburago"]['revision']
|
557
|
+
},
|
558
|
+
{
|
559
|
+
parameter_key: "ECSClusterName",
|
560
|
+
parameter_value: get_ecs_cluster_name
|
561
|
+
},
|
562
|
+
{
|
563
|
+
parameter_key: "TaskDesiredCount",
|
564
|
+
parameter_value: "1"
|
565
|
+
},
|
566
|
+
{
|
567
|
+
parameter_key: "HostnamePattern",
|
568
|
+
parameter_value: "bburago-#{get_deploy_id}.qa.colaster.com"
|
569
|
+
},
|
570
|
+
{
|
571
|
+
parameter_key: "HostnamePatternPriority",
|
572
|
+
parameter_value: hostname_pattern_priority
|
573
|
+
}
|
574
|
+
]
|
575
|
+
if stack_exists?(stack_name_bburago)
|
576
|
+
cur_version = get_currently_deployed_version(stack_name_bburago)
|
577
|
+
update_stack(stack_name_bburago, stack_body, parameters, @tags, @cf_role) unless cur_version.include?(@projects["bburago"]['revision'])
|
578
|
+
else
|
579
|
+
create_stack(stack_name_bburago, stack_body, parameters, @tags, @cf_role)
|
580
|
+
end
|
581
|
+
end
|
582
|
+
|
583
|
+
def create_hal9000_stack()
|
584
|
+
wait_for_artifact('prima-artifacts-encrypted', "microservices/hal9000/#{@projects["hal9000"]['revision']}-qa.tar.gz")
|
585
|
+
|
586
|
+
stack_name_hal9000 = get_stack_name("hal9000")
|
587
|
+
git_checkout_version('hal9000', @projects["hal9000"]['revision'])
|
588
|
+
stack_body = File.read('projects/hal9000/deploy/task.yml')
|
589
|
+
parameters = [
|
590
|
+
{
|
591
|
+
parameter_key: "Environment",
|
592
|
+
parameter_value: "qa"
|
593
|
+
},
|
594
|
+
{
|
595
|
+
parameter_key: "ReleaseVersion",
|
596
|
+
parameter_value: @projects["hal9000"]['revision']
|
597
|
+
},
|
598
|
+
{
|
599
|
+
parameter_key: "ECSClusterName",
|
600
|
+
parameter_value: get_ecs_cluster_name
|
601
|
+
},
|
602
|
+
{
|
603
|
+
parameter_key: "TaskDesiredCount",
|
604
|
+
parameter_value: "1"
|
605
|
+
},
|
606
|
+
{
|
607
|
+
parameter_key: "HostnamePattern",
|
608
|
+
parameter_value: "hal9000-#{get_deploy_id}.qa.colaster.com"
|
609
|
+
},
|
610
|
+
{
|
611
|
+
parameter_key: "HostnamePatternPriority",
|
612
|
+
parameter_value: hostname_pattern_priority
|
613
|
+
}
|
614
|
+
]
|
615
|
+
if stack_exists?(stack_name_hal9000)
|
616
|
+
cur_version = get_currently_deployed_version(stack_name_hal9000)
|
617
|
+
update_stack(stack_name_hal9000, stack_body, parameters, @tags, @cf_role) unless cur_version.include?(@projects["hal9000"]['revision'])
|
618
|
+
else
|
619
|
+
create_stack(stack_name_hal9000, stack_body, parameters, @tags, @cf_role)
|
620
|
+
end
|
621
|
+
end
|
622
|
+
|
623
|
+
def create_fidaty_stack()
|
624
|
+
wait_for_artifact('prima-artifacts-encrypted', "microservices/fidaty/#{@projects["fidaty"]['revision']}-qa.tar.gz")
|
625
|
+
|
626
|
+
stack_name_fidaty = get_stack_name("fidaty")
|
627
|
+
git_checkout_version('fidaty', @projects["fidaty"]['revision'])
|
628
|
+
stack_body = File.read('projects/fidaty/deploy/task.yml')
|
629
|
+
parameters = [
|
630
|
+
{
|
631
|
+
parameter_key: "Environment",
|
632
|
+
parameter_value: "qa"
|
633
|
+
},
|
634
|
+
{
|
635
|
+
parameter_key: "ReleaseVersion",
|
636
|
+
parameter_value: "#{@projects["fidaty"]['revision']}"
|
637
|
+
},
|
638
|
+
{
|
639
|
+
parameter_key: "ECSClusterName",
|
640
|
+
parameter_value: get_ecs_cluster_name
|
641
|
+
},
|
642
|
+
{
|
643
|
+
parameter_key: "TaskDesiredCount",
|
644
|
+
parameter_value: "1"
|
645
|
+
},
|
646
|
+
{
|
647
|
+
parameter_key: "HostnamePattern",
|
648
|
+
parameter_value: "fidaty-#{get_deploy_id}.qa.colaster.com"
|
649
|
+
},
|
650
|
+
{
|
651
|
+
parameter_key: "HostnamePatternPriority",
|
652
|
+
parameter_value: hostname_pattern_priority
|
653
|
+
},
|
654
|
+
{
|
655
|
+
parameter_key: "PeanoHost",
|
656
|
+
parameter_value: get_route53_hostname("ecs-task-peano-qa-notneeded")
|
657
|
+
}
|
658
|
+
]
|
659
|
+
if stack_exists?(stack_name_fidaty)
|
660
|
+
cur_version = get_currently_deployed_version(stack_name_fidaty)
|
661
|
+
update_stack(stack_name_fidaty, stack_body, parameters, @tags, @cf_role) unless cur_version.include?(@projects["fidaty"]['revision'])
|
662
|
+
else
|
663
|
+
create_stack(stack_name_fidaty, stack_body, parameters, @tags, @cf_role)
|
664
|
+
end
|
665
|
+
end
|
666
|
+
|
667
|
+
def create_peano_stack()
|
668
|
+
wait_for_artifact('prima-artifacts-encrypted', "microservices/peano/#{@projects["peano"]['revision']}-qa.tar.gz")
|
669
|
+
|
670
|
+
stack_name_peano = get_stack_name("peano")
|
671
|
+
git_checkout_version('peano', @projects["peano"]['revision'])
|
672
|
+
stack_body = File.read('projects/peano/deploy/task.yml')
|
673
|
+
parameters = [
|
674
|
+
{
|
675
|
+
parameter_key: "Environment",
|
676
|
+
parameter_value: "qa"
|
677
|
+
},
|
678
|
+
{
|
679
|
+
parameter_key: "ReleaseVersion",
|
680
|
+
parameter_value: "#{@projects['peano']['revision']}"
|
681
|
+
},
|
682
|
+
{
|
683
|
+
parameter_key: "ECSClusterName",
|
684
|
+
parameter_value: get_ecs_cluster_name
|
685
|
+
},
|
686
|
+
{
|
687
|
+
parameter_key: "TaskDesiredCount",
|
688
|
+
parameter_value: "1"
|
689
|
+
},
|
690
|
+
{
|
691
|
+
parameter_key: "HostnamePattern",
|
692
|
+
parameter_value: "peano-#{get_deploy_id}.qa.colaster.com"
|
693
|
+
},
|
694
|
+
{
|
695
|
+
parameter_key: "HostnamePatternPriority",
|
696
|
+
parameter_value: hostname_pattern_priority
|
697
|
+
},
|
698
|
+
{
|
699
|
+
parameter_key: "WebHost",
|
700
|
+
parameter_value: "www-#{get_deploy_id}.qa.colaster.com"
|
701
|
+
}
|
702
|
+
]
|
703
|
+
if stack_exists?(stack_name_peano)
|
704
|
+
cur_version = get_currently_deployed_version(stack_name_peano)
|
705
|
+
update_stack(stack_name_peano, stack_body, parameters, @tags, @cf_role) unless cur_version.include?(@projects["peano"]['revision'])
|
706
|
+
else
|
707
|
+
create_stack(stack_name_peano, stack_body, parameters, @tags, @cf_role)
|
708
|
+
end
|
709
|
+
end
|
710
|
+
|
711
|
+
# def create_rogoreport_stack()
|
712
|
+
# wait_for_artifact('prima-artifacts-encrypted', "microservices/rogoreport/rogoreport-#{@projects["rogoreport"]['revision']}-qa.tar.gz")
|
713
|
+
#
|
714
|
+
# stack_name_rogoreport = get_stack_name("rogoreport")
|
715
|
+
# git_checkout_version('rogoreport', @projects["rogoreport"]['revision'])
|
716
|
+
# stack_body = IO.read('projects/rogoreport/deploy/task.yml')
|
717
|
+
# parameters = [
|
718
|
+
# {
|
719
|
+
# parameter_key: "Environment",
|
720
|
+
# parameter_value: "qa"
|
721
|
+
# },
|
722
|
+
# {
|
723
|
+
# parameter_key: "ReleaseVersion",
|
724
|
+
# parameter_value: "#{@projects["rogoreport"]['revision']}"
|
725
|
+
# },
|
726
|
+
# {
|
727
|
+
# parameter_key: "ReleaseName",
|
728
|
+
# parameter_value: "rogoreport"
|
729
|
+
# },
|
730
|
+
# {
|
731
|
+
# parameter_key: "ECSClusterName",
|
732
|
+
# parameter_value: get_ecs_cluster_name
|
733
|
+
# }
|
734
|
+
# ]
|
735
|
+
# if stack_exists?(stack_name_rogoreport)
|
736
|
+
# cur_version = get_currently_deployed_version(stack_name_rogoreport)
|
737
|
+
# update_stack(stack_name_rogoreport, stack_body, parameters, @tags, @cf_role) unless cur_version.include?(@projects["rogoreport"]['revision'])
|
738
|
+
# else
|
739
|
+
# create_stack(stack_name_rogoreport, stack_body, parameters, @tags, @cf_role)
|
740
|
+
# end
|
741
|
+
# end
|
742
|
+
|
743
|
+
def create_assange_stack()
|
744
|
+
wait_for_artifact('prima-artifacts-encrypted', "microservices/assange/#{@projects["assange"]['revision']}-qa.tar.gz")
|
745
|
+
|
746
|
+
stack_name_assange = get_stack_name("assange")
|
747
|
+
git_checkout_version('assange', @projects["assange"]['revision'])
|
748
|
+
stack_body = IO.read('projects/assange/deploy/task.yml')
|
749
|
+
parameters = [
|
750
|
+
{
|
751
|
+
parameter_key: "Environment",
|
752
|
+
parameter_value: "qa"
|
753
|
+
},
|
754
|
+
{
|
755
|
+
parameter_key: "ReleaseVersion",
|
756
|
+
parameter_value: "#{@projects["assange"]['revision']}"
|
757
|
+
},
|
758
|
+
{
|
759
|
+
parameter_key: "ECSClusterName",
|
760
|
+
parameter_value: get_ecs_cluster_name
|
761
|
+
},
|
762
|
+
{
|
763
|
+
parameter_key: "TaskDesiredCount",
|
764
|
+
parameter_value: "1"
|
765
|
+
},
|
766
|
+
{
|
767
|
+
parameter_key: "ALBShortName",
|
768
|
+
parameter_value: "assange-qa-#{get_deploy_id}"[0..27]
|
769
|
+
},
|
770
|
+
{
|
771
|
+
parameter_key: "HostnamePattern",
|
772
|
+
parameter_value: "assange-#{get_deploy_id}.qa.colaster.com"
|
773
|
+
},
|
774
|
+
{
|
775
|
+
parameter_key: "HostnamePatternPriority",
|
776
|
+
parameter_value: (hostname_pattern_priority.to_i + 20).to_s
|
777
|
+
},
|
778
|
+
{
|
779
|
+
parameter_key: "EnvHash",
|
780
|
+
parameter_value: get_deploy_id
|
781
|
+
},
|
782
|
+
{
|
783
|
+
parameter_key: "WebHost",
|
784
|
+
parameter_value: "www-#{get_deploy_id}.qa.colaster.com"
|
785
|
+
},
|
786
|
+
{
|
787
|
+
parameter_key: "AssangeHost",
|
788
|
+
parameter_value: "assange-#{get_deploy_id}.qa.colaster.com"
|
789
|
+
}
|
790
|
+
]
|
791
|
+
if stack_exists?(stack_name_assange)
|
792
|
+
cur_version = get_currently_deployed_version(stack_name_assange)
|
793
|
+
update_stack(stack_name_assange, stack_body, parameters, @tags, @cf_role) unless cur_version.include?(@projects["assange"]['revision'])
|
794
|
+
else
|
795
|
+
create_stack(stack_name_assange, stack_body, parameters, @tags, @cf_role)
|
796
|
+
end
|
797
|
+
|
798
|
+
stack_name_assange_worker = get_stack_name("assange-worker")
|
799
|
+
git_checkout_version('assange', @projects["assange"]['revision'])
|
800
|
+
stack_body = IO.read('projects/assange/deploy/task-worker.yml')
|
801
|
+
parameters = [
|
802
|
+
{
|
803
|
+
parameter_key: "Environment",
|
804
|
+
parameter_value: "qa"
|
805
|
+
},
|
806
|
+
{
|
807
|
+
parameter_key: "ReleaseVersion",
|
808
|
+
parameter_value: "#{@projects["assange"]['revision']}"
|
809
|
+
},
|
810
|
+
{
|
811
|
+
parameter_key: "ECSClusterName",
|
812
|
+
parameter_value: get_ecs_cluster_name
|
813
|
+
},
|
814
|
+
{
|
815
|
+
parameter_key: "TaskDesiredCount",
|
816
|
+
parameter_value: "1"
|
817
|
+
},
|
818
|
+
{
|
819
|
+
parameter_key: "WebHost",
|
820
|
+
parameter_value: "www-#{get_deploy_id}.qa.colaster.com"
|
821
|
+
},
|
822
|
+
{
|
823
|
+
parameter_key: "AssangeHost",
|
824
|
+
parameter_value: "assange-#{get_deploy_id}.qa.colaster.com"
|
825
|
+
}
|
826
|
+
]
|
827
|
+
if stack_exists?(stack_name_assange_worker)
|
828
|
+
cur_version = get_currently_deployed_version(stack_name_assange_worker)
|
829
|
+
update_stack(stack_name_assange_worker, stack_body, parameters, @tags, @cf_role) unless cur_version.include?(@projects["assange"]['revision'])
|
830
|
+
else
|
831
|
+
create_stack(stack_name_assange_worker, stack_body, parameters, @tags, @cf_role)
|
832
|
+
end
|
833
|
+
end
|
834
|
+
|
835
|
+
def create_leftorium_stack()
|
836
|
+
wait_for_artifact('prima-artifacts-encrypted', "microservices/leftorium/#{@projects["leftorium"]['revision']}-qa.tar.gz")
|
837
|
+
|
838
|
+
stack_name_leftorium = get_stack_name("leftorium")
|
839
|
+
git_checkout_version('leftorium', @projects["leftorium"]['revision'])
|
840
|
+
stack_body = File.read('projects/leftorium/deploy/task.yml')
|
841
|
+
parameters = [
|
842
|
+
{
|
843
|
+
parameter_key: "Environment",
|
844
|
+
parameter_value: "qa"
|
845
|
+
},
|
846
|
+
{
|
847
|
+
parameter_key: "ReleaseVersion",
|
848
|
+
parameter_value: "#{@projects["leftorium"]['revision']}"
|
849
|
+
},
|
850
|
+
{
|
851
|
+
parameter_key: "ECSClusterName",
|
852
|
+
parameter_value: get_ecs_cluster_name
|
853
|
+
},
|
854
|
+
{
|
855
|
+
parameter_key: "TaskDesiredCount",
|
856
|
+
parameter_value: "1"
|
857
|
+
},
|
858
|
+
{
|
859
|
+
parameter_key: "HostnamePattern",
|
860
|
+
parameter_value: "leftorium-#{get_deploy_id}.qa.colaster.com"
|
861
|
+
},
|
862
|
+
{
|
863
|
+
parameter_key: "HostnamePatternPriority",
|
864
|
+
parameter_value: hostname_pattern_priority
|
865
|
+
}
|
866
|
+
]
|
867
|
+
if stack_exists?(stack_name_leftorium)
|
868
|
+
cur_version = get_currently_deployed_version(stack_name_leftorium)
|
869
|
+
update_stack(stack_name_leftorium, stack_body, parameters, @tags, @cf_role) unless cur_version.include?(@projects["leftorium"]['revision'])
|
870
|
+
else
|
871
|
+
create_stack(stack_name_leftorium, stack_body, parameters, @tags, @cf_role)
|
872
|
+
end
|
873
|
+
end
|
874
|
+
|
875
|
+
def create_rachele_stack()
|
876
|
+
wait_for_artifact('prima-artifacts-encrypted', "microservices/rachele/#{@projects["rachele"]['revision']}-qa.tar.gz")
|
877
|
+
|
878
|
+
stack_name_rachele = get_stack_name("rachele")
|
879
|
+
git_checkout_version('rachele', @projects["rachele"]['revision'])
|
880
|
+
stack_body = File.read('projects/rachele/deploy/task.yml')
|
881
|
+
parameters = [
|
882
|
+
{
|
883
|
+
parameter_key: "Environment",
|
884
|
+
parameter_value: "qa"
|
885
|
+
},
|
886
|
+
{
|
887
|
+
parameter_key: "ReleaseVersion",
|
888
|
+
parameter_value: "#{@projects["rachele"]['revision']}"
|
889
|
+
},
|
890
|
+
{
|
891
|
+
parameter_key: "ECSClusterName",
|
892
|
+
parameter_value: get_ecs_cluster_name
|
893
|
+
},
|
894
|
+
{
|
895
|
+
parameter_key: "TaskDesiredCount",
|
896
|
+
parameter_value: "1"
|
897
|
+
},
|
898
|
+
{
|
899
|
+
parameter_key: "EnvHash",
|
900
|
+
parameter_value: get_deploy_id
|
901
|
+
},
|
902
|
+
{
|
903
|
+
parameter_key: "WebHost",
|
904
|
+
parameter_value: "www-#{get_deploy_id}.qa.colaster.com"
|
905
|
+
},
|
906
|
+
{
|
907
|
+
parameter_key: "HostnamePattern",
|
908
|
+
parameter_value: "rachele-#{get_deploy_id}.qa.colaster.com"
|
909
|
+
},
|
910
|
+
{
|
911
|
+
parameter_key: "HostnamePatternPriority",
|
912
|
+
parameter_value: hostname_pattern_priority
|
913
|
+
}
|
914
|
+
]
|
915
|
+
if stack_exists?(stack_name_rachele)
|
916
|
+
cur_version = get_currently_deployed_version(stack_name_rachele)
|
917
|
+
unless cur_version.include?(@projects["rachele"]['revision'])
|
918
|
+
delete_stack(stack_name_rachele)
|
919
|
+
wait_for_stack_removal(stack_name_rachele)
|
920
|
+
create_stack(stack_name_rachele, stack_body, parameters, @tags, @cf_role)
|
921
|
+
end
|
922
|
+
else
|
923
|
+
create_stack(stack_name_rachele, stack_body, parameters, @tags, @cf_role)
|
924
|
+
end
|
925
|
+
end
|
926
|
+
|
927
|
+
def create_borat_stack()
|
928
|
+
wait_for_artifact('prima-artifacts-encrypted', "microservices/borat/#{@projects["borat"]['revision']}-qa.tar.gz")
|
929
|
+
|
930
|
+
stack_name_borat = get_stack_name("borat")
|
931
|
+
git_checkout_version('borat', @projects["borat"]['revision'])
|
932
|
+
stack_body = IO.read('projects/borat/deploy/task.yml')
|
933
|
+
parameters = [
|
934
|
+
{
|
935
|
+
parameter_key: "Environment",
|
936
|
+
parameter_value: "qa"
|
937
|
+
},
|
938
|
+
{
|
939
|
+
parameter_key: "ReleaseVersion",
|
940
|
+
parameter_value: "#{@projects["borat"]['revision']}"
|
941
|
+
},
|
942
|
+
{
|
943
|
+
parameter_key: "ECSClusterName",
|
944
|
+
parameter_value: get_ecs_cluster_name
|
945
|
+
},
|
946
|
+
{
|
947
|
+
parameter_key: "TaskDesiredCount",
|
948
|
+
parameter_value: "1"
|
949
|
+
},
|
950
|
+
{
|
951
|
+
parameter_key: "ALBShortName",
|
952
|
+
parameter_value: "borat-qa-#{get_deploy_id}"[0..27]
|
953
|
+
},
|
954
|
+
{
|
955
|
+
parameter_key: "HostnamePattern",
|
956
|
+
parameter_value: "backoffice-#{get_deploy_id}.qa.colaster.com"
|
957
|
+
},
|
958
|
+
{
|
959
|
+
parameter_key: "HostnamePatternPriority",
|
960
|
+
parameter_value: (hostname_pattern_priority.to_i + 30).to_s
|
961
|
+
},
|
962
|
+
{
|
963
|
+
parameter_key: "EnvHash",
|
964
|
+
parameter_value: get_deploy_id
|
965
|
+
},
|
966
|
+
{
|
967
|
+
parameter_key: "WsEndpoint",
|
968
|
+
parameter_value: "wss://backoffice-#{get_deploy_id}.qa.colaster.com/socket/websocket?vsn=1.0.0"
|
969
|
+
},
|
970
|
+
{
|
971
|
+
parameter_key: "GraphqlEndpoint",
|
972
|
+
parameter_value: "https://backoffice-#{get_deploy_id}.qa.colaster.com/graphql"
|
973
|
+
},
|
974
|
+
{
|
975
|
+
parameter_key: "GraphqlInsuranceEndpoint",
|
976
|
+
parameter_value: "https://backoffice-#{get_deploy_id}.qa.colaster.com/graphql/insurance"
|
977
|
+
},
|
978
|
+
{
|
979
|
+
parameter_key: "AuthEndpoint",
|
980
|
+
parameter_value: "https://backoffice-#{get_deploy_id}.qa.colaster.com/auth"
|
981
|
+
},
|
982
|
+
{
|
983
|
+
parameter_key: "FrontendEndpoint",
|
984
|
+
parameter_value: "https://www-#{get_deploy_id}.qa.colaster.com/"
|
985
|
+
}
|
986
|
+
]
|
987
|
+
if stack_exists?(stack_name_borat)
|
988
|
+
cur_version = get_currently_deployed_version(stack_name_borat)
|
989
|
+
update_stack(stack_name_borat, stack_body, parameters, @tags, @cf_role) unless cur_version.include?(@projects["borat"]['revision'])
|
990
|
+
else
|
991
|
+
create_stack(stack_name_borat, stack_body, parameters, @tags, @cf_role)
|
992
|
+
end
|
993
|
+
end
|
994
|
+
|
995
|
+
def create_crash_stack()
|
996
|
+
wait_for_artifact('prima-artifacts-encrypted', "microservices/crash/#{@projects['crash']['revision']}-qa.tar.gz")
|
997
|
+
|
998
|
+
stack_name_crash = get_stack_name("crash")
|
999
|
+
git_checkout_version('crash', @projects['crash']['revision'])
|
1000
|
+
stack_body = IO.read('projects/crash/deploy/task.yml')
|
1001
|
+
parameters = [
|
1002
|
+
{
|
1003
|
+
parameter_key: 'Environment',
|
1004
|
+
parameter_value: 'qa'
|
1005
|
+
},
|
1006
|
+
{
|
1007
|
+
parameter_key: 'ReleaseVersion',
|
1008
|
+
parameter_value: "#{@projects['crash']['revision']}"
|
1009
|
+
},
|
1010
|
+
{
|
1011
|
+
parameter_key: 'TaskDesiredCount',
|
1012
|
+
parameter_value: '1'
|
1013
|
+
},
|
1014
|
+
{
|
1015
|
+
parameter_key: 'ECSClusterName',
|
1016
|
+
parameter_value: get_ecs_cluster_name
|
1017
|
+
},
|
1018
|
+
{
|
1019
|
+
parameter_key: 'ALBShortName',
|
1020
|
+
parameter_value: "crash-qa-#{get_deploy_id}"[0..27]
|
1021
|
+
},
|
1022
|
+
{
|
1023
|
+
parameter_key: 'HostnamePattern',
|
1024
|
+
parameter_value: "crash-#{get_deploy_id}.qa.colaster.com"
|
1025
|
+
},
|
1026
|
+
{
|
1027
|
+
parameter_key: 'HostnamePatternPriority',
|
1028
|
+
parameter_value: (hostname_pattern_priority.to_i + 10).to_s
|
1029
|
+
},
|
1030
|
+
{
|
1031
|
+
parameter_key: "EnvHash",
|
1032
|
+
parameter_value: get_deploy_id
|
1033
|
+
},
|
1034
|
+
{
|
1035
|
+
parameter_key: "WsEndpoint",
|
1036
|
+
parameter_value: "wss://crash-#{get_deploy_id}.qa.colaster.com/socket/websocket?vsn=1.0.0"
|
1037
|
+
},
|
1038
|
+
{
|
1039
|
+
parameter_key: "GraphqlEndpoint",
|
1040
|
+
parameter_value: "https://crash-#{get_deploy_id}.qa.colaster.com/graphql"
|
1041
|
+
},
|
1042
|
+
{
|
1043
|
+
parameter_key: "AuthDomain",
|
1044
|
+
parameter_value: "https://www-#{get_deploy_id}.qa.colaster.com/"
|
1045
|
+
},
|
1046
|
+
]
|
1047
|
+
if stack_exists?(stack_name_crash)
|
1048
|
+
cur_version = get_currently_deployed_version(stack_name_crash)
|
1049
|
+
update_stack(stack_name_crash, stack_body, parameters, @tags, @cf_role) unless cur_version.include?(@projects["crash"]['revision'])
|
1050
|
+
else
|
1051
|
+
create_stack(stack_name_crash, stack_body, parameters, @tags, @cf_role)
|
1052
|
+
end
|
1053
|
+
end
|
1054
|
+
|
1055
|
+
def create_starsky_stack()
|
1056
|
+
wait_for_artifact('prima-artifacts-encrypted', "microservices/starsky/#{@projects["starsky"]['revision']}-qa.tar.gz")
|
1057
|
+
|
1058
|
+
git_checkout_version('starsky', @projects["starsky"]['revision'])
|
1059
|
+
stack_name_starsky = get_stack_name("starsky")
|
1060
|
+
stack_body = IO.read('projects/starsky/deploy/task.yml')
|
1061
|
+
parameters = [
|
1062
|
+
{
|
1063
|
+
parameter_key: "Environment",
|
1064
|
+
parameter_value: "qa"
|
1065
|
+
},
|
1066
|
+
{
|
1067
|
+
parameter_key: "ReleaseVersion",
|
1068
|
+
parameter_value: "#{@projects["starsky"]['revision']}"
|
1069
|
+
},
|
1070
|
+
{
|
1071
|
+
parameter_key: "TaskDesiredCount",
|
1072
|
+
parameter_value: "1"
|
1073
|
+
},
|
1074
|
+
{
|
1075
|
+
parameter_key: "ECSClusterName",
|
1076
|
+
parameter_value: get_ecs_cluster_name
|
1077
|
+
},
|
1078
|
+
{
|
1079
|
+
parameter_key: "ALBShortName",
|
1080
|
+
parameter_value: "starsky-qa-#{get_deploy_id}"[0..27]
|
1081
|
+
},
|
1082
|
+
{
|
1083
|
+
parameter_key: "EnvHash",
|
1084
|
+
parameter_value: get_deploy_id
|
1085
|
+
},
|
1086
|
+
{
|
1087
|
+
parameter_key: "HostnamePattern",
|
1088
|
+
parameter_value: "starsky-#{get_deploy_id}.qa.colaster.com"
|
1089
|
+
},
|
1090
|
+
{
|
1091
|
+
parameter_key: "HostnamePatternPriority",
|
1092
|
+
parameter_value: (hostname_pattern_priority.to_i + 74).to_s
|
1093
|
+
}
|
1094
|
+
]
|
1095
|
+
if stack_exists?(stack_name_starsky)
|
1096
|
+
cur_version = get_currently_deployed_version(stack_name_starsky)
|
1097
|
+
unless cur_version.include?(@projects["starsky"]['revision'])
|
1098
|
+
delete_stack(stack_name_starsky)
|
1099
|
+
wait_for_stack_removal(stack_name_starsky)
|
1100
|
+
create_stack(stack_name_starsky, stack_body, parameters, @tags, @cf_role)
|
1101
|
+
end
|
1102
|
+
else
|
1103
|
+
create_stack(stack_name_starsky, stack_body, parameters, @tags, @cf_role)
|
1104
|
+
end
|
1105
|
+
end
|
1106
|
+
|
1107
|
+
def create_activia_stack()
|
1108
|
+
wait_for_artifact('prima-artifacts-encrypted', "microservices/activia/#{@projects["activia"]['revision']}-qa.tar.gz")
|
1109
|
+
|
1110
|
+
stack_name_activia = get_stack_name("activia")
|
1111
|
+
git_checkout_version('activia', @projects["activia"]['revision'])
|
1112
|
+
stack_body = File.read('projects/activia/deploy/task.yml')
|
1113
|
+
parameters = [
|
1114
|
+
{
|
1115
|
+
parameter_key: "Environment",
|
1116
|
+
parameter_value: "qa"
|
1117
|
+
},
|
1118
|
+
{
|
1119
|
+
parameter_key: "ReleaseVersion",
|
1120
|
+
parameter_value: "#{@projects["activia"]['revision']}"
|
1121
|
+
},
|
1122
|
+
{
|
1123
|
+
parameter_key: "ECSClusterName",
|
1124
|
+
parameter_value: get_ecs_cluster_name
|
1125
|
+
},
|
1126
|
+
{
|
1127
|
+
parameter_key: "TaskDesiredCount",
|
1128
|
+
parameter_value: "1"
|
1129
|
+
},
|
1130
|
+
{
|
1131
|
+
parameter_key: "HostnamePattern",
|
1132
|
+
parameter_value: "activia-#{get_deploy_id}.qa.colaster.com"
|
1133
|
+
},
|
1134
|
+
{
|
1135
|
+
parameter_key: "HostnamePatternPriority",
|
1136
|
+
parameter_value: hostname_pattern_priority
|
1137
|
+
},
|
1138
|
+
{
|
1139
|
+
parameter_key: "WebHost",
|
1140
|
+
parameter_value: get_route53_hostname('ecs-task-web-qa-notneeded')
|
1141
|
+
},
|
1142
|
+
{
|
1143
|
+
parameter_key: "PeanoHost",
|
1144
|
+
parameter_value: get_route53_hostname('ecs-task-peano-qa-notneeded')
|
1145
|
+
}
|
1146
|
+
]
|
1147
|
+
if stack_exists?(stack_name_activia)
|
1148
|
+
cur_version = get_currently_deployed_version(stack_name_activia)
|
1149
|
+
update_stack(stack_name_activia, stack_body, parameters, @tags, @cf_role) unless cur_version.include?(@projects["activia"]['revision'])
|
1150
|
+
else
|
1151
|
+
create_stack(stack_name_activia, stack_body, parameters, @tags, @cf_role)
|
1152
|
+
end
|
1153
|
+
end
|
1154
|
+
|
1155
|
+
def create_web_stack()
|
1156
|
+
wait_for_artifact('prima-artifacts-encrypted', "prima/#{@projects["prima"]['revision']}.tar.gz")
|
1157
|
+
# Waiting for prima healtcheck dependencies
|
1158
|
+
wait_for_stack_ready(get_stack_name("skynet")) unless stack_ready?(get_stack_name("skynet"))
|
1159
|
+
wait_for_stack_ready(get_stack_name("urania")) unless stack_ready?(get_stack_name("urania"))
|
1160
|
+
wait_for_stack_ready(get_stack_name("bburago")) unless stack_ready?(get_stack_name("bburago"))
|
1161
|
+
wait_for_stack_ready(get_stack_name("hal9000")) unless stack_ready?(get_stack_name("hal9000"))
|
1162
|
+
wait_for_stack_ready(get_stack_name("assange")) unless stack_ready?(get_stack_name("assange"))
|
1163
|
+
wait_for_stack_ready(get_stack_name("fidaty")) unless stack_ready?(get_stack_name("fidaty"))
|
1164
|
+
wait_for_stack_ready(get_stack_name("leftorium")) unless stack_ready?(get_stack_name("leftorium"))
|
1165
|
+
wait_for_stack_ready(get_stack_name("rachele")) unless stack_ready?(get_stack_name("rachele"))
|
1166
|
+
stack_name_web = get_stack_name("web")
|
1167
|
+
git_checkout_version('prima', @projects["prima"]['revision'])
|
1168
|
+
stack_body = IO.read('projects/prima/app/cloudformation/tasks/web.yml')
|
1169
|
+
parameters = [
|
1170
|
+
{
|
1171
|
+
parameter_key: "Environment",
|
1172
|
+
parameter_value: "qa"
|
1173
|
+
},
|
1174
|
+
{
|
1175
|
+
parameter_key: "ReleaseVersion",
|
1176
|
+
parameter_value: "#{@projects["prima"]['revision']}"
|
1177
|
+
},
|
1178
|
+
{
|
1179
|
+
parameter_key: "TaskDesiredCount",
|
1180
|
+
parameter_value: "1"
|
1181
|
+
},
|
1182
|
+
{
|
1183
|
+
parameter_key: "ECSClusterName",
|
1184
|
+
parameter_value: get_ecs_cluster_name
|
1185
|
+
},
|
1186
|
+
{
|
1187
|
+
parameter_key: "ALBShortName",
|
1188
|
+
parameter_value: "web-qa-#{get_deploy_id}"[0..27]
|
1189
|
+
},
|
1190
|
+
{
|
1191
|
+
parameter_key: "HostnamePatternPriority",
|
1192
|
+
parameter_value: hostname_pattern_priority
|
1193
|
+
},
|
1194
|
+
{
|
1195
|
+
parameter_key: "HostnamePatternAggregatorPriority",
|
1196
|
+
parameter_value: (hostname_pattern_priority.to_i + 1).to_s
|
1197
|
+
},
|
1198
|
+
{
|
1199
|
+
parameter_key: "EnvHash",
|
1200
|
+
parameter_value: get_deploy_id
|
1201
|
+
},
|
1202
|
+
{
|
1203
|
+
parameter_key: "HostnamePattern",
|
1204
|
+
parameter_value: "www-#{get_deploy_id}.*"
|
1205
|
+
}
|
1206
|
+
]
|
1207
|
+
if stack_exists?(stack_name_web)
|
1208
|
+
cur_version = get_currently_deployed_version(stack_name_web)
|
1209
|
+
update_stack(stack_name_web, stack_body, parameters, @tags, @cf_role) unless cur_version.include?(@projects["prima"]['revision'])
|
1210
|
+
else
|
1211
|
+
create_stack(stack_name_web, stack_body, parameters, @tags, @cf_role)
|
1212
|
+
end
|
1213
|
+
end
|
1214
|
+
|
1215
|
+
def create_consumer_stack()
|
1216
|
+
wait_for_artifact('prima-artifacts-encrypted', "prima/#{@projects["prima"]['revision']}.tar.gz")
|
1217
|
+
# Waiting for prima healtcheck dependencies
|
1218
|
+
wait_for_stack_ready(get_stack_name("skynet")) unless stack_ready?(get_stack_name("skynet"))
|
1219
|
+
wait_for_stack_ready(get_stack_name("urania")) unless stack_ready?(get_stack_name("urania"))
|
1220
|
+
wait_for_stack_ready(get_stack_name("bburago")) unless stack_ready?(get_stack_name("bburago"))
|
1221
|
+
wait_for_stack_ready(get_stack_name("hal9000")) unless stack_ready?(get_stack_name("hal9000"))
|
1222
|
+
wait_for_stack_ready(get_stack_name("assange")) unless stack_ready?(get_stack_name("assange"))
|
1223
|
+
wait_for_stack_ready(get_stack_name("fidaty")) unless stack_ready?(get_stack_name("fidaty"))
|
1224
|
+
wait_for_stack_ready(get_stack_name("leftorium")) unless stack_ready?(get_stack_name("leftorium"))
|
1225
|
+
wait_for_stack_ready(get_stack_name("rachele")) unless stack_ready?(get_stack_name("rachele"))
|
1226
|
+
stack_name_consumer = get_stack_name("consumer")
|
1227
|
+
git_checkout_version('prima', @projects["prima"]['revision'])
|
1228
|
+
stack_body = IO.read('projects/prima/app/cloudformation/tasks/consumer.yml')
|
1229
|
+
parameters = [
|
1230
|
+
{
|
1231
|
+
parameter_key: "Environment",
|
1232
|
+
parameter_value: "qa"
|
1233
|
+
},
|
1234
|
+
{
|
1235
|
+
parameter_key: "ReleaseVersion",
|
1236
|
+
parameter_value: "#{@projects["prima"]['revision']}"
|
1237
|
+
},
|
1238
|
+
{
|
1239
|
+
parameter_key: "ECSClusterName",
|
1240
|
+
parameter_value: get_ecs_cluster_name
|
1241
|
+
},
|
1242
|
+
{
|
1243
|
+
parameter_key: "EnvHash",
|
1244
|
+
parameter_value: get_deploy_id
|
1245
|
+
}
|
1246
|
+
]
|
1247
|
+
if stack_exists?(stack_name_consumer)
|
1248
|
+
cur_version = get_currently_deployed_version(stack_name_consumer)
|
1249
|
+
update_stack(stack_name_consumer, stack_body, parameters, @tags, @cf_role) unless cur_version.include?(@projects["prima"]['revision'])
|
1250
|
+
else
|
1251
|
+
create_stack(stack_name_consumer, stack_body, parameters, @tags, @cf_role)
|
1252
|
+
end
|
1253
|
+
|
1254
|
+
stack_name_consumer_api = get_stack_name("consumer-api")
|
1255
|
+
stack_body = IO.read('projects/prima/app/cloudformation/tasks/consumer-api.yml')
|
1256
|
+
parameters = [
|
1257
|
+
{
|
1258
|
+
parameter_key: "Environment",
|
1259
|
+
parameter_value: "qa"
|
1260
|
+
},
|
1261
|
+
{
|
1262
|
+
parameter_key: "ReleaseVersion",
|
1263
|
+
parameter_value: "#{@projects["prima"]['revision']}"
|
1264
|
+
},
|
1265
|
+
{
|
1266
|
+
parameter_key: "ECSClusterName",
|
1267
|
+
parameter_value: get_ecs_cluster_name
|
1268
|
+
},
|
1269
|
+
{
|
1270
|
+
parameter_key: "EnvHash",
|
1271
|
+
parameter_value: get_deploy_id
|
1272
|
+
},
|
1273
|
+
{
|
1274
|
+
parameter_key: "HostnamePattern",
|
1275
|
+
parameter_value: "consumer-#{get_deploy_id}.qa.colaster.com"
|
1276
|
+
}
|
1277
|
+
]
|
1278
|
+
if stack_exists?(stack_name_consumer_api)
|
1279
|
+
cur_version = get_currently_deployed_version(stack_name_consumer_api)
|
1280
|
+
update_stack(stack_name_consumer_api, stack_body, parameters, @tags, @cf_role) unless cur_version.include?(@projects["prima"]['revision'])
|
1281
|
+
else
|
1282
|
+
create_stack(stack_name_consumer_api, stack_body, parameters, @tags, @cf_role)
|
1283
|
+
end
|
1284
|
+
end
|
1285
|
+
|
1286
|
+
def create_roger_stack()
|
1287
|
+
wait_for_artifact('prima-artifacts-encrypted', "microservices/roger/#{@projects["roger"]['revision']}-qa.tar.gz")
|
1288
|
+
wait_for_stack_ready(get_stack_name("consumer")) unless stack_ready?(get_stack_name("consumer"))
|
1289
|
+
stack_name_roger = "ecs-task-roger-qa-#{get_deploy_id}"
|
1290
|
+
git_checkout_version('roger', @projects["roger"]['revision'])
|
1291
|
+
stack_body = File.read('projects/roger/deploy/task.yml')
|
1292
|
+
parameters = [
|
1293
|
+
{
|
1294
|
+
parameter_key: "Environment",
|
1295
|
+
parameter_value: "qa"
|
1296
|
+
},
|
1297
|
+
{
|
1298
|
+
parameter_key: "ReleaseVersion",
|
1299
|
+
parameter_value: @projects["roger"]['revision']
|
1300
|
+
},
|
1301
|
+
{
|
1302
|
+
parameter_key: "ECSClusterName",
|
1303
|
+
parameter_value: get_ecs_cluster_name
|
1304
|
+
},
|
1305
|
+
{
|
1306
|
+
parameter_key: "TaskDesiredCount",
|
1307
|
+
parameter_value: '1'
|
1308
|
+
}
|
1309
|
+
]
|
1310
|
+
if stack_exists?(stack_name_roger)
|
1311
|
+
cur_version = get_currently_deployed_version(stack_name_roger)
|
1312
|
+
update_stack(stack_name_roger, stack_body, parameters, @tags, @cf_role) unless cur_version.include?(@projects["roger"]['revision'])
|
1313
|
+
else
|
1314
|
+
create_stack(stack_name_roger, stack_body, parameters, @tags, @cf_role)
|
1315
|
+
end
|
1316
|
+
end
|
1317
|
+
|
1318
|
+
def create_hutch_stack()
|
1319
|
+
wait_for_artifact('prima-artifacts-encrypted', "microservices/hutch/#{@projects["hutch"]['revision']}-#{get_deploy_id[0..7]}-qa.tar.gz")
|
1320
|
+
wait_for_stack_ready(get_stack_name("starsky")) unless stack_ready?(get_stack_name("starsky"))
|
1321
|
+
|
1322
|
+
stack_name_hutch = get_stack_name("hutch")
|
1323
|
+
git_checkout_version('hutch', @projects["hutch"]['revision'])
|
1324
|
+
stack_body = File.read('projects/hutch/deploy/task.yml')
|
1325
|
+
parameters = [
|
1326
|
+
{
|
1327
|
+
parameter_key: "Environment",
|
1328
|
+
parameter_value: "qa"
|
1329
|
+
},
|
1330
|
+
{
|
1331
|
+
parameter_key: "ReleaseVersion",
|
1332
|
+
parameter_value: "#{@projects["hutch"]['revision']}-#{get_deploy_id[0..7]}"
|
1333
|
+
},
|
1334
|
+
{
|
1335
|
+
parameter_key: "ALBShortName",
|
1336
|
+
parameter_value: "hutch-qa-#{get_deploy_id}"[0..27]
|
1337
|
+
},
|
1338
|
+
{
|
1339
|
+
parameter_key: "ECSClusterName",
|
1340
|
+
parameter_value: get_ecs_cluster_name
|
1341
|
+
},
|
1342
|
+
{
|
1343
|
+
parameter_key: "EnvHash",
|
1344
|
+
parameter_value: get_deploy_id
|
1345
|
+
},
|
1346
|
+
{
|
1347
|
+
parameter_key: "HostnamePattern",
|
1348
|
+
parameter_value: "hutch-#{get_deploy_id}.qa.colaster.com"
|
1349
|
+
},
|
1350
|
+
{
|
1351
|
+
parameter_key: "HostnamePatternPriority",
|
1352
|
+
parameter_value: (hostname_pattern_priority.to_i + 254).to_s
|
1353
|
+
},
|
1354
|
+
{
|
1355
|
+
parameter_key: "ApiUrl",
|
1356
|
+
parameter_value: "https://#{get_route53_hostname('maia-intermediari')}"
|
1357
|
+
}
|
1358
|
+
]
|
1359
|
+
if stack_exists?(stack_name_hutch)
|
1360
|
+
cur_version = get_currently_deployed_version(stack_name_hutch)
|
1361
|
+
update_stack(stack_name_hutch, stack_body, parameters, @tags, @cf_role) unless cur_version.include?(@projects["hutch"]['revision'])
|
1362
|
+
else
|
1363
|
+
create_stack(stack_name_hutch, stack_body, parameters, @tags, @cf_role)
|
1364
|
+
end
|
1365
|
+
end
|
1366
|
+
|
1367
|
+
def create_maia_stack()
|
1368
|
+
wait_for_artifact('prima-artifacts-encrypted', "microservices/maia/#{@projects["maia"]['revision']}-qa.tar.gz")
|
1369
|
+
stack_name_maia = get_stack_name("maia")
|
1370
|
+
git_checkout_version('maia', @projects["maia"]['revision'])
|
1371
|
+
stack_body = File.read('projects/maia/deploy/task.yml')
|
1372
|
+
parameters = [
|
1373
|
+
{
|
1374
|
+
parameter_key: "Environment",
|
1375
|
+
parameter_value: "qa"
|
1376
|
+
},
|
1377
|
+
{
|
1378
|
+
parameter_key: "ReleaseVersion",
|
1379
|
+
parameter_value: "#{@projects["maia"]['revision']}"
|
1380
|
+
},
|
1381
|
+
{
|
1382
|
+
parameter_key: "ALBShortName",
|
1383
|
+
parameter_value: "maia-qa-#{get_deploy_id}"[0..15]
|
1384
|
+
},
|
1385
|
+
{
|
1386
|
+
parameter_key: "ECSClusterName",
|
1387
|
+
parameter_value: get_ecs_cluster_name
|
1388
|
+
},
|
1389
|
+
{
|
1390
|
+
parameter_key: "EnvHash",
|
1391
|
+
parameter_value: get_deploy_id
|
1392
|
+
},
|
1393
|
+
{
|
1394
|
+
parameter_key: "HostnamePatternPublic",
|
1395
|
+
parameter_value: "api*-#{get_deploy_id}.qa.colaster.com"
|
1396
|
+
},
|
1397
|
+
{
|
1398
|
+
parameter_key: "HostnamePatternPriority",
|
1399
|
+
parameter_value: (hostname_pattern_priority.to_i + 128).to_s
|
1400
|
+
},
|
1401
|
+
{
|
1402
|
+
parameter_key: "ProxyHostnameIntermediari",
|
1403
|
+
parameter_value: "api-intermediari-#{get_deploy_id}.qa.colaster.com"
|
1404
|
+
},
|
1405
|
+
{
|
1406
|
+
parameter_key: "ProxyHostnameApp",
|
1407
|
+
parameter_value: "api-#{get_deploy_id}.qa.colaster.com"
|
1408
|
+
}
|
1409
|
+
]
|
1410
|
+
if stack_exists?(stack_name_maia)
|
1411
|
+
cur_version = get_currently_deployed_version(stack_name_maia)
|
1412
|
+
update_stack(stack_name_maia, stack_body, parameters, @tags, @cf_role) unless cur_version.include?(@projects["maia"]['revision'])
|
1413
|
+
else
|
1414
|
+
create_stack(stack_name_maia, stack_body, parameters, @tags, @cf_role)
|
1415
|
+
end
|
1416
|
+
end
|
1417
|
+
|
1418
|
+
def create_rogoreport_stack()
|
1419
|
+
true
|
1420
|
+
end
|
1421
|
+
|
1422
|
+
def complete_qa_setup!()
|
1423
|
+
wait_for_stack_ready(get_stack_name("web")) unless stack_ready?(get_stack_name("web"))
|
1424
|
+
wait_for_stack_ready(get_stack_name("consumer")) unless stack_ready?(get_stack_name("consumer"))
|
1425
|
+
wait_for_stack_ready(get_stack_name("worker-ermes")) unless stack_ready?(get_stack_name("worker-ermes"))
|
1426
|
+
wait_for_stack_ready(get_stack_name("ermes")) unless stack_ready?(get_stack_name("ermes"))
|
1427
|
+
wait_for_stack_ready(get_stack_name("peano")) unless stack_ready?(get_stack_name("peano"))
|
1428
|
+
# wait_for_stack_ready(get_stack_name("rogoreport")) unless stack_ready?(get_stack_name("rogoreport"))
|
1429
|
+
wait_for_stack_ready(get_stack_name("borat")) unless stack_ready?(get_stack_name("borat"))
|
1430
|
+
wait_for_stack_ready(get_stack_name("activia")) unless stack_ready?(get_stack_name("activia"))
|
1431
|
+
wait_for_stack_ready(get_stack_name("maia")) unless stack_ready?(get_stack_name("maia"))
|
1432
|
+
wait_for_stack_ready(get_stack_name("crash")) unless stack_ready?(get_stack_name("crash"))
|
1433
|
+
wait_for_stack_ready(get_stack_name("hutch")) unless stack_ready?(get_stack_name("hutch"))
|
1434
|
+
|
1435
|
+
update_service_defaults(get_stack_name("web"))
|
1436
|
+
update_service_defaults(get_stack_name("consumer-api"))
|
1437
|
+
update_service_defaults(get_stack_name("urania"))
|
1438
|
+
update_service_defaults(get_stack_name("worker-ermes"))
|
1439
|
+
update_service_defaults(get_stack_name("ermes"))
|
1440
|
+
update_service_defaults(get_stack_name("bburago"))
|
1441
|
+
update_service_defaults(get_stack_name("hal9000"))
|
1442
|
+
update_service_defaults(get_stack_name("fidaty"))
|
1443
|
+
update_service_defaults(get_stack_name("peano"))
|
1444
|
+
# update_service_defaults(get_stack_name("rogoreport"))
|
1445
|
+
update_service_defaults(get_stack_name("assange"))
|
1446
|
+
update_service_defaults(get_stack_name("borat"))
|
1447
|
+
update_service_defaults(get_stack_name("activia"))
|
1448
|
+
update_service_defaults(get_stack_name("skynet"))
|
1449
|
+
update_service_defaults(get_stack_name("leftorium"))
|
1450
|
+
update_service_defaults(get_stack_name("rachele"))
|
1451
|
+
update_service_defaults(get_stack_name("maia"))
|
1452
|
+
update_service_defaults(get_stack_name("starsky"))
|
1453
|
+
update_service_defaults(get_stack_name("hutch"))
|
1454
|
+
update_service_defaults(get_stack_name("crash"))
|
1455
|
+
|
1456
|
+
activia_hostname = get_route53_hostname("activia")
|
1457
|
+
assange_hostname = get_route53_hostname("assange")
|
1458
|
+
bburago_hostname = get_route53_hostname("bburago")
|
1459
|
+
borat_hostname = get_route53_hostname("borat")
|
1460
|
+
ermes_hostname = get_route53_hostname("ermes")
|
1461
|
+
fidaty_hostname = get_route53_hostname("fidaty")
|
1462
|
+
hal9000_hostname = get_route53_hostname("hal9000")
|
1463
|
+
prima_hostname = get_route53_hostname("web")
|
1464
|
+
peano_hostname = get_route53_hostname("peano")
|
1465
|
+
skynet_hostname = get_route53_hostname("skynet")
|
1466
|
+
urania_hostname = get_route53_hostname("urania")
|
1467
|
+
roger_hostname = get_route53_hostname("roger")
|
1468
|
+
leftorium_hostname = get_route53_hostname("leftorium")
|
1469
|
+
rachele_hostname = get_route53_hostname("rachele")
|
1470
|
+
maia_app_hostname = get_route53_hostname("maia-app")
|
1471
|
+
maia_intermediari_hostname = get_route53_hostname("maia-intermediari")
|
1472
|
+
crash_hostname = get_route53_hostname("crash")
|
1473
|
+
starsky_hostname = get_route53_hostname("starsky")
|
1474
|
+
hutch_hostname = get_route53_hostname("hutch")
|
1475
|
+
|
1476
|
+
launch_mimo(get_deploy_id)
|
1477
|
+
|
1478
|
+
projects_text = "
|
1479
|
+
> Prima url: https://#{prima_hostname}
|
1480
|
+
> Backoffice (Borat) url: https://#{borat_hostname}
|
1481
|
+
> Urania url: http://#{urania_hostname}:81
|
1482
|
+
> Bburago url: http://#{bburago_hostname}:83
|
1483
|
+
> Ermes url: http://#{ermes_hostname}:10002
|
1484
|
+
> Hal9000 url: http://#{hal9000_hostname}:10031
|
1485
|
+
> Fidaty url: http://#{fidaty_hostname}:10021
|
1486
|
+
> Peano url: http://#{peano_hostname}:10039
|
1487
|
+
> Assange url: https://#{assange_hostname}
|
1488
|
+
> Activia url: http://#{activia_hostname}:10041
|
1489
|
+
> Skynet url: http://#{skynet_hostname}:8050
|
1490
|
+
> Roger url: http://#{roger_hostname}:10051
|
1491
|
+
> Leftorium url: http://#{leftorium_hostname}:10061
|
1492
|
+
> Rachele url: http://#{rachele_hostname}:10040
|
1493
|
+
> Maia App url: https://#{maia_app_hostname}
|
1494
|
+
> Maia Intermediari url: https://#{maia_intermediari_hostname}
|
1495
|
+
> Crash url: https://#{crash_hostname}
|
1496
|
+
> Starsky url: https://#{starsky_hostname}
|
1497
|
+
> Hutch url: https://#{hutch_hostname}
|
1498
|
+
> RabbitMQ url: http://#{get_ec2_ip_address}:15672
|
1499
|
+
> Elasticsearch url: http://#{get_ec2_ip_address}:9200
|
1500
|
+
> Git branch: #{@git_branch}
|
1501
|
+
> SSH connection: ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no githubUsername@#{get_ec2_ip_address}\n"
|
1502
|
+
output projects_text.cyan
|
1503
|
+
output "Deploy effettuato, everything is awesome!\n".green
|
1504
|
+
|
1505
|
+
if @projects['prima']['name'] != 'master' then
|
1506
|
+
output "Lancio il batch job per la visual regression..."
|
1507
|
+
launch_bocelli_test(prima_hostname)
|
1508
|
+
output "Visual regression lanciata con successo!"
|
1509
|
+
|
1510
|
+
output "Lancio i test con Lighthouse..."
|
1511
|
+
launch_lighthouse_test(prima_hostname, "mobile")
|
1512
|
+
launch_lighthouse_test(prima_hostname, "desktop")
|
1513
|
+
output "Test con Lighthouse lanciati con successo..."
|
1514
|
+
end
|
1515
|
+
|
1516
|
+
qainit_write_output(projects_text, 'Indirizzi scritti su ')
|
1517
|
+
end
|
1518
|
+
|
1519
|
+
def get_route53_hostname(project)
|
1520
|
+
case
|
1521
|
+
when project.include?('web')
|
1522
|
+
host = "www-#{get_deploy_id}.qa.colaster.com"
|
1523
|
+
when project.include?('urania')
|
1524
|
+
host = "urania-#{get_deploy_id}.qa.colaster.com"
|
1525
|
+
when project.include?('bburago')
|
1526
|
+
host = "bburago-#{get_deploy_id}.qa.colaster.com"
|
1527
|
+
when project.include?('hal9000')
|
1528
|
+
host = "hal9000-#{get_deploy_id}.qa.colaster.com"
|
1529
|
+
when project.include?('fidaty')
|
1530
|
+
host = "fidaty-#{get_deploy_id}.qa.colaster.com"
|
1531
|
+
when project.include?('peano')
|
1532
|
+
host = "peano-#{get_deploy_id}.qa.colaster.com"
|
1533
|
+
when project.include?('assange')
|
1534
|
+
host = "assange-#{get_deploy_id}.qa.colaster.com"
|
1535
|
+
when project.include?('borat')
|
1536
|
+
host = "backoffice-#{get_deploy_id}.qa.colaster.com"
|
1537
|
+
when project.include?('crash')
|
1538
|
+
host = "crash-#{get_deploy_id}.qa.colaster.com"
|
1539
|
+
when project.include?('ermes')
|
1540
|
+
host = "ermes-#{get_deploy_id}.qa.colaster.com"
|
1541
|
+
when project.include?('activia')
|
1542
|
+
host = "activia-#{get_deploy_id}.qa.colaster.com"
|
1543
|
+
when project.include?('skynet')
|
1544
|
+
host = "skynet-#{get_deploy_id}.qa.colaster.com"
|
1545
|
+
when project.include?('roger')
|
1546
|
+
host = "roger-#{get_deploy_id}.qa.colaster.com"
|
1547
|
+
when project.include?('leftorium')
|
1548
|
+
host = "leftorium-#{get_deploy_id}.qa.colaster.com"
|
1549
|
+
when project.include?('rachele')
|
1550
|
+
host = "rachele-#{get_deploy_id}.qa.colaster.com"
|
1551
|
+
when project.include?('starsky')
|
1552
|
+
host = "starsky-#{get_deploy_id}.qa.colaster.com"
|
1553
|
+
when project.include?('hutch')
|
1554
|
+
host = "hutch-#{get_deploy_id}.qa.colaster.com"
|
1555
|
+
when project.include?('maia-app')
|
1556
|
+
host = "api-#{get_deploy_id}.qa.colaster.com"
|
1557
|
+
when project.include?('maia-intermediari')
|
1558
|
+
host = "api-intermediari-#{get_deploy_id}.qa.colaster.com"
|
1559
|
+
end
|
1560
|
+
host
|
1561
|
+
end
|
1562
|
+
|
1563
|
+
def get_ec2_ip_address()
|
1564
|
+
if @ec2_ip_address
|
1565
|
+
@ec2_ip_address
|
1566
|
+
else
|
1567
|
+
resp = describe_stack_resource(get_asg_stack_name, 'ECSAutoScalingGroup')
|
1568
|
+
resp = describe_auto_scaling_groups([resp.stack_resource_detail.physical_resource_id], 1)
|
1569
|
+
instance_id = resp.auto_scaling_groups[0].instances[0].instance_id
|
1570
|
+
resp = describe_instances([instance_id])
|
1571
|
+
@ec2_ip_address = resp.reservations[0].instances[0].private_ip_address
|
1572
|
+
@ec2_ip_address
|
1573
|
+
end
|
1574
|
+
end
|
1575
|
+
|
1576
|
+
def get_alb_host(stack_name)
|
1577
|
+
case
|
1578
|
+
when stack_name.include?('web')
|
1579
|
+
logical_resource_id = 'EcsApplicationLoadBalancerPublic'
|
1580
|
+
when stack_name.include?('urania')
|
1581
|
+
logical_resource_id = 'EcsApplicationLoadBalancerInternal'
|
1582
|
+
when stack_name.include?('backoffice')
|
1583
|
+
logical_resource_id = 'EcsApplicationLoadBalancerPublic'
|
1584
|
+
when stack_name.include?('bburago')
|
1585
|
+
logical_resource_id = 'EcsApplicationLoadBalancerInternal'
|
1586
|
+
when stack_name.include?('hal9000')
|
1587
|
+
logical_resource_id = 'EcsApplicationLoadBalancerInternal'
|
1588
|
+
when stack_name.include?('fidaty')
|
1589
|
+
logical_resource_id = 'EcsApplicationLoadBalancerInternal'
|
1590
|
+
when stack_name.include?('activia')
|
1591
|
+
logical_resource_id = 'EcsApplicationLoadBalancerInternal'
|
1592
|
+
when stack_name.include?('skynet')
|
1593
|
+
logical_resource_id = 'EcsApplicationLoadBalancerInternal'
|
1594
|
+
when stack_name.include?('roger')
|
1595
|
+
logical_resource_id = 'EcsApplicationLoadBalancerInternal'
|
1596
|
+
when stack_name.include?('alb-http-public')
|
1597
|
+
logical_resource_id = 'EcsApplicationLoadBalancerPublic'
|
1598
|
+
when stack_name.include?('alb-ws-public')
|
1599
|
+
logical_resource_id = 'EcsApplicationLoadBalancerPublic'
|
1600
|
+
when stack_name.include?('peano')
|
1601
|
+
logical_resource_id = 'EcsApplicationLoadBalancerInternal'
|
1602
|
+
when stack_name.include?('leftorium')
|
1603
|
+
logical_resource_id = 'EcsApplicationLoadBalancerInternal'
|
1604
|
+
when stack_name.include?('assange')
|
1605
|
+
logical_resource_id = 'EcsApplicationLoadBalancerPublic'
|
1606
|
+
when stack_name.include?('borat')
|
1607
|
+
logical_resource_id = 'EcsApplicationLoadBalancerPublic'
|
1608
|
+
when stack_name.include?('crash')
|
1609
|
+
logical_resource_id = 'EcsApplicationLoadBalancerPublic'
|
1610
|
+
when stack_name.include?('rachele')
|
1611
|
+
logical_resource_id = 'EcsApplicationLoadBalancerInternal'
|
1612
|
+
when stack_name.include?('starsky')
|
1613
|
+
logical_resource_id = 'EcsApplicationLoadBalancerPublic'
|
1614
|
+
when stack_name.include?('hutch')
|
1615
|
+
logical_resource_id = 'EcsApplicationLoadBalancerPublic'
|
1616
|
+
when stack_name.include?('maia')
|
1617
|
+
logical_resource_id = 'EcsApplicationLoadBalancerPublic'
|
1618
|
+
end
|
1619
|
+
resp = describe_stack_resource(stack_name, logical_resource_id)
|
1620
|
+
resp = describe_load_balancers([resp.stack_resource_detail.physical_resource_id])
|
1621
|
+
resp.load_balancers[0].dns_name
|
1622
|
+
end
|
1623
|
+
|
1624
|
+
def update_service_defaults(stack_name)
|
1625
|
+
case
|
1626
|
+
when stack_name.include?('web')
|
1627
|
+
logical_resource_id = 'ECSServiceWebQA'
|
1628
|
+
when stack_name.include?('consumer')
|
1629
|
+
logical_resource_id = 'ECSServiceConsumerApiQa'
|
1630
|
+
when stack_name.include?('urania')
|
1631
|
+
logical_resource_id = 'ECSServiceUraniaQA'
|
1632
|
+
when stack_name.include?('backoffice')
|
1633
|
+
logical_resource_id = 'ECSServiceBackoffice'
|
1634
|
+
when stack_name.include?('worker-ermes')
|
1635
|
+
logical_resource_id = 'ECSServiceErmesWorker'
|
1636
|
+
when stack_name.include?('ermes')
|
1637
|
+
logical_resource_id = 'ECSServiceErmesQA'
|
1638
|
+
when stack_name.include?('bburago')
|
1639
|
+
logical_resource_id = 'ECSServiceBburagoQA'
|
1640
|
+
when stack_name.include?('hal9000')
|
1641
|
+
logical_resource_id = 'ECSServiceHal9000QA'
|
1642
|
+
when stack_name.include?('fidaty')
|
1643
|
+
logical_resource_id = 'ECSServiceFidatyQA'
|
1644
|
+
when stack_name.include?('skynet')
|
1645
|
+
logical_resource_id = 'ECSServiceSkynetQA'
|
1646
|
+
when stack_name.include?('roger')
|
1647
|
+
logical_resource_id = 'ECSServiceRogerQA'
|
1648
|
+
when stack_name.include?('activia')
|
1649
|
+
logical_resource_id = 'ECSServiceActiviaQA'
|
1650
|
+
when stack_name.include?('peano')
|
1651
|
+
logical_resource_id = 'ECSServicePeanoQA'
|
1652
|
+
# when stack_name.include?('rogoreport')
|
1653
|
+
# logical_resource_id = 'ECSServiceRogoreport'
|
1654
|
+
when stack_name.include?('assange')
|
1655
|
+
logical_resource_id = 'ECSServiceAssangeQA'
|
1656
|
+
when stack_name.include?('borat')
|
1657
|
+
logical_resource_id = 'ECSServiceBorat'
|
1658
|
+
when stack_name.include?('leftorium')
|
1659
|
+
logical_resource_id = 'ECSServiceLeftoriumQA'
|
1660
|
+
when stack_name.include?('rachele')
|
1661
|
+
logical_resource_id = 'ECSServiceRacheleQA'
|
1662
|
+
when stack_name.include?('crash')
|
1663
|
+
logical_resource_id = 'ECSServiceCrashQA'
|
1664
|
+
when stack_name.include?('starsky')
|
1665
|
+
logical_resource_id = 'ECSServiceStarskyQA'
|
1666
|
+
when stack_name.include?('hutch')
|
1667
|
+
logical_resource_id = 'ECSServiceHutch'
|
1668
|
+
when stack_name.include?('maia')
|
1669
|
+
logical_resource_id = 'ECSServiceMaia'
|
1670
|
+
else
|
1671
|
+
raise "Service name non gestito per lo stack #{stack_name}"
|
1672
|
+
end
|
1673
|
+
resp = describe_stack_resource(stack_name, logical_resource_id)
|
1674
|
+
update_ecs_service(get_ecs_cluster_name, resp.stack_resource_detail.physical_resource_id, {minimum_healthy_percent: 0, maximum_percent: 100})
|
1675
|
+
end
|
1676
|
+
|
1677
|
+
def launch_lighthouse_test(url, device)
|
1678
|
+
@cloudflare.post("zones/1fb634f19c43dfb0162cc4cb91915da2/dns_records", {type: 'CNAME', name: "www-#{get_deploy_id}", content: url, proxied: true, ttl: 1}) unless get_lighthouse_dns()
|
1679
|
+
|
1680
|
+
@batch.submit_job({
|
1681
|
+
job_name: "lighthouse-#{device}-#{get_deploy_id}",
|
1682
|
+
job_queue: "tools-production",
|
1683
|
+
job_definition: describe_stack_resource('batch-job-lighthouse-production', 'JobDefinition').stack_resource_detail.physical_resource_id,
|
1684
|
+
container_overrides: {
|
1685
|
+
environment: [
|
1686
|
+
{
|
1687
|
+
name: "URL_TO_TEST",
|
1688
|
+
value: "https://www-#{get_deploy_id}.prima.it/?superprima"
|
1689
|
+
},
|
1690
|
+
{
|
1691
|
+
name: "DEVICE",
|
1692
|
+
value: device
|
1693
|
+
},
|
1694
|
+
{
|
1695
|
+
name: "BRANCH_NAME",
|
1696
|
+
value: @projects['prima']['name']
|
1697
|
+
},
|
1698
|
+
{
|
1699
|
+
name: "COMMITTER_EMAIL",
|
1700
|
+
value: @projects['prima']['committer']
|
1701
|
+
}
|
1702
|
+
]
|
1703
|
+
}
|
1704
|
+
})
|
1705
|
+
end
|
1706
|
+
|
1707
|
+
def get_lighthouse_dns()
|
1708
|
+
dns_records = @cloudflare.get("zones/1fb634f19c43dfb0162cc4cb91915da2/dns_records", {per_page: 100, type: 'CNAME', name: "www-#{get_deploy_id}.prima.it"})
|
1709
|
+
if dns_records.body[:result_info][:count] > 0
|
1710
|
+
return dns_records.body[:result][0][:id]
|
1711
|
+
end
|
1712
|
+
false
|
1713
|
+
end
|
1714
|
+
|
1715
|
+
def delete_lighthouse_dns()
|
1716
|
+
dns_id = get_lighthouse_dns()
|
1717
|
+
@cloudflare.delete("zones/1fb634f19c43dfb0162cc4cb91915da2/dns_records/#{dns_id}") if dns_id
|
1718
|
+
end
|
1719
|
+
|
1720
|
+
def launch_bocelli_test(url)
|
1721
|
+
@batch.submit_job({
|
1722
|
+
job_name: "bocelli-test-#{get_deploy_id}",
|
1723
|
+
job_queue: "tools-production",
|
1724
|
+
job_definition: describe_stack_resource('batch-job-bocelli-production', 'JobDefinition').stack_resource_detail.physical_resource_id,
|
1725
|
+
container_overrides: {
|
1726
|
+
environment: [
|
1727
|
+
{
|
1728
|
+
name: "BATCH_COMMAND",
|
1729
|
+
value: "test"
|
1730
|
+
},
|
1731
|
+
{
|
1732
|
+
name: "QA_HOSTNAME",
|
1733
|
+
value: url
|
1734
|
+
},
|
1735
|
+
{
|
1736
|
+
name: "BRANCH_NAME",
|
1737
|
+
value: @projects['prima']['name']
|
1738
|
+
},
|
1739
|
+
{
|
1740
|
+
name: "COMMITTER_EMAIL",
|
1741
|
+
value: @projects['prima']['committer']
|
1742
|
+
}
|
1743
|
+
]
|
1744
|
+
}
|
1745
|
+
})
|
1746
|
+
end
|
1747
|
+
|
1748
|
+
def git_checkout_version(project, revision)
|
1749
|
+
Dir.chdir "projects/#{project}"
|
1750
|
+
exec_step "git checkout -- . && git checkout #{revision}"
|
1751
|
+
Dir.chdir "../../"
|
1752
|
+
end
|
1753
|
+
|
1754
|
+
def create_asg_stack(stack_name, tags = [])
|
1755
|
+
stack_body = IO.read('cloudformation/stacks/asg/ecs-asg-allinone.yml')
|
1756
|
+
parameters = [
|
1757
|
+
{
|
1758
|
+
parameter_key: "Environment",
|
1759
|
+
parameter_value: "qa"
|
1760
|
+
},
|
1761
|
+
{
|
1762
|
+
parameter_key: "InstanceType",
|
1763
|
+
parameter_value: "t3a.xlarge"
|
1764
|
+
},
|
1765
|
+
{
|
1766
|
+
parameter_key: "ECSClusterName",
|
1767
|
+
parameter_value: get_ecs_cluster_name
|
1768
|
+
},
|
1769
|
+
{
|
1770
|
+
parameter_key: "AMIID",
|
1771
|
+
parameter_value: @ami_id
|
1772
|
+
}
|
1773
|
+
]
|
1774
|
+
create_stack(stack_name, stack_body, parameters, tags, @cf_role)
|
1775
|
+
end
|
1776
|
+
|
1777
|
+
def create_cluster_stack(stack_name, tags = [])
|
1778
|
+
stack_body = IO.read('cloudformation/stacks/ecs-cluster.yml')
|
1779
|
+
create_stack(stack_name, stack_body, [], tags)
|
1780
|
+
end
|
1781
|
+
|
1782
|
+
def update_cluster_stack(stack_name, tags = [])
|
1783
|
+
stack_body = IO.read('cloudformation/stacks/ecs-cluster.yml')
|
1784
|
+
update_stack(stack_name, stack_body, [], tags)
|
1785
|
+
end
|
1786
|
+
|
1787
|
+
def create_alb_stack(stack_name, role, hash, environment = 'qa')
|
1788
|
+
stack_body = IO.read('cloudformation/stacks/elb/alb-public-qa.yml')
|
1789
|
+
parameters = [
|
1790
|
+
{
|
1791
|
+
parameter_key: "Environment",
|
1792
|
+
parameter_value: environment
|
1793
|
+
},
|
1794
|
+
{
|
1795
|
+
parameter_key: "Role",
|
1796
|
+
parameter_value: role
|
1797
|
+
},
|
1798
|
+
{
|
1799
|
+
parameter_key: "EnvHash",
|
1800
|
+
parameter_value: hash
|
1801
|
+
}
|
1802
|
+
]
|
1803
|
+
create_stack(stack_name, stack_body, parameters, [], @cf_role)
|
1804
|
+
end
|
1805
|
+
|
1806
|
+
def import_redis_crash(qa_ip_address)
|
1807
|
+
output "Importo chiavi di Redis da staging\n".yellow
|
1808
|
+
|
1809
|
+
prefixes = ['CODICI', 'fun_with_flags']
|
1810
|
+
redis_qa = Redis.new(:url => "redis://#{qa_ip_address}:6379/10")
|
1811
|
+
redis_staging = Redis.new(:url => 'redis://staging.cache-1.prima.it:6379/10')
|
1812
|
+
|
1813
|
+
prefixes.each do |prefix|
|
1814
|
+
redis_staging.keys("#{prefix}*").each do |key|
|
1815
|
+
next unless redis_qa.keys(key).empty?
|
1816
|
+
output "Importo #{key} dal Redis di staging\n".yellow
|
1817
|
+
dump_staging = redis_staging.dump key
|
1818
|
+
redis_qa.restore key, 0, dump_staging
|
1819
|
+
end
|
1820
|
+
end
|
1821
|
+
end
|
1822
|
+
|
1823
|
+
def import_dbs(ip_address)
|
1824
|
+
overrides = {
|
1825
|
+
container_overrides: [
|
1826
|
+
{
|
1827
|
+
name: 'dbrestore',
|
1828
|
+
environment: [
|
1829
|
+
{
|
1830
|
+
name: 'EC2_IP_ADDRESS',
|
1831
|
+
value: ip_address
|
1832
|
+
}
|
1833
|
+
]
|
1834
|
+
}
|
1835
|
+
]
|
1836
|
+
}
|
1837
|
+
resp = run_ecs_task(get_ecs_cluster_name, @import_db_task, overrides, 1)
|
1838
|
+
return resp
|
1839
|
+
end
|
1840
|
+
|
1841
|
+
def wait_for_db_import(task)
|
1842
|
+
output "Attendo che i DB vengano importati...\n".yellow
|
1843
|
+
stopped_at = nil
|
1844
|
+
sleep 15 # altrimenti non trova il task appena avviato...
|
1845
|
+
while stopped_at.nil?
|
1846
|
+
if task.tasks[0].nil?
|
1847
|
+
pp get_ecs_cluster_name
|
1848
|
+
pp task
|
1849
|
+
stop_if true, "Task di import DB lanciato, ma risposta vuota!".red
|
1850
|
+
end
|
1851
|
+
task = describe_ecs_tasks(task.tasks[0].cluster_arn, [task.tasks[0].task_arn])
|
1852
|
+
stopped_at = task.tasks[0].stopped_at unless task.tasks[0].nil?
|
1853
|
+
sleep_seconds = 10
|
1854
|
+
seconds_elapsed = 0
|
1855
|
+
while true && stopped_at.nil?
|
1856
|
+
break if seconds_elapsed >= sleep_seconds
|
1857
|
+
print '.'.yellow; STDOUT.flush
|
1858
|
+
sleep 1
|
1859
|
+
seconds_elapsed += 1
|
1860
|
+
end
|
1861
|
+
end
|
1862
|
+
print "\n"
|
1863
|
+
end
|
1864
|
+
|
1865
|
+
def get_stacks()
|
1866
|
+
envs = {}
|
1867
|
+
stack_list = stack_list()
|
1868
|
+
stack_list.each do |stack|
|
1869
|
+
unless stack.stack_name.match(/spotfleet-allinone-qa-(\w+)$/)
|
1870
|
+
env_hash = stack.stack_name.match(/qa-(\w+)$/)[0]
|
1871
|
+
envs[env_hash] = stack.tags unless envs.has_key?(env_hash) || stack.tags.empty?
|
1872
|
+
end
|
1873
|
+
end
|
1874
|
+
return stack_list, envs
|
1875
|
+
end
|
1876
|
+
|
1877
|
+
def get_clusters()
|
1878
|
+
envs = {}
|
1879
|
+
cluster_list = cluster_list()
|
1880
|
+
cluster_list.each do |stack|
|
1881
|
+
unless stack.stack_name.match(/spotfleet-allinone-qa-(\w+)$/)
|
1882
|
+
env_hash = stack.stack_name.match(/qa-(\w+)$/)[0]
|
1883
|
+
envs[env_hash] = stack.tags unless envs.has_key?(env_hash) || stack.tags.empty?
|
1884
|
+
end
|
1885
|
+
end
|
1886
|
+
return cluster_list, envs
|
1887
|
+
end
|
1888
|
+
|
1889
|
+
def hostname_pattern_priority()
|
1890
|
+
(Time.now.to_i.to_s[-4..-1].to_i + Random.rand(40000)).to_s
|
1891
|
+
end
|
1892
|
+
|
1893
|
+
def launch_mimo(env_hash)
|
1894
|
+
resp = describe_stack_resource('batch-job-mimo', 'JobDefinition')
|
1895
|
+
|
1896
|
+
@batch.submit_job({
|
1897
|
+
job_name: "mimo-#{get_deploy_id}", # required
|
1898
|
+
job_queue: "tools-production", # required
|
1899
|
+
job_definition: resp.stack_resource_detail.physical_resource_id, # required
|
1900
|
+
container_overrides: {
|
1901
|
+
environment: [
|
1902
|
+
{
|
1903
|
+
name: 'ENV_HASH',
|
1904
|
+
value: env_hash
|
1905
|
+
},
|
1906
|
+
{
|
1907
|
+
name: 'APP_ENV',
|
1908
|
+
value: 'qa'
|
1909
|
+
},
|
1910
|
+
{
|
1911
|
+
name: 'CYPRESS_BASE_URL',
|
1912
|
+
value: "https://hutch-#{env_hash}.qa.colaster.com"
|
1913
|
+
},
|
1914
|
+
{
|
1915
|
+
name: 'CYPRESS_PEANO_BASE_URL',
|
1916
|
+
value: "http://peano-#{env_hash}.qa.colaster.com:10039/quotation"
|
1917
|
+
},
|
1918
|
+
{
|
1919
|
+
name: 'CYPRESS_API_BASE_URL',
|
1920
|
+
value: "https://#{get_route53_hostname("starsky")}/graphql"
|
1921
|
+
},
|
1922
|
+
{
|
1923
|
+
name: 'QA_NAME',
|
1924
|
+
value: @git_branch
|
1925
|
+
}
|
1926
|
+
]
|
1927
|
+
}
|
1928
|
+
})
|
1929
|
+
|
1930
|
+
output "Mimo lanciato con successo!\n".green
|
1931
|
+
end
|
1932
|
+
|
1933
|
+
def get_currently_deployed_version(stack_name)
|
1934
|
+
parameters = get_stack_parameters(stack_name)
|
1935
|
+
currently_deployed_version = nil
|
1936
|
+
parameters.each do |parameter|
|
1937
|
+
if parameter.parameter_key == "ReleaseVersion"
|
1938
|
+
currently_deployed_version = parameter.parameter_value
|
1939
|
+
end
|
1940
|
+
end
|
1941
|
+
currently_deployed_version
|
1942
|
+
end
|
1943
|
+
|
1944
|
+
def get_ami_id(stack_name)
|
1945
|
+
get_stack_parameters(stack_name).each do |param|
|
1946
|
+
if param.parameter_key == "AMIID"
|
1947
|
+
return param.parameter_value
|
1948
|
+
end
|
1949
|
+
end
|
1950
|
+
end
|
1951
|
+
end
|
1952
|
+
|
1953
|
+
def help_content
|
1954
|
+
<<-HELP
|
1955
|
+
|
1956
|
+
twig-buils
|
1957
|
+
===========
|
1958
|
+
|
1959
|
+
Manage qa cloudformation stack creation
|
1960
|
+
|
1961
|
+
Synopsis
|
1962
|
+
--------
|
1963
|
+
|
1964
|
+
twig build #command
|
1965
|
+
|
1966
|
+
Description
|
1967
|
+
-----------
|
1968
|
+
|
1969
|
+
#command #command description
|
1970
|
+
|
1971
|
+
HELP
|
1972
|
+
end
|
1973
|
+
|
1974
|
+
args = ARGV.dup
|
1975
|
+
|
1976
|
+
if args.include?('--help')
|
1977
|
+
puts help_content
|
1978
|
+
exit
|
1979
|
+
end
|
1980
|
+
|
1981
|
+
args.delete('no-gem-update')
|
1982
|
+
|
1983
|
+
Build.new().execute!(args)
|