prima-twig 0.22.0 → 0.23.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/twig-feature +137 -30
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c4f054f0e07bcd2d1f15b8dc6a18f9c7830b7b4b
4
- data.tar.gz: 4f9b8a5c0168ee4e203d499a005128f652649a38
3
+ metadata.gz: 557c066a05b5846bcde31c11d683c36df91c9608
4
+ data.tar.gz: 10ed3de5540df2d21c630b3ffaae069d5bb124d5
5
5
  SHA512:
6
- metadata.gz: 0791e80a0c86585cb3a7b335ec912e3fcf63ec344aad21c63e74b88182111c79da3dd5e20bfa54343a4bfa705a90d70130f81e49d810f02b4e7d469fff2f854a
7
- data.tar.gz: 9729ee6521b59052c37385f1ad5e5a92dc0419c6d9db0618317f21a9f9644fccd78063d678695315d728d1e3615a93a005b74e2889381572d35ee248237656d8
6
+ metadata.gz: 46e3e2ae5f4e5077095fd5b13bf9f6f227c778266cd9e69c8791532ff9fb22df4be9289ec51063a61bb7575efa476721fdaa7bcaff41e9b2ca0adf6abcd30164
7
+ data.tar.gz: 08955a4c3d75ae2d2dce8f80a242fc819a951c626aa790b2b716860c2f8bb68bc3eec0eaeb51e904f2494a4c386f770690490178fc0d538a6ecd99623c571e8e
@@ -33,6 +33,7 @@ class Release
33
33
  @dns_record_identifier = nil
34
34
  @ecs_cluster_name = nil
35
35
  @projects = {"prima" => {}, "backoffice" => {}, "urania" => {}, "ermes" => {}, "bburago" => {}, "hal9000" => {}, "fidaty" => {}}
36
+ @stack_name_alb = "ecs-alb-http-public-qa"
36
37
  end
37
38
 
38
39
  def execute! args
@@ -130,6 +131,7 @@ class Release
130
131
  output "Attendo 60 secondi per poter eliminare il cluster ECS"
131
132
  sleep 60
132
133
  delete_stack(cluster_stack_name)
134
+ delete_stack(@stack_name_alb) if envs.length < 2
133
135
  output "Finito!".green
134
136
  end
135
137
 
@@ -211,6 +213,8 @@ class Release
211
213
  create_cluster_stack(cluster_stack_name, tags) unless stack_exists?(cluster_stack_name)
212
214
  wait_for_stack_ready(cluster_stack_name) unless stack_ready?(cluster_stack_name)
213
215
 
216
+ create_alb_stack(@stack_name_alb) unless stack_exists?(@stack_name_alb)
217
+
214
218
  resp = @cf.describe_stack_resource({stack_name: cluster_stack_name, logical_resource_id: 'ECSCluster'})
215
219
  @ecs_cluster_name = resp.stack_resource_detail.physical_resource_id
216
220
 
@@ -242,6 +246,8 @@ class Release
242
246
  wait_for_stack_ready(stack_name_db) unless stack_ready?(stack_name_db)
243
247
  import_dbs(ec2_ip_address(asg_stack_name)) unless stack_exists?("ecs-task-web-qa-#{deploy_id}")
244
248
 
249
+ wait_for_stack_ready(@stack_name_alb) unless stack_ready?(@stack_name_alb)
250
+
245
251
  stack_name_web = "ecs-task-web-qa-#{deploy_id}"
246
252
  git_checkout_version('prima', @projects["prima"][:revision])
247
253
  stack_body = IO.read('projects/prima/app/cloudformation/tasks/web.yml')
@@ -264,11 +270,19 @@ class Release
264
270
  },
265
271
  {
266
272
  parameter_key: "ALBShortName",
267
- parameter_value: "ecs-task-web-qa-#{deploy_id}"[0..31]
273
+ parameter_value: "web-qa-#{deploy_id}"[0..31]
268
274
  },
269
275
  {
270
276
  parameter_key: "WebQaBaseHostname",
271
277
  parameter_value: "#{@dns_record_identifier}.qa.colaster.com"
278
+ },
279
+ {
280
+ parameter_key: "HostnamePattern",
281
+ parameter_value: "ww*-#{@dns_record_identifier}.qa.colaster.com"
282
+ },
283
+ {
284
+ parameter_key: "HostnamePatternPriority",
285
+ parameter_value: hostname_pattern_priority()
272
286
  }
