prima-twig 1.0.41 → 1.0.42

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