prima-twig 0.57.0 → 0.57.80
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.
- checksums.yaml +4 -4
- data/bin/twig-feature +26 -271
- data/lib/prima_aws_client.rb +93 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 51903b41de0cd28b6e1b56faa840380a3373ca3103b58365136cf426350da89a
|
|
4
|
+
data.tar.gz: b0d891e37eab45b631c00047941c56814fe595edc023eb746c2ff2c02290ff22
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 54a09eec6cb7a1bf6a70c9060223cb79959862b034425182faf38c7fbb57b85817e46a8db89a5edcf698702ebffd8fe7777123a56fa60b2cd6970d735306dafe
|
|
7
|
+
data.tar.gz: 0d8006713738879a987506f5e8d8c075970d77f252fbe684769d5222113d44395cdcae26da2f38adeaf01740f1a6fbce6f78d26b91f323495cdb64fc1992dff0
|
data/bin/twig-feature
CHANGED
|
@@ -22,12 +22,7 @@ class Release
|
|
|
22
22
|
exec "twig feature #{ARGV.join ' '}"
|
|
23
23
|
end
|
|
24
24
|
end
|
|
25
|
-
@cf = Aws::CloudFormation::Client.new
|
|
26
|
-
@alb = Aws::ElasticLoadBalancingV2::Client.new
|
|
27
|
-
@ec2 = Aws::EC2::Client.new
|
|
28
|
-
@ecs = Aws::ECS::Client.new
|
|
29
25
|
@batch = Aws::Batch::Client.new
|
|
30
|
-
@asg = Aws::AutoScaling::Client.new
|
|
31
26
|
@s3 = Aws::S3::Client.new
|
|
32
27
|
@s3_bucket = 'prima-artifacts'
|
|
33
28
|
@artifact_path = '/tmp/prima-artifact.zip'
|
|
@@ -79,8 +74,6 @@ class Release
|
|
|
79
74
|
qainit_deploy_update!
|
|
80
75
|
elsif 'read' == args[1]
|
|
81
76
|
qainit_read_config! args[2]
|
|
82
|
-
elsif 'minimal' == args[1]
|
|
83
|
-
qainit_minimal_deploy! args[2]
|
|
84
77
|
else
|
|
85
78
|
if args[1]
|
|
86
79
|
select_branches(args[1..-1])
|
|
@@ -105,8 +98,6 @@ class Release
|
|
|
105
98
|
deploy_update!
|
|
106
99
|
elsif 'lock' == args[1]
|
|
107
100
|
deploy_lock!
|
|
108
|
-
elsif 'minimal' == args[1]
|
|
109
|
-
qainit_drone_minimal_deploy!
|
|
110
101
|
else
|
|
111
102
|
if args[1]
|
|
112
103
|
select_branches(args[1])
|
|
@@ -499,35 +490,6 @@ class Release
|
|
|
499
490
|
git checkout master`
|
|
500
491
|
end
|
|
501
492
|
|
|
502
|
-
def qainit_minimal_deploy!(project)
|
|
503
|
-
abort('L\'unico progetto permesso è prima') unless ['prima'].include? project
|
|
504
|
-
project_definition = choose_branch_to_deploy(project)
|
|
505
|
-
|
|
506
|
-
`git checkout master && git pull && git remote prune origin`
|
|
507
|
-
|
|
508
|
-
default_name = project_definition[:name]
|
|
509
|
-
output "Inserisci la feature a cui si riferisce il QA: [#{default_name}]".cyan
|
|
510
|
-
feature_number = String(STDIN.gets.chomp)
|
|
511
|
-
feature_number = default_name if feature_number.empty?
|
|
512
|
-
|
|
513
|
-
if `git branch -l | grep #{feature_number}`.size > 0
|
|
514
|
-
`git checkout #{feature_number} && git pull`
|
|
515
|
-
else
|
|
516
|
-
`git checkout -b #{feature_number}`
|
|
517
|
-
end
|
|
518
|
-
|
|
519
|
-
# così recupero le informazioni sul branch, poi vado a scrivere il file branch_names con una sola riga
|
|
520
|
-
branch = {'project' => { 'name' => project_definition[:name], 'revision' => project_definition[:revision], 'default_branch' => project_definition[:default_branch]}}
|
|
521
|
-
|
|
522
|
-
File.open('branch_names', 'w') { |file| file.write(JSON.generate(branch)) }
|
|
523
|
-
|
|
524
|
-
`git add projects && \
|
|
525
|
-
git add branch_names && \
|
|
526
|
-
git commit -m 'minimal_#{feature_number}' && \
|
|
527
|
-
git push --set-upstream origin #{feature_number} && \
|
|
528
|
-
git checkout master`
|
|
529
|
-
end
|
|
530
|
-
|
|
531
493
|
def qainit_deploy_update!
|
|
532
494
|
`git checkout master && git pull`
|
|
533
495
|
# cancelliamo tutti i branch che non sono più sul repo remoto
|
|
@@ -566,11 +528,7 @@ class Release
|
|
|
566
528
|
|
|
567
529
|
File.open('branch_names', 'w') { |file| file.write(JSON.generate(@projects)) }
|
|
568
530
|
|
|
569
|
-
|
|
570
|
-
`git commit -am 'minimal_update'`
|
|
571
|
-
else
|
|
572
|
-
`git commit -am 'update'`
|
|
573
|
-
end
|
|
531
|
+
`git commit -am 'update'`
|
|
574
532
|
`git push && git checkout master`
|
|
575
533
|
end
|
|
576
534
|
|
|
@@ -678,9 +636,6 @@ class Release
|
|
|
678
636
|
when 'shutdown'
|
|
679
637
|
output 'Shutting down'.green
|
|
680
638
|
qainit_drone_shutdown!
|
|
681
|
-
when 'minimal'
|
|
682
|
-
output 'Starting minimal deploy'.green
|
|
683
|
-
qainit_drone_minimal_deploy!
|
|
684
639
|
else
|
|
685
640
|
output 'Starting standard deploy'.green
|
|
686
641
|
deploy_feature!
|
|
@@ -692,7 +647,6 @@ class Release
|
|
|
692
647
|
`mkdir -p cloudformation/stacks/task cloudformation/stacks/route53 cloudformation/stacks/asg cloudformation/stacks/elb`
|
|
693
648
|
@s3.get_object({bucket: "prima-deploy", key: 'cloudformation/stacks/task/db.yml', response_target: 'cloudformation/stacks/task/db.yml'})
|
|
694
649
|
@s3.get_object({bucket: "prima-deploy", key: 'cloudformation/stacks/route53/qa.yml', response_target: 'cloudformation/stacks/route53/qa.yml'})
|
|
695
|
-
@s3.get_object({bucket: "prima-deploy", key: 'cloudformation/stacks/route53/minimal_qa.yml', response_target: 'cloudformation/stacks/route53/minimal_qa.yml'})
|
|
696
650
|
@s3.get_object({bucket: "prima-deploy", key: 'cloudformation/stacks/asg/ecs-asg-allinone.yml', response_target: 'cloudformation/stacks/asg/ecs-asg-allinone.yml'})
|
|
697
651
|
@s3.get_object({bucket: "prima-deploy", key: 'cloudformation/stacks/ecs-cluster.yml', response_target: 'cloudformation/stacks/ecs-cluster.yml'})
|
|
698
652
|
@s3.get_object({bucket: "prima-deploy", key: 'cloudformation/stacks/elb/alb-public-qa.yml', response_target: 'cloudformation/stacks/elb/alb-public-qa.yml'})
|
|
@@ -707,173 +661,6 @@ class Release
|
|
|
707
661
|
end
|
|
708
662
|
end
|
|
709
663
|
|
|
710
|
-
def qainit_drone_minimal_deploy!
|
|
711
|
-
# tenere solo il project da deployare (l'unico project è prima)
|
|
712
|
-
@ami_id = get_ami_id("ecs-fleet-allinone-staging")
|
|
713
|
-
project = ''
|
|
714
|
-
@projects.each_key do |project_key|
|
|
715
|
-
if @projects[project_key]['revision']
|
|
716
|
-
project = project_key
|
|
717
|
-
git_checkout_version(project_key, @projects[project_key]['revision'])
|
|
718
|
-
end
|
|
719
|
-
end
|
|
720
|
-
deploy_id = get_deploy_id
|
|
721
|
-
|
|
722
|
-
@git_branch = ENV['DRONE_BRANCH']
|
|
723
|
-
@dns_record_identifier = deploy_id
|
|
724
|
-
hostname_pattern_priority = hostname_pattern_priority()
|
|
725
|
-
tags = [
|
|
726
|
-
{
|
|
727
|
-
key: "qainit",
|
|
728
|
-
value: @git_branch
|
|
729
|
-
},
|
|
730
|
-
{
|
|
731
|
-
key: project,
|
|
732
|
-
value: @projects[project]['name']
|
|
733
|
-
},
|
|
734
|
-
{
|
|
735
|
-
key: "hostname_pattern_priority",
|
|
736
|
-
value: hostname_pattern_priority
|
|
737
|
-
}
|
|
738
|
-
]
|
|
739
|
-
|
|
740
|
-
cluster_stack_name = "ecs-cluster-qa-#{deploy_id}"
|
|
741
|
-
|
|
742
|
-
if stack_exists?(cluster_stack_name)
|
|
743
|
-
tags = get_stack_tags(cluster_stack_name)
|
|
744
|
-
hostname_pattern_priority = tags.detect do |tag|
|
|
745
|
-
tag.key == 'hostname_pattern_priority'
|
|
746
|
-
end.value
|
|
747
|
-
end
|
|
748
|
-
|
|
749
|
-
stack_name_alb = @base_stack_name_alb + deploy_id[0..5]
|
|
750
|
-
stack_name_alb_ws = @base_stack_name_alb_ws + deploy_id[0..5]
|
|
751
|
-
|
|
752
|
-
create_cluster_stack(cluster_stack_name, tags) unless stack_exists?(cluster_stack_name)
|
|
753
|
-
wait_for_stack_ready(cluster_stack_name) unless stack_ready?(cluster_stack_name)
|
|
754
|
-
|
|
755
|
-
create_alb_stack(stack_name_alb, "http", deploy_id, 'qa-minimal') unless stack_exists?(stack_name_alb)
|
|
756
|
-
create_alb_stack(stack_name_alb_ws, "websocket", deploy_id, 'qa-minimal') unless stack_exists?(stack_name_alb_ws)
|
|
757
|
-
|
|
758
|
-
resp = @cf.describe_stack_resource({stack_name: cluster_stack_name, logical_resource_id: 'ECSCluster'})
|
|
759
|
-
@ecs_cluster_name = resp.stack_resource_detail.physical_resource_id
|
|
760
|
-
|
|
761
|
-
asg_stack_name = "ecs-asg-allinone-qa-#{deploy_id}"
|
|
762
|
-
create_asg_stack(asg_stack_name, tags) unless stack_exists?(asg_stack_name)
|
|
763
|
-
|
|
764
|
-
deploy_id = get_deploy_id
|
|
765
|
-
create_pyxis_artifact(@projects["pyxis-npm"]['revision'], deploy_id)
|
|
766
|
-
create_prima_artifact(@projects["prima"]['revision'], @projects["prima"]['name'], deploy_id, true) unless artifact_exists?('prima-artifacts-encrypted', "prima/#{@projects["prima"]['revision']}.tar.gz")
|
|
767
|
-
|
|
768
|
-
wait_for_stack_ready(stack_name_alb) unless stack_ready?(stack_name_alb)
|
|
769
|
-
wait_for_stack_ready(stack_name_alb_ws) unless stack_ready?(stack_name_alb_ws)
|
|
770
|
-
|
|
771
|
-
stack_name_route53 = "ecs-route53-qa-#{deploy_id}"
|
|
772
|
-
stack_body = IO.read('cloudformation/stacks/route53/minimal_qa.yml')
|
|
773
|
-
parameters = [
|
|
774
|
-
{
|
|
775
|
-
parameter_key: "DnsRecordIdentifier",
|
|
776
|
-
parameter_value: @dns_record_identifier
|
|
777
|
-
},
|
|
778
|
-
{
|
|
779
|
-
parameter_key: "PrimaElbHostname",
|
|
780
|
-
parameter_value: get_alb_host(stack_name_alb)
|
|
781
|
-
},
|
|
782
|
-
{
|
|
783
|
-
parameter_key: 'CrashElbHostname',
|
|
784
|
-
parameter_value: get_alb_host(stack_name_alb_ws)
|
|
785
|
-
}
|
|
786
|
-
]
|
|
787
|
-
|
|
788
|
-
create_stack(stack_name_route53, stack_body, parameters, tags, @cf_role) unless stack_exists?(stack_name_route53)
|
|
789
|
-
wait_for_stack_ready(stack_name_route53) unless stack_ready?(stack_name_route53)
|
|
790
|
-
|
|
791
|
-
stack_name_web = "ecs-task-web-qa-#{deploy_id}"
|
|
792
|
-
git_checkout_version('prima', @projects["prima"]['revision'])
|
|
793
|
-
stack_body = IO.read('projects/prima/app/cloudformation/tasks/web.yml')
|
|
794
|
-
parameters = [
|
|
795
|
-
{
|
|
796
|
-
parameter_key: "Environment",
|
|
797
|
-
parameter_value: "qa-minimal"
|
|
798
|
-
},
|
|
799
|
-
{
|
|
800
|
-
parameter_key: "ReleaseVersion",
|
|
801
|
-
parameter_value: "#{@projects["prima"]['revision']}"
|
|
802
|
-
},
|
|
803
|
-
{
|
|
804
|
-
parameter_key: "TaskDesiredCount",
|
|
805
|
-
parameter_value: "1"
|
|
806
|
-
},
|
|
807
|
-
{
|
|
808
|
-
parameter_key: "ECSClusterName",
|
|
809
|
-
parameter_value: @ecs_cluster_name
|
|
810
|
-
},
|
|
811
|
-
{
|
|
812
|
-
parameter_key: "ALBShortName",
|
|
813
|
-
parameter_value: "web-qa-#{deploy_id}"[0..27]
|
|
814
|
-
},
|
|
815
|
-
{
|
|
816
|
-
parameter_key: "WebQaBaseHostname",
|
|
817
|
-
parameter_value: "#{@dns_record_identifier}.qa.colaster.com"
|
|
818
|
-
},
|
|
819
|
-
{
|
|
820
|
-
parameter_key: "HostnamePattern",
|
|
821
|
-
parameter_value: "ww*-#{@dns_record_identifier}.qa.colaster.com"
|
|
822
|
-
},
|
|
823
|
-
{
|
|
824
|
-
parameter_key: "HostnamePatternPriority",
|
|
825
|
-
parameter_value: hostname_pattern_priority
|
|
826
|
-
},
|
|
827
|
-
{
|
|
828
|
-
parameter_key: "HostnamePatternAggregatorPriority",
|
|
829
|
-
parameter_value: (hostname_pattern_priority.to_i + 1).to_s
|
|
830
|
-
},
|
|
831
|
-
{
|
|
832
|
-
parameter_key: "EnvHash",
|
|
833
|
-
parameter_value: deploy_id
|
|
834
|
-
},
|
|
835
|
-
{
|
|
836
|
-
parameter_key: "AssangeHostname",
|
|
837
|
-
parameter_value: "assange-#{@dns_record_identifier}.qa.colaster.com"
|
|
838
|
-
},
|
|
839
|
-
{
|
|
840
|
-
parameter_key: "BackofficeHostname",
|
|
841
|
-
parameter_value: "backoffice-#{@dns_record_identifier}.qa.colaster.com"
|
|
842
|
-
},
|
|
843
|
-
{
|
|
844
|
-
parameter_key: "WebHostname",
|
|
845
|
-
parameter_value: "www-#{@dns_record_identifier}.qa.colaster.com"
|
|
846
|
-
},
|
|
847
|
-
{
|
|
848
|
-
parameter_key: "FePrimaDomain",
|
|
849
|
-
parameter_value: "www-#{@dns_record_identifier}.qa.colaster.com"
|
|
850
|
-
},
|
|
851
|
-
{
|
|
852
|
-
parameter_key: "HostnamePattern",
|
|
853
|
-
parameter_value: "www-#{@dns_record_identifier}.qa.colaster.com"
|
|
854
|
-
}
|
|
855
|
-
]
|
|
856
|
-
if stack_exists?(stack_name_web)
|
|
857
|
-
cur_version = get_currently_deployed_version(stack_name_web)
|
|
858
|
-
update_stack(stack_name_web, stack_body, parameters, tags, @cf_role) unless cur_version.include?(@projects["prima"]['revision'])
|
|
859
|
-
else
|
|
860
|
-
create_stack(stack_name_web, stack_body, parameters, tags, @cf_role)
|
|
861
|
-
end
|
|
862
|
-
wait_for_stack_ready(stack_name_web) unless stack_ready?(stack_name_web)
|
|
863
|
-
update_service_defaults(stack_name_web)
|
|
864
|
-
prima_hostname = get_route53_hostname(stack_name_web)
|
|
865
|
-
|
|
866
|
-
projects_text = "
|
|
867
|
-
> Prima url: https://#{prima_hostname}
|
|
868
|
-
> SSH connection: ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no githubUsername@#{ec2_ip_address(asg_stack_name)}\n"
|
|
869
|
-
|
|
870
|
-
output projects_text.cyan
|
|
871
|
-
output "Deploy effettuato, everything is awesome!\n".green
|
|
872
|
-
if @qainit
|
|
873
|
-
qainit_write_output(projects_text, 'Indirizzi scritti su ')
|
|
874
|
-
end
|
|
875
|
-
end
|
|
876
|
-
|
|
877
664
|
def deploy_feature!
|
|
878
665
|
`git pull && git submodule init && git submodule update`
|
|
879
666
|
@ami_id = get_ami_id("ecs-fleet-allinone-staging")
|
|
@@ -926,7 +713,7 @@ class Release
|
|
|
926
713
|
create_alb_stack(stack_name_alb, "http", deploy_id) unless stack_exists?(stack_name_alb)
|
|
927
714
|
create_alb_stack(stack_name_alb_ws, "websocket", deploy_id) unless stack_exists?(stack_name_alb_ws)
|
|
928
715
|
|
|
929
|
-
resp =
|
|
716
|
+
resp = describe_stack_resource(cluster_stack_name, 'ECSCluster')
|
|
930
717
|
@ecs_cluster_name = resp.stack_resource_detail.physical_resource_id
|
|
931
718
|
|
|
932
719
|
asg_stack_name = "ecs-asg-allinone-qa-#{deploy_id}"
|
|
@@ -2037,16 +1824,10 @@ class Release
|
|
|
2037
1824
|
end
|
|
2038
1825
|
|
|
2039
1826
|
def ec2_ip_address(asg_stack_name)
|
|
2040
|
-
resp =
|
|
2041
|
-
|
|
2042
|
-
logical_resource_id: 'ECSAutoScalingGroup'
|
|
2043
|
-
})
|
|
2044
|
-
resp = @asg.describe_auto_scaling_groups({
|
|
2045
|
-
auto_scaling_group_names: [resp.stack_resource_detail.physical_resource_id],
|
|
2046
|
-
max_records: 1
|
|
2047
|
-
})
|
|
1827
|
+
resp = describe_stack_resource(asg_stack_name, 'ECSAutoScalingGroup')
|
|
1828
|
+
resp = describe_auto_scaling_groups([resp.stack_resource_detail.physical_resource_id], 1)
|
|
2048
1829
|
instance_id = resp.auto_scaling_groups[0].instances[0].instance_id
|
|
2049
|
-
resp =
|
|
1830
|
+
resp = describe_instances([instance_id])
|
|
2050
1831
|
resp.reservations[0].instances[0].private_ip_address
|
|
2051
1832
|
end
|
|
2052
1833
|
|
|
@@ -2091,13 +1872,8 @@ class Release
|
|
|
2091
1872
|
when stack_name.include?('hutch')
|
|
2092
1873
|
logical_resource_id = 'EcsApplicationLoadBalancerPublic'
|
|
2093
1874
|
end
|
|
2094
|
-
resp =
|
|
2095
|
-
|
|
2096
|
-
logical_resource_id: logical_resource_id
|
|
2097
|
-
})
|
|
2098
|
-
resp = @alb.describe_load_balancers({
|
|
2099
|
-
load_balancer_arns: [resp.stack_resource_detail.physical_resource_id]
|
|
2100
|
-
})
|
|
1875
|
+
resp = describe_stack_resource(stack_name, logical_resource_id)
|
|
1876
|
+
resp = describe_load_balancers([resp.stack_resource_detail.physical_resource_id])
|
|
2101
1877
|
resp.load_balancers[0].dns_name
|
|
2102
1878
|
end
|
|
2103
1879
|
|
|
@@ -2146,18 +1922,8 @@ class Release
|
|
|
2146
1922
|
else
|
|
2147
1923
|
raise "Service name non gestito per lo stack #{stack_name}"
|
|
2148
1924
|
end
|
|
2149
|
-
resp =
|
|
2150
|
-
|
|
2151
|
-
logical_resource_id: logical_resource_id
|
|
2152
|
-
)
|
|
2153
|
-
@ecs.update_service(
|
|
2154
|
-
cluster: @ecs_cluster_name,
|
|
2155
|
-
service: resp.stack_resource_detail.physical_resource_id,
|
|
2156
|
-
deployment_configuration: {
|
|
2157
|
-
minimum_healthy_percent: 0,
|
|
2158
|
-
maximum_percent: 100
|
|
2159
|
-
}
|
|
2160
|
-
)
|
|
1925
|
+
resp = describe_stack_resource(stack_name, logical_resource_id)
|
|
1926
|
+
update_ecs_service(@ecs_cluster_name, resp.stack_resource_detail.physical_resource_id, {minimum_healthy_percent: 0, maximum_percent: 100})
|
|
2161
1927
|
end
|
|
2162
1928
|
|
|
2163
1929
|
def create_activia_artifact(revision)
|
|
@@ -2531,7 +2297,7 @@ class Release
|
|
|
2531
2297
|
Dir.chdir '../../'
|
|
2532
2298
|
end
|
|
2533
2299
|
|
|
2534
|
-
def create_prima_artifact(revision, branch_name, deploy_id
|
|
2300
|
+
def create_prima_artifact(revision, branch_name, deploy_id)
|
|
2535
2301
|
output "Preparo l'artifact prima .zip\n".yellow
|
|
2536
2302
|
|
|
2537
2303
|
git_checkout_version('prima', revision)
|
|
@@ -2892,24 +2658,20 @@ class Release
|
|
|
2892
2658
|
end
|
|
2893
2659
|
|
|
2894
2660
|
def import_dbs(ip_address)
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
]
|
|
2910
|
-
},
|
|
2911
|
-
count: 1
|
|
2912
|
-
})
|
|
2661
|
+
overrides = {
|
|
2662
|
+
container_overrides: [
|
|
2663
|
+
{
|
|
2664
|
+
name: 'dbrestore',
|
|
2665
|
+
environment: [
|
|
2666
|
+
{
|
|
2667
|
+
name: 'EC2_IP_ADDRESS',
|
|
2668
|
+
value: ip_address
|
|
2669
|
+
}
|
|
2670
|
+
]
|
|
2671
|
+
}
|
|
2672
|
+
]
|
|
2673
|
+
}
|
|
2674
|
+
resp = run_ecs_task(@ecs_cluster_name, @import_db_task, overrides, 1)
|
|
2913
2675
|
return resp
|
|
2914
2676
|
end
|
|
2915
2677
|
|
|
@@ -2923,10 +2685,7 @@ class Release
|
|
|
2923
2685
|
pp task
|
|
2924
2686
|
stop_if true, "Task di import DB lanciato, ma risposta vuota!".red
|
|
2925
2687
|
end
|
|
2926
|
-
task =
|
|
2927
|
-
cluster: task.tasks[0].cluster_arn,
|
|
2928
|
-
tasks: [task.tasks[0].task_arn]
|
|
2929
|
-
})
|
|
2688
|
+
task = describe_ecs_tasks(task.tasks[0].cluster_arn, [task.tasks[0].task_arn])
|
|
2930
2689
|
stopped_at = task.tasks[0].stopped_at unless task.tasks[0].nil?
|
|
2931
2690
|
sleep_seconds = 10
|
|
2932
2691
|
seconds_elapsed = 0
|
|
@@ -3030,10 +2789,7 @@ class Release
|
|
|
3030
2789
|
end
|
|
3031
2790
|
|
|
3032
2791
|
def launch_marley(ip_address, prima_hostname, borat_hostname)
|
|
3033
|
-
resp =
|
|
3034
|
-
stack_name: 'batch-job-marley',
|
|
3035
|
-
logical_resource_id: 'JobDefinition'
|
|
3036
|
-
})
|
|
2792
|
+
resp = describe_stack_resource('batch-job-marley', 'JobDefinition')
|
|
3037
2793
|
|
|
3038
2794
|
@batch.submit_job({
|
|
3039
2795
|
job_name: "marley-#{@dns_record_identifier}", # required
|
|
@@ -3142,7 +2898,6 @@ Description
|
|
|
3142
2898
|
finish finishes the feature by merging to dev and master
|
|
3143
2899
|
qainit deploys a new environment with selected branches from every project
|
|
3144
2900
|
qainit $PROJECT_NAME deploys a new environment allowing to selected a branch from the input project (everything else is master)
|
|
3145
|
-
qainit minimal prima deploys a new copy of prima project, using staging microservices and database
|
|
3146
2901
|
qainit shutdown deletes a specific qa environment
|
|
3147
2902
|
|
|
3148
2903
|
Available only to devops (from artemide)
|
data/lib/prima_aws_client.rb
CHANGED
|
@@ -18,6 +18,14 @@ module PrimaAwsClient
|
|
|
18
18
|
@ec2 ||= Aws::EC2::Client.new
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
+
def alb_client
|
|
22
|
+
@alb ||= Aws::ElasticLoadBalancingV2::Client.new
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def ecs_client
|
|
26
|
+
@ecs ||= Aws::ECS::Client.new
|
|
27
|
+
end
|
|
28
|
+
|
|
21
29
|
def stack_list
|
|
22
30
|
stacks = []
|
|
23
31
|
next_token = ''
|
|
@@ -307,6 +315,91 @@ module PrimaAwsClient
|
|
|
307
315
|
stacks
|
|
308
316
|
end
|
|
309
317
|
|
|
318
|
+
def describe_stack_resource(cluster_stack_name, logical_resource_id)
|
|
319
|
+
begin
|
|
320
|
+
resp = cf_client.describe_stack_resource({stack_name: cluster_stack_name, logical_resource_id: logical_resource_id})
|
|
321
|
+
rescue Aws::CloudFormation::Errors::Throttling => e
|
|
322
|
+
output 'Throttling, retrying in 15 seconds'.red
|
|
323
|
+
sleep 15
|
|
324
|
+
resp = describe_stack_resource(cluster_stack_name, logical_resource_id)
|
|
325
|
+
end
|
|
326
|
+
end
|
|
327
|
+
|
|
328
|
+
def describe_instances(instance_ids)
|
|
329
|
+
begin
|
|
330
|
+
resp = ec2_client.describe_instances({instance_ids: instance_ids})
|
|
331
|
+
rescue Aws::CloudFormation::Errors::Throttling => e
|
|
332
|
+
output 'Throttling, retrying in 15 seconds'.red
|
|
333
|
+
sleep 15
|
|
334
|
+
resp = describe_instances(instance_ids)
|
|
335
|
+
end
|
|
336
|
+
end
|
|
337
|
+
|
|
338
|
+
def describe_auto_scaling_groups(auto_scaling_group_names, max_records)
|
|
339
|
+
begin
|
|
340
|
+
resp = asg_client.describe_auto_scaling_groups({
|
|
341
|
+
auto_scaling_group_names: auto_scaling_group_names,
|
|
342
|
+
max_records: max_records
|
|
343
|
+
})
|
|
344
|
+
rescue Aws::CloudFormation::Errors::Throttling => e
|
|
345
|
+
output 'Throttling, retrying in 15 seconds'.red
|
|
346
|
+
sleep 15
|
|
347
|
+
resp = describe_auto_scaling_groups(auto_scaling_group_names, max_records)
|
|
348
|
+
end
|
|
349
|
+
end
|
|
350
|
+
|
|
351
|
+
def describe_load_balancers(load_balancer_arns)
|
|
352
|
+
begin
|
|
353
|
+
resp = alb_client.describe_load_balancers({load_balancer_arns: load_balancer_arns})
|
|
354
|
+
rescue Aws::CloudFormation::Errors::Throttling => e
|
|
355
|
+
output 'Throttling, retrying in 15 seconds'.red
|
|
356
|
+
sleep 15
|
|
357
|
+
resp = describe_load_balancers(load_balancer_arns)
|
|
358
|
+
end
|
|
359
|
+
end
|
|
360
|
+
|
|
361
|
+
def update_ecs_service(cluster, service, deployment_configuration)
|
|
362
|
+
begin
|
|
363
|
+
resp = ecs_client.update_service(
|
|
364
|
+
cluster: cluster,
|
|
365
|
+
service: service,
|
|
366
|
+
deployment_configuration: deployment_configuration
|
|
367
|
+
)
|
|
368
|
+
rescue Aws::CloudFormation::Errors::Throttling => e
|
|
369
|
+
output 'Throttling, retrying in 15 seconds'.red
|
|
370
|
+
sleep 15
|
|
371
|
+
resp = update_ecs_service(cluster, service, deployment_configuration)
|
|
372
|
+
end
|
|
373
|
+
end
|
|
374
|
+
|
|
375
|
+
def describe_ecs_tasks(cluster, tasks)
|
|
376
|
+
begin
|
|
377
|
+
resp = ecs_client.describe_tasks({
|
|
378
|
+
cluster: cluster,
|
|
379
|
+
tasks: tasks
|
|
380
|
+
})
|
|
381
|
+
rescue Aws::CloudFormation::Errors::Throttling => e
|
|
382
|
+
output 'Throttling, retrying in 15 seconds'.red
|
|
383
|
+
sleep 15
|
|
384
|
+
resp = describe_ecs_tasks(cluster, tasks)
|
|
385
|
+
end
|
|
386
|
+
end
|
|
387
|
+
|
|
388
|
+
def run_ecs_task(cluster, task_definition, overrides, count)
|
|
389
|
+
begin
|
|
390
|
+
resp = ecs_client.run_task({
|
|
391
|
+
cluster: cluster,
|
|
392
|
+
task_definition: task_definition,
|
|
393
|
+
overrides: overrides,
|
|
394
|
+
count: count
|
|
395
|
+
})
|
|
396
|
+
rescue Aws::CloudFormation::Errors::Throttling => e
|
|
397
|
+
output 'Throttling, retrying in 15 seconds'.red
|
|
398
|
+
sleep 15
|
|
399
|
+
resp = run_ecs_task(cluster, task_definition, overrides, count)
|
|
400
|
+
end
|
|
401
|
+
end
|
|
402
|
+
|
|
310
403
|
def get_autoscaling_capacity(asg_name)
|
|
311
404
|
resp = asg_client.describe_auto_scaling_groups(auto_scaling_group_names: [asg_name])
|
|
312
405
|
resp.auto_scaling_groups[0].desired_capacity
|
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.57.
|
|
4
|
+
version: 0.57.80
|
|
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: 2019-11-
|
|
17
|
+
date: 2019-11-26 00:00:00.000000000 Z
|
|
18
18
|
dependencies:
|
|
19
19
|
- !ruby/object:Gem::Dependency
|
|
20
20
|
name: aws-sdk
|