273
287
  ]
274
288
  if stack_exists?(stack_name_web)
@@ -302,7 +316,9 @@ class Release
302
316
 
303
317
  stack_name_urania = "ecs-task-urania-qa-#{deploy_id}"
304
318
  git_checkout_version('urania', @projects["urania"][:revision])
305
- stack_body = IO.read('projects/urania/deploy/task.yml')
319
+ stack_body = YAML.load_file('projects/urania/deploy/task.yml')
320
+ stack_body['Resources']['ECSServiceUrania']['Properties'].reject!{ |k| ['LoadBalancers', 'Role'].include?(k) }
321
+ stack_body = stack_body.to_yaml
306
322
  parameters = [
307
323
  {
308
324
  parameter_key: "Environment",
@@ -322,7 +338,15 @@ class Release
322
338
  },
323
339
  {
324
340
  parameter_key: "ALBShortName",
325
- parameter_value: "ecs-task-urania-qa-#{deploy_id}"[0..31]
341
+ parameter_value: "urania-qa-#{deploy_id}"[0..31]
342
+ },
343
+ {
344
+ parameter_key: "HostnamePattern",
345
+ parameter_value: "urania-#{@dns_record_identifier}.qa.colaster.com"
346
+ },
347
+ {
348
+ parameter_key: "HostnamePatternPriority",
349
+ parameter_value: hostname_pattern_priority()
326
350
  }
327
351
  ]
328
352
  if stack_exists?(stack_name_urania)
@@ -356,7 +380,9 @@ class Release
356
380
 
357
381
  stack_name_bburago = "ecs-task-bburago-qa-#{deploy_id}"
358
382
  git_checkout_version('bburago', @projects["bburago"][:revision])
359
- stack_body = IO.read('projects/bburago/deploy/task.yml')
383
+ stack_body = YAML.load_file('projects/bburago/deploy/task.yml')
384
+ stack_body['Resources']['ECSServiceBburago']['Properties'].reject!{ |k| ['LoadBalancers', 'Role'].include?(k) }
385
+ stack_body = stack_body.to_yaml
360
386
  parameters = [
361
387
  {
362
388
  parameter_key: "Environment",
@@ -376,7 +402,15 @@ class Release
376
402
  },
377
403
  {
378
404
  parameter_key: "ALBShortName",
379
- parameter_value: "ecs-task-bburago-qa-#{deploy_id}"[0..31]
405
+ parameter_value: "bburago-qa-#{deploy_id}"[0..31]
406
+ },
407
+ {
408
+ parameter_key: "HostnamePattern",
409
+ parameter_value: "bburago-#{@dns_record_identifier}.qa.colaster.com"
410
+ },
411
+ {
412
+ parameter_key: "HostnamePatternPriority",
413
+ parameter_value: hostname_pattern_priority()
380
414
  }
381
415
  ]
382
416
  if stack_exists?(stack_name_bburago)
@@ -387,7 +421,9 @@ class Release
387
421
 
388
422
  stack_name_hal9000 = "ecs-task-hal9000-qa-#{deploy_id}"
389
423
  git_checkout_version('hal9000', @projects["hal9000"][:revision])
390
- stack_body = IO.read('projects/hal9000/deploy/task.yml')
424
+ stack_body = YAML.load_file('projects/hal9000/deploy/task.yml')
425
+ stack_body['Resources']['ECSServiceHal9000']['Properties'].reject!{ |k| ['LoadBalancers', 'Role'].include?(k) }
426
+ stack_body = stack_body.to_yaml
391
427
  parameters = [
392
428
  {
393
429
  parameter_key: "Environment",
@@ -407,7 +443,15 @@ class Release
407
443
  },
408
444
  {
409
445
  parameter_key: "ALBShortName",
410
- parameter_value: "ecs-task-hal9000-qa-#{deploy_id}"[0..31]
446
+ parameter_value: "hal9000-qa-#{deploy_id}"[0..31]
447
+ },
448
+ {
449
+ parameter_key: "HostnamePattern",
450
+ parameter_value: "hal9000-#{@dns_record_identifier}.qa.colaster.com"
451
+ },
452
+ {
453
+ parameter_key: "HostnamePatternPriority",
454
+ parameter_value: hostname_pattern_priority()
411
455
  }
412
456
  ]
413
457
  if stack_exists?(stack_name_hal9000)
