prima-twig 0.62.14 → 0.62.101
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-build +1983 -0
- data/bin/twig-feature +15 -2251
- data/bin/twig-update-ami +29 -28
- data/lib/prima_aws_client.rb +23 -0
- data/lib/prima_twig.rb +3 -1
- metadata +6 -3
data/bin/twig-update-ami
CHANGED
@@ -29,11 +29,12 @@ class TwigUpdateAmi
|
|
29
29
|
Dir.chdir 'ami'
|
30
30
|
update_instance_name(ami_id, ami_name, ami_description, ami_template)
|
31
31
|
output 'running packer update (this could take some time)'.light_green
|
32
|
-
new_ami_id = update_packer(ami_template)
|
33
|
-
# new_ami_id = 'ami-
|
32
|
+
new_ami_id = update_packer(ami_template, env)
|
33
|
+
# new_ami_id = 'ami-026890988d91ee8c6'
|
34
34
|
Dir.chdir '..'
|
35
35
|
stop_if(new_ami_id.to_s.empty?, 'Failed to generate AMI!'.red)
|
36
36
|
output "new ami id: #{new_ami_id}"
|
37
|
+
stop_if(true, "skipping stacks update")
|
37
38
|
|
38
39
|
output 'searching for ami to update...'
|
39
40
|
ami_mappings = JSON.parse(@s3.get_object(bucket: @s3_bucket, key: "ami/ami-mappings.json")["body"].read())
|
@@ -50,33 +51,33 @@ class TwigUpdateAmi
|
|
50
51
|
if stack.include?('qa')
|
51
52
|
output "skipping stack #{stack} because is a qa"
|
52
53
|
next
|
53
|
-
|
54
|
-
stack_parameters = update_stack_parameters(get_stack_parameters(stack),
|
55
|
-
[
|
56
|
-
{ parameter_key: 'AMIID', parameter_value: new_ami_id }
|
57
|
-
]
|
58
|
-
)
|
59
|
-
update_stack(stack, get_stack_template(stack), stack_parameters)
|
60
|
-
elsif stack.include?('fleet')
|
54
|
+
else
|
61
55
|
stack_tags = tags_to_hashes(get_stack_tags(stack))
|
62
56
|
stack_tags['TemplateVersion'] = stack_tags['TemplateVersion'].to_i + 1
|
63
57
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
58
|
+
if stack.include?('batch')
|
59
|
+
stack_parameters = update_stack_parameters(get_stack_parameters(stack),
|
60
|
+
[
|
61
|
+
{ parameter_key: 'AMIID', parameter_value: new_ami_id },
|
62
|
+
{ parameter_key: 'TemplateVersion', parameter_value: stack_tags['TemplateVersion'].to_s }
|
63
|
+
]
|
64
|
+
)
|
65
|
+
if stack.include?('offsite-backups')
|
66
|
+
stack_template = File.read("./cloudformation/stacks/batch/compute-environment-offsite-backups.yml")
|
67
|
+
else
|
68
|
+
stack_template = File.read("./cloudformation/stacks/batch/compute-environment.yml")
|
69
|
+
end
|
70
|
+
else
|
71
|
+
stack_parameters = update_stack_parameters(get_stack_parameters(stack),
|
72
|
+
[
|
73
|
+
{ parameter_key: 'AMIID', parameter_value: new_ami_id },
|
74
|
+
{ parameter_key: 'DesiredCapacity', parameter_value: get_desired_capacity(stack).to_s },
|
75
|
+
{ parameter_key: 'TemplateVersion', parameter_value: stack_tags['TemplateVersion'].to_s }
|
76
|
+
]
|
77
|
+
)
|
78
|
+
stack_template = File.read("./cloudformation/stacks/asg/#{stack.to_s.split("/")[1]}.yml")
|
79
|
+
end
|
80
|
+
update_stack(stack, stack_template, stack_parameters, hashes_to_tags(stack_tags))
|
80
81
|
end
|
81
82
|
end
|
82
83
|
|
@@ -149,8 +150,8 @@ class TwigUpdateAmi
|
|
149
150
|
end
|
150
151
|
end
|
151
152
|
|
152
|
-
def update_packer(json_filename)
|
153
|
-
execute_command "AWS_MAX_ATTEMPTS=90 AWS_POLL_DELAY_SECONDS=60 packer build -var datadog_apikey=`biscuit get -f ../configs/secrets/common.yml common_production_apikey_datadog` -var github_token=`biscuit get -f ../configs/secrets/common.yml common_private_repo_github_token` -var drone_key=\"`biscuit get -f ../configs/secrets/common.yml drone_license_key`\" -machine-readable ./#{json_filename} | tee build.log"
|
153
|
+
def update_packer(json_filename, env)
|
154
|
+
execute_command "AWS_MAX_ATTEMPTS=90 AWS_POLL_DELAY_SECONDS=60 packer build -var datadog_apikey=`biscuit get -f ../configs/secrets/common.yml common_production_apikey_datadog` -var github_token=`biscuit get -f ../configs/secrets/common.yml common_private_repo_github_token` -var drone_key=\"`biscuit get -f ../configs/secrets/common.yml drone_license_key`\" -var env=#{env} -machine-readable ./#{json_filename} | tee build.log"
|
154
155
|
`grep 'artifact,0,id' build.log | cut -d, -f6 | cut -d: -f2`.sub(/\n/, '')
|
155
156
|
end
|
156
157
|
|
data/lib/prima_aws_client.rb
CHANGED
@@ -337,6 +337,29 @@ module PrimaAwsClient
|
|
337
337
|
output "#{s3_bucket}/#{destination_path} uploadato con successo!\n".green
|
338
338
|
end
|
339
339
|
|
340
|
+
def wait_for_artifact(bucket, path)
|
341
|
+
ready = artifact_exists?(bucket, path)
|
342
|
+
sleep_seconds = 13
|
343
|
+
output "Attendo che lo sia pronto l'artefatto #{path}...\n".yellow
|
344
|
+
retries = 0
|
345
|
+
while !ready
|
346
|
+
ready = true if artifact_exists?(bucket, path)
|
347
|
+
seconds_elapsed = 0
|
348
|
+
loop do
|
349
|
+
break if seconds_elapsed >= sleep_seconds
|
350
|
+
print '.'.yellow; STDOUT.flush
|
351
|
+
sleep 1
|
352
|
+
seconds_elapsed += 1
|
353
|
+
end
|
354
|
+
retries += 1
|
355
|
+
if retries > 150
|
356
|
+
output "\n Timeout raggiunto aspettando #{path}\n".red
|
357
|
+
exit
|
358
|
+
end
|
359
|
+
end
|
360
|
+
output "\nArtefatto #{path} creato!\n".green
|
361
|
+
end
|
362
|
+
|
340
363
|
def list_import_stacks(export_name)
|
341
364
|
stacks = []
|
342
365
|
next_token = ''
|
data/lib/prima_twig.rb
CHANGED
@@ -20,7 +20,9 @@ class Prima
|
|
20
20
|
@twig = Twig.new(:read_options => true, :max_days_old => 30)
|
21
21
|
unless has_config?
|
22
22
|
if File.exist?('../prima/twig.yml')
|
23
|
-
|
23
|
+
`cp ../prima/twig.yml .`
|
24
|
+
elsif File.exist?('/tmp/twig.yml')
|
25
|
+
`cp /tmp/twig.yml .`
|
24
26
|
else
|
25
27
|
generate_config
|
26
28
|
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.62.
|
4
|
+
version: 0.62.101
|
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-
|
17
|
+
date: 2020-05-25 00:00:00.000000000 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: aws-sdk-autoscaling
|
@@ -285,6 +285,7 @@ dependencies:
|
|
285
285
|
description: Our tools to manage git and github
|
286
286
|
email: matteo.giachino@prima.it
|
287
287
|
executables:
|
288
|
+
- twig-build
|
288
289
|
- twig-circle
|
289
290
|
- twig-deploy
|
290
291
|
- twig-feature
|
@@ -296,6 +297,7 @@ executables:
|
|
296
297
|
extensions: []
|
297
298
|
extra_rdoc_files: []
|
298
299
|
files:
|
300
|
+
- bin/twig-build
|
299
301
|
- bin/twig-circle
|
300
302
|
- bin/twig-deploy
|
301
303
|
- bin/twig-feature
|
@@ -326,7 +328,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
326
328
|
- !ruby/object:Gem::Version
|
327
329
|
version: '0'
|
328
330
|
requirements: []
|
329
|
-
|
331
|
+
rubyforge_project:
|
332
|
+
rubygems_version: 2.7.8
|
330
333
|
signing_key:
|
331
334
|
specification_version: 4
|
332
335
|
summary: The Prima twig toolbelt
|