prima-twig 0.31.55 → 0.31.56
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 +4 -0
- data/bin/twig-update-ami +22 -1
- data/lib/prima_aws_client.rb +23 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0880a7f1e6f2543a179ad98b5bfbd05cec9bd42f'
|
4
|
+
data.tar.gz: 16ebf28302e7c32f5cd845154f6d44a69acd85c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f7eb4f286a25d22110de1648b0cd8bd6832816417ba8ddc1b4b99ad005cea4cdc592c84f670757c6673c4b08c17b2164f3b5b2e3e6c250240d3d78f84d7b01b
|
7
|
+
data.tar.gz: 531be4ca7ab4d09094e645f6431eb995ce27d4c04c0dd64dbda540315613cf8f640604f4433a74f631890de7c409ad39fad4d8760eb3325db8972ba35f5dc816
|
data/bin/twig-feature
CHANGED
@@ -1127,6 +1127,10 @@ class Release
|
|
1127
1127
|
projects_text.concat "
|
1128
1128
|
> Crash url: https://#{crash_hostname}" if deploy_crash?
|
1129
1129
|
projects_text.concat "
|
1130
|
+
> RabbitMQ url: http://#{ec2_ip_address(asg_stack_name)}:15672"
|
1131
|
+
> Supervisor url: http://#{ec2_ip_address(asg_stack_name)}:9001"
|
1132
|
+
> Elasticsearch url: http://#{ec2_ip_address(asg_stack_name)}:9200"
|
1133
|
+
> Elasticsearch 2 url: http://#{ec2_ip_address(asg_stack_name)}:9201"
|
1130
1134
|
> SSH connection: ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no githubUsername@#{ec2_ip_address(asg_stack_name)}\n"
|
1131
1135
|
output projects_text.cyan
|
1132
1136
|
output "Deploy effettuato, everything is awesome!\n".green
|
data/bin/twig-update-ami
CHANGED
@@ -51,9 +51,18 @@ class TwigUpdateAmi
|
|
51
51
|
copy_yml_files_to_s3(stack['yaml_filename'], stack['s3_key'])
|
52
52
|
output 'updating stack on cloudformation'
|
53
53
|
if stack['stack_name'] and stack_exists?(stack['stack_name'])
|
54
|
-
|
54
|
+
stack_parameters = get_stack_parameters(stack['stack_name'])
|
55
|
+
stack_parameters.each do |param|
|
56
|
+
if param.parameter_key.eql?('DesiredCapacity')
|
57
|
+
desired_capacity = get_desired_capacity(stack['stack_name'])
|
58
|
+
desired_capacity.nil? ? break : param.parameter_value.sub!(/[0-9]+/, desired_capacity.to_s)
|
59
|
+
break
|
60
|
+
end
|
61
|
+
end
|
62
|
+
update_stack_url(stack['stack_name'], stack['template_url'], stack_parameters)
|
55
63
|
end
|
56
64
|
end
|
65
|
+
|
57
66
|
unless ami['batch_compute_environments'].nil? or only_staging
|
58
67
|
ami['batch_compute_environments'].each do |ce|
|
59
68
|
update_batch_compute_environment(ce, new_ami_id)
|
@@ -83,6 +92,18 @@ class TwigUpdateAmi
|
|
83
92
|
end
|
84
93
|
end
|
85
94
|
|
95
|
+
def get_desired_capacity(stack_name)
|
96
|
+
stack_outputs = get_stack_outputs(stack_name)
|
97
|
+
stack_outputs.each do |out|
|
98
|
+
if out.export_name.include?('ECSAutoScalingGroup')
|
99
|
+
return get_autoscaling_capacity(out.output_value)
|
100
|
+
elsif out.export_name.include?('SpotFleet')
|
101
|
+
return get_spotfleet_capacity(out.output_value)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
return nil
|
105
|
+
end
|
106
|
+
|
86
107
|
def update_packer(json_filename)
|
87
108
|
execute_command "packer build -var datadog_apikey=`biscuit get -f ../configs/secrets/common.yml common_production_apikey_datadog` -machine-readable ./#{json_filename} | tee build.log"
|
88
109
|
`grep 'artifact,0,id' build.log | cut -d, -f6 | cut -d: -f2`.sub(/\n/, '')
|
data/lib/prima_aws_client.rb
CHANGED
@@ -10,6 +10,14 @@ module PrimaAwsClient
|
|
10
10
|
@cf ||= Aws::CloudFormation::Client.new
|
11
11
|
end
|
12
12
|
|
13
|
+
def asg_client
|
14
|
+
@asg ||= Aws::AutoScaling::Client.new
|
15
|
+
end
|
16
|
+
|
17
|
+
def appscaling_client
|
18
|
+
@appscaling ||= Aws::ApplicationAutoScaling::Client.new
|
19
|
+
end
|
20
|
+
|
13
21
|
def stack_list
|
14
22
|
stacks = []
|
15
23
|
next_token = ''
|
@@ -107,6 +115,11 @@ module PrimaAwsClient
|
|
107
115
|
resp.stacks[0].parameters
|
108
116
|
end
|
109
117
|
|
118
|
+
def get_stack_outputs(name)
|
119
|
+
resp = cf_client.describe_stacks(stack_name: name)
|
120
|
+
resp.stacks[0].outputs
|
121
|
+
end
|
122
|
+
|
110
123
|
def get_stack_template(name)
|
111
124
|
resp = cf_client.get_template(stack_name: name)
|
112
125
|
resp.template_body
|
@@ -154,4 +167,14 @@ module PrimaAwsClient
|
|
154
167
|
end
|
155
168
|
stacks
|
156
169
|
end
|
170
|
+
|
171
|
+
def get_autoscaling_capacity(asg_name)
|
172
|
+
resp = asg_client.describe_auto_scaling_groups(auto_scaling_group_names: [asg_name])
|
173
|
+
resp.auto_scaling_groups[0].desired_capacity
|
174
|
+
end
|
175
|
+
|
176
|
+
def get_spotfleet_capacity(fleet_arn)
|
177
|
+
resp = appscaling_client.describe_scalable_targets(service_namespace: 'ec2', resource_ids: ["spot-fleet-request/#{fleet_arn}"])
|
178
|
+
resp.scalable_targets[0].min_capacity
|
179
|
+
end
|
157
180
|
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: 0.31.
|
4
|
+
version: 0.31.56
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matteo Giachino
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2018-
|
16
|
+
date: 2018-03-08 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: aws-sdk
|