@@ -418,7 +462,9 @@ class Release
418
462
 
419
463
  stack_name_fidaty = "ecs-task-fidaty-qa-#{deploy_id}"
420
464
  git_checkout_version('fidaty', @projects["fidaty"][:revision])
421
- stack_body = IO.read('projects/fidaty/deploy/task.yml')
465
+ stack_body = YAML.load_file('projects/fidaty/deploy/task.yml')
466
+ stack_body['Resources']['ECSServiceFidaty']['Properties'].reject!{ |k| ['LoadBalancers', 'Role'].include?(k) }
467
+ stack_body = stack_body.to_yaml
422
468
  parameters = [
423
469
  {
424
470
  parameter_key: "Environment",
@@ -438,7 +484,15 @@ class Release
438
484
  },
439
485
  {
440
486
  parameter_key: "ALBShortName",
441
- parameter_value: "ecs-task-fidaty-qa-#{deploy_id}"[0..31]
487
+ parameter_value: "fidaty-qa-#{deploy_id}"[0..31]
488
+ },
489
+ {
490
+ parameter_key: "HostnamePattern",
491
+ parameter_value: "fidaty-#{@dns_record_identifier}.qa.colaster.com"
492
+ },
493
+ {
494
+ parameter_key: "HostnamePatternPriority",
495
+ parameter_value: hostname_pattern_priority()
442
496
  }
443
497
  ]
444
498
  if stack_exists?(stack_name_fidaty)
@@ -469,7 +523,15 @@ class Release
469
523
  },
470
524
  {
471
525
  parameter_key: "ALBShortName",
472
- parameter_value: "ecs-task-backoffice-qa-#{deploy_id}"[0..31]
526
+ parameter_value: "backoffice-qa-#{deploy_id}"[0..31]
527
+ },
528
+ {
529
+ parameter_key: "HostnamePattern",
530
+ parameter_value: "backoffice-#{@dns_record_identifier}.qa.colaster.com"
531
+ },
532
+ {
533
+ parameter_key: "HostnamePatternPriority",
534
+ parameter_value: hostname_pattern_priority()
473
535
  }
474
536
  ]
475
537
  if stack_exists?(stack_name_backoffice)
@@ -505,27 +567,27 @@ class Release
505
567
  },
506
568
  {
507
569
  parameter_key: "PrimaElbHostname",
508
- parameter_value: get_alb_host(stack_name_web)
570
+ parameter_value: get_alb_host(@stack_name_alb)
509
571
  },
510
572
  {
511
573
  parameter_key: "BackofficeElbHostname",
512
- parameter_value: get_alb_host(stack_name_backoffice)
574
+ parameter_value: get_alb_host(@stack_name_alb)
513
575
  },
514
576
  {
515
- parameter_key: "UraniaElbHostname",
516
- parameter_value: get_alb_host(stack_name_urania)
577
+ parameter_key: "UraniaIp",
578
+ parameter_value: ec2_ip_address(asg_stack_name)
517
579
  },
518
580
  {
519
- parameter_key: "BburagoElbHostname",
520
- parameter_value: get_alb_host(stack_name_bburago)
581
+ parameter_key: "BburagoIp",
582
+ parameter_value: ec2_ip_address(asg_stack_name)
521
583
  },
522
584
  {
523
- parameter_key: "Hal9000ElbHostname",
524
- parameter_value: get_alb_host(stack_name_hal9000)
585
+ parameter_key: "Hal9000Ip",
586
+ parameter_value: ec2_ip_address(asg_stack_name)
525
587
  },
526
588
  {
527
- parameter_key: "FidatyElbHostname",
528
- parameter_value: get_alb_host(stack_name_fidaty)
589
+ parameter_key: "FidatyIp",
590
+ parameter_value: ec2_ip_address(asg_stack_name)
529
591
  }
530
592
  ]
531
593
  create_stack(stack_name_route53, stack_body, parameters, tags) unless stack_exists?(stack_name_route53)
@@ -539,13 +601,13 @@ class Release
539
601
 
540
602
  wait_for_stack_ready(stack_name_route53) unless stack_ready?(stack_name_route53)
541
603
 
542
- output "Prima url: #{prima_hostname}\n".cyan
543
- output "Prima RI url: #{prima_hostname.sub("www", "wwwri")}\n".cyan
544
- output "Urania url: #{urania_hostname}\n".cyan
545
- output "Backoffice url: #{backoffice_hostname}\n".cyan
546
- output "Bburago url: #{bburago_hostname}\n".cyan
547
- output "Hal9000 url: #{hal9000_hostname}\n".cyan
548
- output "Fidaty url: #{fidaty_hostname}\n".cyan
604
+ output "Prima url: https://#{prima_hostname}\n".cyan
605
+ output "Prima RI url: https://#{prima_hostname.sub("www", "wwwri")}\n".cyan
606
+ output "Backoffice url: https://#{backoffice_hostname}\n".cyan
607
+ output "Urania url: http://#{urania_hostname}:81\n".cyan
608
+ output "Bburago url: http://#{bburago_hostname}:83\n".cyan
609
+ output "Hal9000 url: http://#{hal9000_hostname}:10031\n".cyan
610
+ output "Fidaty url: http://#{fidaty_hostname}:10021\n".cyan
549
611
  output "SSH connection: ssh ec2-user@#{ec2_ip_address(asg_stack_name)} -i ~/.ssh/ecs-cluster-qa.pem".cyan
550
612
  output "Deploy effettuato, everything is awesome!\n".green
551
613
  end
@@ -596,6 +658,8 @@ class Release
596
658
  logical_resource_id = 'EcsApplicationLoadBalancerInternal'
597
659
  when stack_name.include?('fidaty')
598
660
  logical_resource_id = 'EcsApplicationLoadBalancerInternal'
661
+ when stack_name.include?('alb-http-public')
662
+ logical_resource_id = 'EcsApplicationLoadBalancerPublic'
599
663
  end
600
664
  resp = @cf.describe_stack_resource({
601
665
  stack_name: stack_name,
@@ -676,6 +740,8 @@ class Release
676
740
 
677
741
  Dir.chdir 'projects/urania'
678
742
 
743
+ stop_unless is_branch_compatible_with_current_twig_version?("urania"), "Il tuo branch del progetto urania non e' compatibile con questa versione di twig, devi REBASARE DA MASTER!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!".red
744
+
679
745
  [
680
746
  "docker-compose build web",
681
747
  "docker run -v $PWD:/code -w /code -e MIX_ENV=qa --entrypoint /bin/sh urania_web \
@@ -744,6 +810,8 @@ class Release
744
810
 
745
811
  Dir.chdir 'projects/bburago'
746
812
 
813
+ stop_unless is_branch_compatible_with_current_twig_version?("bburago"), "Il tuo branch del progetto bburago non e' compatibile con questa versione di twig, devi REBASARE DA MASTER!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!".red
814
+
747
815
  [
748
816
  "docker-compose build web",
749
817
  "docker run -v $PWD:/code -w /code -e MIX_ENV=qa --entrypoint /bin/sh bburago_web \
@@ -778,6 +846,8 @@ class Release
778
846
 
779
847
  Dir.chdir 'projects/hal9000'
780
848
 
849
+ stop_unless is_branch_compatible_with_current_twig_version?("hal9000"), "Il tuo branch del progetto hal9000 non e' compatibile con questa versione di twig, devi REBASARE DA MASTER!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!".red
850
+
781
851
  [
782
852
  "docker-compose build web",
783
853
  "docker run -v $PWD:/code -w /code -e MIX_ENV=qa --entrypoint /bin/sh hal9000_web \
@@ -815,6 +885,8 @@ class Release
815
885
 
816
886
  Dir.chdir 'projects/fidaty'
817
887
 
888
+ stop_unless is_branch_compatible_with_current_twig_version?("fidaty"), "Il tuo branch del progetto fidaty non e' compatibile con questa versione di twig, devi REBASARE DA MASTER!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!".red
889
+
818
890
  stack_name_web = "ecs-task-web-qa-notneeded"
819
891
  web_qa_host = get_route53_hostname(stack_name_web)
820
892
 
@@ -854,6 +926,8 @@ class Release
854
926
 
855
927
  Dir.chdir 'projects/backoffice'
856
928
 
929
+ stop_unless is_branch_compatible_with_current_twig_version?("backoffice"), "Il tuo branch del progetto backoffice non e' compatibile con questa versione di twig, devi REBASARE DA MASTER!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!".red
930
+
857
931
  ['node_modules'].each do |dir|
858
932
  unless File.directory?(dir)
859
933
  if File.directory?("../../../backoffice/#{dir}")
@@ -868,6 +942,7 @@ class Release
868
942
 
869
943
  [
870
944
  "docker-compose build workers",
945
+ "rm -rf src/ && git checkout -- .",
871
946
  "cd ../../ && docker run -e GIT_DIR=$PWD -v $PWD:/usr/app/src -w /usr/app/src/projects/backoffice blinkmobile/bower install --allow-root",
872
947
  "docker run -v $PWD:/code -w /code -e PHANTOMJS_BIN=/code/node_modules/grunt-selenium-webdriver/node_modules/phantomjs/bin/phantomjs --entrypoint /bin/bash backoffice_workers '-c' 'sed -i \"s/web-qa-url/#{web_qa_host}/g\" Gruntfile.js && sed -i \"s/web-qa-ri-url/#{webri_qa_host}/g\" Gruntfile.js && npm install && grunt qa'",
873
948
  "sudo chown -R `whoami` ."
@@ -898,7 +973,7 @@ class Release
898
973
 
899
974
  Dir.chdir 'projects/prima'
900
975
 
901
- stop_unless is_branch_compatible_with_current_twig_version?, "Il tuo branch non e' compatibile con questa versione di twig, devi REBASARE DA MASTER!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!".red
976
+ stop_unless is_branch_compatible_with_current_twig_version?("prima"), "Il tuo branch del progetto prima non e' compatibile con questa versione di twig, devi REBASARE DA MASTER!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!".red
902
977
 
903
978
  ['vendor'].each do |dir|
904
979
  unless File.directory?(dir)
@@ -1004,6 +1079,21 @@ class Release
1004
1079
  create_stack(stack_name, stack_body, [], tags)
1005
1080
  end
1006
1081
 
1082
+ def create_alb_stack(stack_name)
1083
+ stack_body = IO.read('cloudformation/stacks/alb/ecs-alb-public.yml')
1084
+ parameters = [
1085
+ {
1086
+ parameter_key: "Environment",
1087
+ parameter_value: "qa"
1088
+ },
1089
+ {
1090
+ parameter_key: "Role",
1091
+ parameter_value: "http"
1092
+ }
1093
+ ]
1094
+ create_stack(stack_name, stack_body, parameters)
1095
+ end
1096
+
1007
1097
  def import_dbs(ip_address)
1008
1098
  resp = @ecs.run_task({
1009
1099
  cluster: @ecs_cluster_name,
@@ -1152,8 +1242,21 @@ class Release
1152
1242
  { name: name, revision: revision[0..14] }
1153
1243
  end
1154
1244
 
1155
- def is_branch_compatible_with_current_twig_version?
1156
- File.readlines("bin/local_build_artifact.sh").grep(/DEPLOY_ID=\$4/).size > 0
1245
+ def is_branch_compatible_with_current_twig_version?(project)
1246
+ case
1247
+ when project == 'prima'
1248
+ File.readlines("bin/deploy").grep(/HOSTNAME_PATTERN/).size > 0
1249
+ when project == 'urania'
1250
+ File.readlines("deploy/deploy").grep(/HOSTNAME_PATTERN/).size > 0
1251
+ when project == 'backoffice'
1252
+ File.readlines("deploy/deploy.sh").grep(/HOSTNAME_PATTERN/).size > 0
1253
+ when project == 'bburago'
1254
+ File.readlines("deploy/deploy").grep(/HOSTNAME_PATTERN/).size > 0
1255
+ when project == 'hal9000'
1256
+ File.readlines("deploy/deploy").grep(/HOSTNAME_PATTERN/).size > 0
1257
+ when project == 'fidaty'
1258
+ File.readlines("deploy/deploy").grep(/HOSTNAME_PATTERN/).size > 0
1259
+ end
1157
1260
  end
1158
1261
 
1159
1262
  def get_stacks()
@@ -1167,6 +1270,10 @@ class Release
1167
1270
  return stack_list, envs
1168
1271
  end
1169
1272
 
1273
+ def hostname_pattern_priority()
1274
+ (Time.now.to_i.to_s[-4..-1].to_i + Random.rand(40000)).to_s
1275
+ end
1276
+
1170
1277
  def select_branches(project_name = nil)
1171
1278
  output "Deploy feature menu"
1172
1279
  if project_name.nil?
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: 0.22.0
4
+ version: 0.23.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matteo Giachino
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2017-05-30 00:00:00.000000000 Z
15
+ date: 2017-06-07 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: twig