prima-twig 0.20.0 → 0.54.20
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 +5 -5
- data/bin/twig-deploy +46 -50
- data/bin/twig-feature +2482 -551
- data/bin/twig-update-ami +197 -0
- data/lib/command.rb +37 -24
- data/lib/prima_aws_client.rb +336 -0
- data/lib/prima_twig.rb +8 -2
- metadata +60 -28
data/bin/twig-feature
CHANGED
|
@@ -2,67 +2,140 @@
|
|
|
2
2
|
|
|
3
3
|
require 'rubygems'
|
|
4
4
|
require_relative '../lib/prima_twig.rb'
|
|
5
|
-
|
|
5
|
+
require_relative '../lib/prima_aws_client.rb'
|
|
6
6
|
require 'digest'
|
|
7
|
+
require 'json'
|
|
8
|
+
require 'launchy'
|
|
7
9
|
require 'pp'
|
|
10
|
+
require 'redis'
|
|
8
11
|
|
|
9
12
|
class Release
|
|
10
13
|
include Command
|
|
14
|
+
include PrimaAwsClient
|
|
11
15
|
|
|
12
|
-
def initialize
|
|
16
|
+
def initialize(update_gem=true)
|
|
13
17
|
@prima = Prima.new
|
|
14
|
-
|
|
15
|
-
|
|
18
|
+
if update_gem
|
|
19
|
+
output 'Controllo se ci sono aggiornamenti da fare (potrebbe richiedere qualche minuto)'
|
|
20
|
+
unless `gem update prima-twig`=="Updating installed gems\nNothing to update\n"
|
|
21
|
+
output 'Gemma prima-twig aggiornata'
|
|
22
|
+
exec "twig feature #{ARGV.join ' '}"
|
|
23
|
+
end
|
|
24
|
+
end
|
|
16
25
|
@cf = Aws::CloudFormation::Client.new
|
|
17
|
-
@elb = Aws::ElasticLoadBalancing::Client.new
|
|
18
26
|
@alb = Aws::ElasticLoadBalancingV2::Client.new
|
|
19
27
|
@ec2 = Aws::EC2::Client.new
|
|
20
28
|
@ecs = Aws::ECS::Client.new
|
|
21
|
-
@
|
|
29
|
+
@batch = Aws::Batch::Client.new
|
|
22
30
|
@asg = Aws::AutoScaling::Client.new
|
|
31
|
+
@s3 = Aws::S3::Client.new
|
|
23
32
|
@s3_bucket = 'prima-artifacts'
|
|
24
33
|
@artifact_path = '/tmp/prima-artifact.zip'
|
|
25
|
-
@import_db_task = 'arn:aws:ecs:eu-west-1:001575623345:task-definition/ecs-task-db-restore2-TaskDefinitionDbRestore-
|
|
26
|
-
@
|
|
27
|
-
@urania_built = false
|
|
28
|
-
@ermes_built = false
|
|
29
|
-
@bburago_built = false
|
|
30
|
-
@hal9000_built = false
|
|
31
|
-
@fidaty_built = false
|
|
32
|
-
@backoffice_built = false
|
|
34
|
+
@import_db_task = 'arn:aws:ecs:eu-west-1:001575623345:task-definition/ecs-task-db-restore2-TaskDefinitionDbRestore-1BXH13XEVLPP0:1'
|
|
35
|
+
@cf_role = 'arn:aws:iam::001575623345:role/qainit-service-role-cloudformat-CloudformationRole-18KBZQIS148R9'
|
|
33
36
|
@dns_record_identifier = nil
|
|
34
37
|
@ecs_cluster_name = nil
|
|
35
|
-
@
|
|
38
|
+
@deploy_update = false
|
|
39
|
+
@qainit = false
|
|
40
|
+
@qainit_host_folder = "/var/ci/#{ENV['DRONE_REPO']}/#{ENV['DRONE_BRANCH']}/#{ENV['DRONE_BUILD_NUMBER']}"
|
|
41
|
+
@qainit_folder = "/drone/src/github.com/project/primait/qainit"
|
|
42
|
+
@projects = {
|
|
43
|
+
'prima' => {},
|
|
44
|
+
'urania' => {},
|
|
45
|
+
'ermes' => {},
|
|
46
|
+
'bburago' => {},
|
|
47
|
+
'hal9000' => {},
|
|
48
|
+
'fidaty' => {},
|
|
49
|
+
'peano' => {},
|
|
50
|
+
'rogoreport' => {},
|
|
51
|
+
'assange' => {},
|
|
52
|
+
'borat' => {},
|
|
53
|
+
'crash' => {},
|
|
54
|
+
'activia' => {},
|
|
55
|
+
'skynet' => {},
|
|
56
|
+
'roger' => {},
|
|
57
|
+
'rachele' => {},
|
|
58
|
+
'leftorium' => {},
|
|
59
|
+
'pyxis-npm' => {},
|
|
60
|
+
'starsky' => {},
|
|
61
|
+
'hutch' => {}
|
|
62
|
+
}
|
|
63
|
+
@base_stack_name_alb = 'ecs-alb-http-public-qa-'
|
|
64
|
+
@base_stack_name_alb_ws = 'ecs-alb-ws-public-qa-'
|
|
65
|
+
@git_branch = ''
|
|
36
66
|
end
|
|
37
67
|
|
|
38
|
-
def execute!
|
|
68
|
+
def execute!(args)
|
|
39
69
|
case args[0]
|
|
40
|
-
when
|
|
70
|
+
when 'start'
|
|
41
71
|
start_feature!
|
|
42
|
-
when
|
|
72
|
+
when 'finish'
|
|
43
73
|
finish_feature!
|
|
44
|
-
when
|
|
74
|
+
when 'qainit'
|
|
75
|
+
abort('Non sei nella cartella di qainit') unless Dir.pwd.match 'qainit$' or Dir.pwd.match '/drone/src'
|
|
76
|
+
if ['terminate', 'stop', 'shutdown', 'halt', 'destroy'].include? args[1]
|
|
77
|
+
qainit_deploy_shutdown!
|
|
78
|
+
elsif 'update' == args[1]
|
|
79
|
+
qainit_deploy_update!
|
|
80
|
+
elsif 'read' == args[1]
|
|
81
|
+
qainit_read_config! args[2]
|
|
82
|
+
elsif 'minimal' == args[1]
|
|
83
|
+
qainit_minimal_deploy! args[2]
|
|
84
|
+
else
|
|
85
|
+
if args[1]
|
|
86
|
+
select_branches(args[1..-1])
|
|
87
|
+
else
|
|
88
|
+
select_branches
|
|
89
|
+
end
|
|
90
|
+
qainit_deploy!
|
|
91
|
+
end
|
|
92
|
+
when 'suite'
|
|
93
|
+
abort('Non sei nella cartella di qainit') unless Dir.pwd.match 'qainit$'
|
|
94
|
+
if 'deploy' == args[1]
|
|
95
|
+
suite_py_branches(args[2])
|
|
96
|
+
qainit_deploy!(true)
|
|
97
|
+
else
|
|
98
|
+
qainit_deploy_shutdown!(args[2])
|
|
99
|
+
end
|
|
100
|
+
when 'deploy'
|
|
101
|
+
abort('Non sei nella cartella di artemide') unless Dir.pwd.match 'artemide$'
|
|
45
102
|
if ['terminate', 'stop', 'shutdown', 'halt', 'destroy'].include? args[1]
|
|
46
103
|
deploy_shutdown!
|
|
47
|
-
elsif
|
|
104
|
+
elsif 'update' == args[1]
|
|
48
105
|
deploy_update!
|
|
106
|
+
elsif 'lock' == args[1]
|
|
107
|
+
deploy_lock!
|
|
108
|
+
elsif 'minimal' == args[1]
|
|
109
|
+
qainit_drone_minimal_deploy!
|
|
49
110
|
else
|
|
50
111
|
if args[1]
|
|
51
112
|
select_branches(args[1])
|
|
52
|
-
deploy_feature!
|
|
53
113
|
else
|
|
54
114
|
select_branches
|
|
55
|
-
deploy_feature!
|
|
56
115
|
end
|
|
116
|
+
deploy_feature!
|
|
117
|
+
end
|
|
118
|
+
when 'aggregator'
|
|
119
|
+
if 'enable' == args[1]
|
|
120
|
+
aggregator_enable!
|
|
121
|
+
elsif 'disable' == args[1]
|
|
122
|
+
aggregator_disable!
|
|
123
|
+
else
|
|
124
|
+
stop_for_wrong_args
|
|
57
125
|
end
|
|
58
126
|
else
|
|
59
|
-
|
|
127
|
+
stop_for_wrong_args
|
|
60
128
|
end
|
|
61
129
|
end
|
|
62
130
|
|
|
131
|
+
def stop_for_wrong_args
|
|
132
|
+
puts help_content
|
|
133
|
+
stop_if true, [:wrong_args, ['start', 'finish', 'deploy', 'deploy project_name', 'deploy stop', 'deploy update', 'aggregator enable', 'aggregator disable']]
|
|
134
|
+
end
|
|
135
|
+
|
|
63
136
|
def start_feature!
|
|
64
137
|
branch_name = @prima.clean_branch_name(ask('Inserisci il nome del branch (puoi omettere feature/): '.cyan))
|
|
65
|
-
stop_unless branch_name.
|
|
138
|
+
stop_unless !branch_name.empty?, 'Devi inserire il nome del branch'
|
|
66
139
|
branch_name.prepend 'feature/' unless branch_name.include? 'feature'
|
|
67
140
|
|
|
68
141
|
output "Il nome del branch sarà " + branch_name.yellow
|
|
@@ -72,6 +145,138 @@ class Release
|
|
|
72
145
|
exec_step "git checkout -b " + branch_name
|
|
73
146
|
end
|
|
74
147
|
|
|
148
|
+
def aggregator_disable!
|
|
149
|
+
output 'Disable aggregator'
|
|
150
|
+
|
|
151
|
+
output "Recupero le informazioni relative al puntamento dei record DNS..."
|
|
152
|
+
cloudflare = Rubyflare.connect_with(@prima.config['cloudflare_email'], @prima.config['cloudflare_apikey'])
|
|
153
|
+
output "Recupero le informazioni sui QA attivi..."
|
|
154
|
+
stack_list, envs = get_stacks()
|
|
155
|
+
|
|
156
|
+
env_hash = nil
|
|
157
|
+
unless envs.empty?
|
|
158
|
+
env_hash = envs.detect do |key, tags|
|
|
159
|
+
aggregator_enabled = tags.detect do |tag|
|
|
160
|
+
tag.key === "hostname_pattern_priority" and tag.value === "1"
|
|
161
|
+
end.is_a?(Aws::CloudFormation::Types::Tag)
|
|
162
|
+
aggregator_enabled
|
|
163
|
+
end[0]
|
|
164
|
+
dns_records = cloudflare.get("zones/1fb634f19c43dfb0162cc4cb91915da2/dns_records", {per_page: 100, type: 'CNAME', content: get_alb_host(@base_stack_name_alb + env_hash[3..8])})
|
|
165
|
+
stop_if dns_records.body[:result].empty?, "I record DNS degli aggregatori non stanno puntando ad un QA".red
|
|
166
|
+
change_hostname_priority(env_hash, hostname_pattern_priority())
|
|
167
|
+
dns_to_staging(env_hash)
|
|
168
|
+
else
|
|
169
|
+
output 'Nessun QA trovato'.red
|
|
170
|
+
exit
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
output 'Finito!'.green
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
def aggregator_enable!
|
|
177
|
+
output 'Enable aggregator'
|
|
178
|
+
|
|
179
|
+
output 'Recupero le informazioni relative al puntamento dei record DNS...'
|
|
180
|
+
cloudflare = Rubyflare.connect_with(@prima.config['cloudflare_email'], @prima.config['cloudflare_apikey'])
|
|
181
|
+
dns_records = cloudflare.get('zones/1fb634f19c43dfb0162cc4cb91915da2/dns_records', { per_page: 100, type: 'CNAME', content: 'staging.prima.it' })
|
|
182
|
+
stop_if dns_records.body[:result].empty?, "I record DNS degli aggregatori stanno gia' puntando ad un QA".red
|
|
183
|
+
|
|
184
|
+
output "Recupero le informazioni sui QA attivi..."
|
|
185
|
+
stack_list, envs = get_stacks()
|
|
186
|
+
|
|
187
|
+
env_hash = nil
|
|
188
|
+
unless envs.empty?
|
|
189
|
+
env_hash = choose do |menu|
|
|
190
|
+
menu.prompt = "Scegli il QA al quale vuoi far puntare gli ambienti di staging dei comparatori: ".cyan
|
|
191
|
+
menu.shell = true
|
|
192
|
+
envs.each do |key, env|
|
|
193
|
+
title = ""
|
|
194
|
+
env.each do |e|
|
|
195
|
+
title << "\n#{e.key.upcase}: #{e.value}"
|
|
196
|
+
end
|
|
197
|
+
msg = "#{@prima.reduce_size(title, 1000)}".light_blue
|
|
198
|
+
menu.choice(msg) { key }
|
|
199
|
+
end
|
|
200
|
+
end
|
|
201
|
+
else
|
|
202
|
+
output "Nessun QA trovato".red
|
|
203
|
+
exit
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
change_hostname_priority(env_hash, "1")
|
|
207
|
+
|
|
208
|
+
dns_records.body[:result].each do |dns|
|
|
209
|
+
if dns[:name] =~ /^\w+\-\w+\-staging\.prima\.it$/
|
|
210
|
+
output "Changing #{dns[:name]} DNS record"
|
|
211
|
+
cloudflare.put("zones/1fb634f19c43dfb0162cc4cb91915da2/dns_records/#{dns[:id]}", {type: 'CNAME', name: dns[:name], content: get_alb_host(@base_stack_name_alb + env_hash[3..8]), proxied: true, ttl: 1})
|
|
212
|
+
end
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
output "Finito!".green
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
def change_hostname_priority(env_hash, hostname_pattern_priority)
|
|
219
|
+
cluster_stack_name = "ecs-cluster-#{env_hash}"
|
|
220
|
+
tags = get_stack_tags(cluster_stack_name).map do |tag|
|
|
221
|
+
if tag.key === "hostname_pattern_priority"
|
|
222
|
+
{
|
|
223
|
+
key: "hostname_pattern_priority",
|
|
224
|
+
value: hostname_pattern_priority
|
|
225
|
+
}
|
|
226
|
+
else
|
|
227
|
+
tag
|
|
228
|
+
end
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
stack_list = stack_list()
|
|
232
|
+
|
|
233
|
+
stack_list.each do |stack|
|
|
234
|
+
if stack.stack_name.match(/#{env_hash}$/)
|
|
235
|
+
stack_name = stack.stack_name
|
|
236
|
+
update_stack(stack_name, get_stack_template(stack_name), get_stack_parameters(stack_name), tags)
|
|
237
|
+
end
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
stack_list.each do |stack|
|
|
241
|
+
if stack.stack_name.match(/#{env_hash}$/)
|
|
242
|
+
wait_for_stack_ready(stack.stack_name) unless stack_ready?(stack.stack_name)
|
|
243
|
+
end
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
stack_name_web = "ecs-task-web-#{env_hash}"
|
|
247
|
+
parameters = get_stack_parameters(stack_name_web).map do |param|
|
|
248
|
+
if param.parameter_key === "HostnamePatternPriority"
|
|
249
|
+
{
|
|
250
|
+
parameter_key: "HostnamePatternPriority",
|
|
251
|
+
parameter_value: hostname_pattern_priority
|
|
252
|
+
}
|
|
253
|
+
elsif param.parameter_key === "HostnamePatternAggregatorPriority"
|
|
254
|
+
{
|
|
255
|
+
parameter_key: "HostnamePatternAggregatorPriority",
|
|
256
|
+
parameter_value: (hostname_pattern_priority.to_i + 1).to_s
|
|
257
|
+
}
|
|
258
|
+
else
|
|
259
|
+
param
|
|
260
|
+
end
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
update_stack(stack_name_web, get_stack_template(stack_name_web), parameters)
|
|
264
|
+
|
|
265
|
+
wait_for_stack_ready(stack_name_web) unless stack_ready?(stack_name_web)
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
def dns_to_staging(env_hash)
|
|
269
|
+
output "Recupero le informazioni relative al puntamento dei record DNS..."
|
|
270
|
+
cloudflare = Rubyflare.connect_with(@prima.config['cloudflare_email'], @prima.config['cloudflare_apikey'])
|
|
271
|
+
dns_records = cloudflare.get("zones/1fb634f19c43dfb0162cc4cb91915da2/dns_records", {per_page: 100, type: 'CNAME', content: get_alb_host(@base_stack_name_alb + env_hash[3..8])})
|
|
272
|
+
dns_records.body[:result].each do |dns|
|
|
273
|
+
if dns[:name] =~ /^\w+\-\w+\-staging\.prima\.it$/
|
|
274
|
+
output "Changing #{dns[:name]} DNS record"
|
|
275
|
+
cloudflare.put("zones/1fb634f19c43dfb0162cc4cb91915da2/dns_records/#{dns[:id]}", {type: 'CNAME', name: dns[:name], content: 'staging.prima.it', proxied: true, ttl: 1})
|
|
276
|
+
end
|
|
277
|
+
end
|
|
278
|
+
end
|
|
279
|
+
|
|
75
280
|
def finish_feature!
|
|
76
281
|
current_branch_name = @prima.twig.current_branch_name
|
|
77
282
|
stop_unless (current_branch_name =~ /^feature\//), "Non sei su un branch di feature, non posso mergiare nulla"
|
|
@@ -93,7 +298,7 @@ class Release
|
|
|
93
298
|
|
|
94
299
|
def deploy_shutdown!
|
|
95
300
|
output "Recupero le informazioni sui QA attivi..."
|
|
96
|
-
stack_list, envs = get_stacks
|
|
301
|
+
stack_list, envs = get_stacks
|
|
97
302
|
|
|
98
303
|
env_hash = nil
|
|
99
304
|
unless envs.empty?
|
|
@@ -102,42 +307,105 @@ class Release
|
|
|
102
307
|
menu.shell = true
|
|
103
308
|
|
|
104
309
|
envs.each do |key, env|
|
|
105
|
-
title =
|
|
310
|
+
title = ''
|
|
106
311
|
env.each do |e|
|
|
107
|
-
title << "#{e.key}: #{e.value} "
|
|
312
|
+
title << "\n#{e.key}: #{e.value} "
|
|
108
313
|
end
|
|
109
|
-
msg =
|
|
314
|
+
msg = @prima.reduce_size(title, 1000).to_s.light_blue
|
|
110
315
|
menu.choice(msg) { key }
|
|
111
316
|
end
|
|
112
317
|
end
|
|
113
318
|
else
|
|
114
|
-
output
|
|
319
|
+
output 'Nessun environment trovato'.red
|
|
115
320
|
exit
|
|
116
321
|
end
|
|
117
322
|
|
|
118
323
|
cluster_stack_name = nil
|
|
324
|
+
stacks_to_delete = []
|
|
119
325
|
stack_list.each do |stack|
|
|
120
326
|
if stack.stack_name.match(/#{env_hash}$/)
|
|
121
327
|
if stack.stack_name.match(/ecs-cluster/)
|
|
122
328
|
cluster_stack_name = stack.stack_name
|
|
123
329
|
else
|
|
124
|
-
|
|
330
|
+
break unless stack.stack_name.match(/#{env_hash}$/)
|
|
331
|
+
stacks_to_delete.push(stack.stack_name)
|
|
332
|
+
delete_stack(stack.stack_name)
|
|
125
333
|
end
|
|
126
334
|
end
|
|
127
335
|
end
|
|
128
336
|
|
|
337
|
+
cluster_stack_name = "ecs-cluster-#{env_hash}"
|
|
338
|
+
aggregator_enabled = get_stack_tags(cluster_stack_name).detect do |tag|
|
|
339
|
+
tag.key === "hostname_pattern_priority" and tag.value === "1"
|
|
340
|
+
end.is_a?(Aws::CloudFormation::Types::Tag)
|
|
341
|
+
|
|
342
|
+
if aggregator_enabled
|
|
343
|
+
dns_to_staging(env_hash)
|
|
344
|
+
end
|
|
345
|
+
|
|
129
346
|
# Se non ha finito di cancellare le altre non si puo' cancellare il cluster
|
|
130
|
-
output "Attendo
|
|
131
|
-
|
|
347
|
+
output "Attendo 10 secondi per poter eliminare il cluster ECS"
|
|
348
|
+
|
|
349
|
+
while stacks_to_delete.length > 0
|
|
350
|
+
sleep 13
|
|
351
|
+
stacks_to_delete.each do |stack_name|
|
|
352
|
+
stacks_to_delete = stacks_to_delete - [stack_name] unless stack_exists?(stack_name)
|
|
353
|
+
end
|
|
354
|
+
output "Stack ancora attivi: #{stacks_to_delete.length.to_s}. Attendo altri 10 secondi per eliminare il cluster ECS"
|
|
355
|
+
end
|
|
356
|
+
|
|
132
357
|
delete_stack(cluster_stack_name)
|
|
358
|
+
delete_stack(@base_stack_name_alb + env_hash[3..8])
|
|
359
|
+
delete_stack(@base_stack_name_alb_ws + env_hash[3..8])
|
|
360
|
+
output "Finito!".green
|
|
361
|
+
end
|
|
362
|
+
|
|
363
|
+
def deploy_lock!
|
|
364
|
+
output "Deploy update menu"
|
|
365
|
+
`git pull && git submodule init && git submodule update`
|
|
366
|
+
|
|
367
|
+
@deploy_update = true
|
|
368
|
+
|
|
369
|
+
output "Recupero le informazioni sui QA attivi..."
|
|
370
|
+
stack_list, envs = get_clusters()
|
|
371
|
+
|
|
372
|
+
env_hash = nil
|
|
373
|
+
unless envs.empty?
|
|
374
|
+
env_hash = choose do |menu|
|
|
375
|
+
menu.prompt = "Scegli il QA che vuoi proteggere dallo spegnimento automatico: ".cyan
|
|
376
|
+
menu.shell = true
|
|
377
|
+
envs.each do |key, env|
|
|
378
|
+
title = ""
|
|
379
|
+
env.each do |e|
|
|
380
|
+
title << "#{e.value}" if e.key == 'qainit'
|
|
381
|
+
end
|
|
382
|
+
msg = "#{@prima.reduce_size(title, 1000)}".light_blue
|
|
383
|
+
menu.choice(msg) { key }
|
|
384
|
+
end
|
|
385
|
+
end
|
|
386
|
+
else
|
|
387
|
+
output "Nessun QA trovato".red
|
|
388
|
+
exit
|
|
389
|
+
end
|
|
390
|
+
|
|
391
|
+
cluster_stack_name = "ecs-cluster-#{env_hash}"
|
|
392
|
+
if stack_exists?(cluster_stack_name)
|
|
393
|
+
tags = get_stack_tags(cluster_stack_name)
|
|
394
|
+
tag_keep_data = Aws::CloudFormation::Types::Tag.new({key:'AUTOMATIC_DELETION_PROTECTION', value:'true'})
|
|
395
|
+
tags.push tag_keep_data
|
|
396
|
+
end
|
|
397
|
+
|
|
398
|
+
update_cluster_stack(cluster_stack_name, tags)
|
|
399
|
+
|
|
133
400
|
output "Finito!".green
|
|
134
401
|
end
|
|
135
402
|
|
|
136
403
|
def deploy_update!
|
|
137
404
|
output "Deploy update menu"
|
|
138
|
-
`sudo true` # cosi' non chiede la password dopo
|
|
139
405
|
`git pull && git submodule init && git submodule update`
|
|
140
406
|
|
|
407
|
+
@deploy_update = true
|
|
408
|
+
|
|
141
409
|
output "Recupero le informazioni sui QA attivi..."
|
|
142
410
|
stack_list, envs = get_stacks()
|
|
143
411
|
|
|
@@ -161,86 +429,373 @@ class Release
|
|
|
161
429
|
end
|
|
162
430
|
|
|
163
431
|
envs[env_hash].each do |env|
|
|
164
|
-
|
|
432
|
+
unless ['hostname_pattern_priority', 'AUTOMATIC_DELETION_PROTECTION'].include? env.key
|
|
433
|
+
@projects[env.key] = select_branch_to_deploy(env.key, env.value)
|
|
434
|
+
end
|
|
165
435
|
end
|
|
166
|
-
|
|
167
436
|
deploy_feature!
|
|
168
437
|
|
|
169
438
|
output "Finito!".green
|
|
170
439
|
end
|
|
171
440
|
|
|
172
|
-
def
|
|
173
|
-
|
|
174
|
-
|
|
441
|
+
def get_default_branch_name(projects)
|
|
442
|
+
if !projects['prima'][:default_branch]
|
|
443
|
+
return projects['prima'][:name]
|
|
444
|
+
elsif ![nil, 'master'].include? projects['crash'][:name]
|
|
445
|
+
return projects['crash'][:name]
|
|
446
|
+
else
|
|
447
|
+
projects.each_key do |project_key|
|
|
448
|
+
return projects[project_key][:name] if projects[project_key][:name] != 'master'
|
|
449
|
+
end
|
|
450
|
+
end
|
|
451
|
+
end
|
|
175
452
|
|
|
176
|
-
|
|
177
|
-
|
|
453
|
+
def suite_py_branches(args_json)
|
|
454
|
+
args = JSON.parse(args_json)
|
|
455
|
+
|
|
456
|
+
args['projects'].each_key do |project|
|
|
457
|
+
@projects[project] = { name: args['projects'][project]['branch'], revision: args['projects'][project]['revision'], committer: '', default_branch: false }
|
|
458
|
+
end
|
|
459
|
+
|
|
460
|
+
@projects.each_key do |project|
|
|
461
|
+
@projects[project] = choose_branch_to_deploy(project, true) unless args['projects'].key? project
|
|
462
|
+
end
|
|
463
|
+
end
|
|
464
|
+
|
|
465
|
+
def get_git_user()
|
|
466
|
+
`git config user.name`.gsub(/[^A-Za-z]/, '').gsub("\n", '')
|
|
467
|
+
end
|
|
468
|
+
|
|
469
|
+
def get_git_mail()
|
|
470
|
+
`git config user.email`.gsub("\n", '')
|
|
471
|
+
end
|
|
472
|
+
|
|
473
|
+
def qainit_deploy!(quiet = false)
|
|
474
|
+
`git checkout master && git pull && git remote prune origin`
|
|
475
|
+
|
|
476
|
+
default_name = get_default_branch_name @projects
|
|
477
|
+
feature_number = ''
|
|
478
|
+
unless quiet
|
|
479
|
+
output "Inserisci la feature a cui si riferisce il QA: [#{default_name}]".cyan
|
|
480
|
+
feature_number = String(STDIN.gets.chomp)
|
|
481
|
+
end
|
|
482
|
+
feature_number = default_name if feature_number.empty?
|
|
483
|
+
branch_name = get_git_user + '_' + feature_number
|
|
484
|
+
|
|
485
|
+
if `git branch -l | grep #{branch_name}`.size > 0
|
|
486
|
+
`git checkout #{branch_name} && git pull`
|
|
487
|
+
else
|
|
488
|
+
`git checkout -b #{branch_name}`
|
|
489
|
+
end
|
|
490
|
+
|
|
491
|
+
branches = ''
|
|
492
|
+
@git_branch = branch_name
|
|
493
|
+
|
|
494
|
+
@projects.each_key do |project_key|
|
|
495
|
+
if @projects[project_key][:revision]
|
|
496
|
+
branches += "#{project_key}:#{@projects[project_key][:name]}:#{@projects[project_key][:revision]}:#{@projects[project_key][:default_branch]}\n"
|
|
497
|
+
end
|
|
498
|
+
end
|
|
499
|
+
|
|
500
|
+
File.open('branch_names', 'w') { |file| file.write(branches) }
|
|
501
|
+
|
|
502
|
+
`git add projects && \
|
|
503
|
+
git add branch_names && \
|
|
504
|
+
git commit -m '#{branch_name}' && \
|
|
505
|
+
git push -f --set-upstream origin #{branch_name} && \
|
|
506
|
+
git checkout master`
|
|
507
|
+
end
|
|
508
|
+
|
|
509
|
+
def qainit_minimal_deploy!(project)
|
|
510
|
+
abort('L\'unico progetto permesso è prima') unless ['prima'].include? project
|
|
511
|
+
project_definition = choose_branch_to_deploy(project)
|
|
512
|
+
|
|
513
|
+
`git checkout master && git pull && git remote prune origin`
|
|
514
|
+
|
|
515
|
+
default_name = project_definition[:name]
|
|
516
|
+
output "Inserisci la feature a cui si riferisce il QA: [#{default_name}]".cyan
|
|
517
|
+
feature_number = String(STDIN.gets.chomp)
|
|
518
|
+
feature_number = default_name if feature_number.empty?
|
|
519
|
+
|
|
520
|
+
if `git branch -l | grep #{feature_number}`.size > 0
|
|
521
|
+
`git checkout #{feature_number} && git pull`
|
|
522
|
+
else
|
|
523
|
+
`git checkout -b #{feature_number}`
|
|
524
|
+
end
|
|
525
|
+
|
|
526
|
+
# così recupero le informazioni sul branch, poi vado a scrivere il file branch_names con una sola riga
|
|
527
|
+
branch = "#{project}:#{project_definition[:name]}:#{project_definition[:revision]}:#{project_definition[:default_branch]}"
|
|
528
|
+
|
|
529
|
+
File.open('branch_names', 'w') { |file| file.write(branch) }
|
|
530
|
+
|
|
531
|
+
`git add projects && \
|
|
532
|
+
git add branch_names && \
|
|
533
|
+
git commit -m 'minimal_#{feature_number}' && \
|
|
534
|
+
git push --set-upstream origin #{feature_number} && \
|
|
535
|
+
git checkout master`
|
|
536
|
+
end
|
|
537
|
+
|
|
538
|
+
def qainit_deploy_update!
|
|
539
|
+
`git checkout master && git pull`
|
|
540
|
+
# cancelliamo tutti i branch che non sono più sul repo remoto
|
|
541
|
+
`git fetch -p && for branch in \`git branch -vv | grep ': gone]' | awk '{print $1}'\`; do git branch -D $branch; done`
|
|
542
|
+
# leggiamo i nomi dei branch superstiti
|
|
543
|
+
former_branches = `git branch -a | grep remotes/ | grep -v HEAD | sed 's/ remotes\\/origin\\///g'`.split "\n"
|
|
544
|
+
git_user = get_git_user
|
|
545
|
+
# stampiamo la lista
|
|
546
|
+
chosen_branch = choose do |menu|
|
|
547
|
+
menu.prompt = "Scegli il QA che vuoi aggiornare: ".cyan
|
|
548
|
+
menu.shell = true
|
|
549
|
+
former_branches.delete('master')
|
|
550
|
+
former_branches.each_with_index do |branch, index|
|
|
551
|
+
msg = index.odd? ? branch.white : branch.light_yellow # uno bianco e uno giallo alternati
|
|
552
|
+
msg = branch.start_with?(git_user) ? msg.on_blue : msg.on_black # i branch creati da chi lancia l'update sono su sfondo più chiaro
|
|
553
|
+
menu.choice(msg) { branch }
|
|
554
|
+
end
|
|
555
|
+
end
|
|
556
|
+
# checkout master, checkout branch, pull branch
|
|
557
|
+
`git checkout master && git checkout #{chosen_branch} && git pull`
|
|
558
|
+
|
|
559
|
+
# aggiornare il commit (revision a cui fa riferimento)
|
|
560
|
+
|
|
561
|
+
# leggo il file branch_names / recupero i nomi dei branch / riscrivo tutto
|
|
562
|
+
File.open('branch_names', 'r') do |file|
|
|
563
|
+
file.each_line do |line|
|
|
564
|
+
project = line.split(':')
|
|
565
|
+
@projects[project[0]] = select_branch_to_deploy(project[0], project[1])
|
|
566
|
+
@projects[project[0]][:default_branch] = project[3]
|
|
567
|
+
end
|
|
568
|
+
end
|
|
569
|
+
|
|
570
|
+
branches = ''
|
|
571
|
+
|
|
572
|
+
@projects.each_key do |project_key|
|
|
573
|
+
if @projects[project_key][:revision]
|
|
574
|
+
branches += "#{project_key}:#{@projects[project_key][:name]}:#{@projects[project_key][:revision]}:#{@projects[project_key][:default_branch]}"
|
|
575
|
+
end
|
|
576
|
+
end
|
|
577
|
+
|
|
578
|
+
File.open('branch_names', 'w') { |file| file.write(branches) }
|
|
579
|
+
|
|
580
|
+
if `git log -1` =~ /minimal_/
|
|
581
|
+
`git commit -am 'minimal_update'`
|
|
582
|
+
else
|
|
583
|
+
`git commit -am 'update'`
|
|
584
|
+
end
|
|
585
|
+
`git push && git checkout master`
|
|
586
|
+
end
|
|
587
|
+
|
|
588
|
+
def qainit_deploy_shutdown!(selection = nil)
|
|
589
|
+
`git checkout master && git pull && git remote prune origin`
|
|
590
|
+
# leggiamo i nomi dei branch
|
|
591
|
+
former_branches = `git branch -a | grep remotes/ | grep -v HEAD | sed 's/ remotes\\/origin\\///g'`.split "\n"
|
|
592
|
+
if selection.nil?
|
|
593
|
+
# stampiamo la lista
|
|
594
|
+
chosen_branch = choose do |menu|
|
|
595
|
+
menu.prompt = "Scegli il QA che vuoi spegnere: ".cyan
|
|
596
|
+
menu.shell = true
|
|
597
|
+
git_user = get_git_user
|
|
598
|
+
former_branches.delete('master')
|
|
599
|
+
former_branches.each_with_index do |branch, index|
|
|
600
|
+
msg = index.odd? ? branch.white : branch.light_yellow # uno bianco e uno giallo alternati
|
|
601
|
+
msg = branch.start_with?(git_user) ? msg.on_blue : msg.on_black # i branch creati da chi lancia l'update sono su sfondo blu
|
|
602
|
+
menu.choice(msg) { branch }
|
|
603
|
+
end
|
|
604
|
+
end
|
|
605
|
+
else
|
|
606
|
+
chosen_branch = selection
|
|
607
|
+
end
|
|
608
|
+
# checkout master, checkout branch, pull branch, push sul branch con commit vuoto
|
|
609
|
+
`git checkout master && git checkout #{chosen_branch} && git pull`
|
|
610
|
+
`git commit --allow-empty -m 'shutdown' && git push && git checkout master`
|
|
611
|
+
end
|
|
178
612
|
|
|
613
|
+
def qainit_drone_shutdown!
|
|
614
|
+
output "Recupero le informazioni sui QA attivi..."
|
|
615
|
+
stack_list, envs = get_stacks
|
|
616
|
+
|
|
617
|
+
env_hash = "qa-" + get_deploy_id
|
|
618
|
+
|
|
619
|
+
cluster_stack_name = nil
|
|
620
|
+
stacks_to_delete = []
|
|
621
|
+
stack_list.each do |stack|
|
|
622
|
+
if stack.stack_name.match(/#{env_hash}$/)
|
|
623
|
+
if stack.stack_name.match(/ecs-cluster/)
|
|
624
|
+
cluster_stack_name = stack.stack_name
|
|
625
|
+
else
|
|
626
|
+
break unless stack.stack_name.match(/#{env_hash}$/)
|
|
627
|
+
stacks_to_delete.push(stack.stack_name)
|
|
628
|
+
delete_stack(stack.stack_name)
|
|
629
|
+
end
|
|
630
|
+
end
|
|
631
|
+
end
|
|
632
|
+
|
|
633
|
+
cluster_stack_name = "ecs-cluster-#{env_hash}"
|
|
634
|
+
if stack_exists?(cluster_stack_name)
|
|
635
|
+
aggregator_enabled = get_stack_tags(cluster_stack_name).detect do |tag|
|
|
636
|
+
tag.key === "hostname_pattern_priority" and tag.value === "1"
|
|
637
|
+
end.is_a?(Aws::CloudFormation::Types::Tag)
|
|
638
|
+
|
|
639
|
+
if aggregator_enabled
|
|
640
|
+
dns_to_staging(env_hash)
|
|
641
|
+
end
|
|
642
|
+
end
|
|
643
|
+
|
|
644
|
+
# Se non ha finito di cancellare le altre non si puo' cancellare il cluster
|
|
645
|
+
output "Attendo 10 secondi per poter eliminare il cluster ECS"
|
|
646
|
+
|
|
647
|
+
while stacks_to_delete.length > 0
|
|
648
|
+
sleep 13
|
|
649
|
+
stacks_to_delete.each do |stack_name|
|
|
650
|
+
stacks_to_delete = stacks_to_delete - [stack_name] unless stack_exists?(stack_name)
|
|
651
|
+
end
|
|
652
|
+
output "Stack ancora attivi: #{stacks_to_delete.length.to_s}. Attendo altri 10 secondi per eliminare il cluster ECS"
|
|
653
|
+
end
|
|
654
|
+
|
|
655
|
+
delete_stack(cluster_stack_name) if stack_exists?(cluster_stack_name)
|
|
656
|
+
delete_stack(@base_stack_name_alb + env_hash[3..8]) if stack_exists?(@base_stack_name_alb + env_hash[3..8])
|
|
657
|
+
delete_stack(@base_stack_name_alb_ws + env_hash[3..8]) if stack_exists?(@base_stack_name_alb_ws + env_hash[3..8])
|
|
658
|
+
`git checkout master && git push origin --delete ${DRONE_BRANCH}`
|
|
659
|
+
output "Finito!".green
|
|
660
|
+
|
|
661
|
+
if @qainit
|
|
662
|
+
qainit_write_output("QA #{ENV["DRONE_BRANCH"]} spento.", 'Indirizzi scritti su ')
|
|
663
|
+
end
|
|
664
|
+
end
|
|
665
|
+
|
|
666
|
+
def qainit_write_output(file_message, output_message)
|
|
667
|
+
`mkdir -p /etc/qainit-output`
|
|
668
|
+
qa_file_name = "/etc/qainit-output/url_qa"
|
|
669
|
+
File.open(qa_file_name + '.txt', 'w') { |file| file.write(file_message) }
|
|
670
|
+
output "#{output_message} #{qa_file_name}".green
|
|
671
|
+
end
|
|
672
|
+
|
|
673
|
+
def qainit_read_config!(action)
|
|
674
|
+
File.open('branch_names', 'r') do |file|
|
|
675
|
+
file.each_line do |line|
|
|
676
|
+
project = line.gsub("\n", '').split(':')
|
|
677
|
+
if project[3] == 'true'
|
|
678
|
+
@projects[project[0]] = {:name=> project[1], :revision=> project[2], :default_branch=> true}
|
|
679
|
+
elsif project[3] == 'false'
|
|
680
|
+
@projects[project[0]] = {:name=> project[1], :revision=> project[2], :default_branch=> false}
|
|
681
|
+
end
|
|
682
|
+
end
|
|
683
|
+
end
|
|
684
|
+
get_s3_config_files
|
|
685
|
+
@qainit = true
|
|
686
|
+
case action
|
|
687
|
+
when 'shutdown'
|
|
688
|
+
output 'Shutting down'.green
|
|
689
|
+
qainit_drone_shutdown!
|
|
690
|
+
when 'minimal'
|
|
691
|
+
output 'Starting minimal deploy'.green
|
|
692
|
+
qainit_drone_minimal_deploy!
|
|
693
|
+
else
|
|
694
|
+
output 'Starting standard deploy'.green
|
|
695
|
+
deploy_feature!
|
|
696
|
+
end
|
|
697
|
+
end
|
|
698
|
+
|
|
699
|
+
def get_s3_config_files
|
|
700
|
+
# manteniamo la struttura per lanciarlo facilmente anche da locale
|
|
701
|
+
`mkdir -p cloudformation/stacks/task cloudformation/stacks/route53 cloudformation/stacks/asg cloudformation/stacks/elb`
|
|
702
|
+
@s3.get_object({bucket: "prima-deploy", key: 'cloudformation/stacks/task/db.yml', response_target: 'cloudformation/stacks/task/db.yml'})
|
|
703
|
+
@s3.get_object({bucket: "prima-deploy", key: 'cloudformation/stacks/route53/qa.yml', response_target: 'cloudformation/stacks/route53/qa.yml'})
|
|
704
|
+
@s3.get_object({bucket: "prima-deploy", key: 'cloudformation/stacks/route53/minimal_qa.yml', response_target: 'cloudformation/stacks/route53/minimal_qa.yml'})
|
|
705
|
+
@s3.get_object({bucket: "prima-deploy", key: 'cloudformation/stacks/asg/ecs-asg-allinone.yml', response_target: 'cloudformation/stacks/asg/ecs-asg-allinone.yml'})
|
|
706
|
+
@s3.get_object({bucket: "prima-deploy", key: 'cloudformation/stacks/ecs-cluster.yml', response_target: 'cloudformation/stacks/ecs-cluster.yml'})
|
|
707
|
+
@s3.get_object({bucket: "prima-deploy", key: 'cloudformation/stacks/elb/alb-public-qa.yml', response_target: 'cloudformation/stacks/elb/alb-public-qa.yml'})
|
|
708
|
+
end
|
|
709
|
+
|
|
710
|
+
def get_deploy_id
|
|
711
|
+
if @deploy_id
|
|
712
|
+
@deploy_id
|
|
713
|
+
else
|
|
714
|
+
@deploy_id = Digest::MD5.hexdigest(ENV['DRONE_BRANCH'])
|
|
715
|
+
@deploy_id
|
|
716
|
+
end
|
|
717
|
+
end
|
|
718
|
+
|
|
719
|
+
def qainit_drone_minimal_deploy!
|
|
720
|
+
# tenere solo il project da deployare (l'unico project è prima)
|
|
721
|
+
@ami_id = get_ami_id("ecs-fleet-allinone-staging")
|
|
722
|
+
project = ''
|
|
723
|
+
@projects.each_key do |project_key|
|
|
724
|
+
if @projects[project_key][:revision]
|
|
725
|
+
project = project_key
|
|
726
|
+
git_checkout_version(project_key, @projects[project_key][:revision])
|
|
727
|
+
end
|
|
728
|
+
end
|
|
729
|
+
deploy_id = get_deploy_id
|
|
730
|
+
|
|
731
|
+
@git_branch = ENV['DRONE_BRANCH']
|
|
732
|
+
@dns_record_identifier = deploy_id
|
|
733
|
+
hostname_pattern_priority = hostname_pattern_priority()
|
|
179
734
|
tags = [
|
|
180
735
|
{
|
|
181
|
-
key: "
|
|
182
|
-
value: @
|
|
183
|
-
},
|
|
184
|
-
{
|
|
185
|
-
key: "urania",
|
|
186
|
-
value: @projects["urania"][:name]
|
|
736
|
+
key: "qainit",
|
|
737
|
+
value: @git_branch
|
|
187
738
|
},
|
|
188
739
|
{
|
|
189
|
-
key:
|
|
190
|
-
value: @projects[
|
|
740
|
+
key: project,
|
|
741
|
+
value: @projects[project][:name]
|
|
191
742
|
},
|
|
192
743
|
{
|
|
193
|
-
key: "
|
|
194
|
-
value:
|
|
195
|
-
},
|
|
196
|
-
{
|
|
197
|
-
key: "bburago",
|
|
198
|
-
value: @projects["bburago"][:name]
|
|
199
|
-
},
|
|
200
|
-
{
|
|
201
|
-
key: "hal9000",
|
|
202
|
-
value: @projects["hal9000"][:name]
|
|
203
|
-
},
|
|
204
|
-
{
|
|
205
|
-
key: "fidaty",
|
|
206
|
-
value: @projects["fidaty"][:name]
|
|
744
|
+
key: "hostname_pattern_priority",
|
|
745
|
+
value: hostname_pattern_priority
|
|
207
746
|
}
|
|
208
747
|
]
|
|
209
748
|
|
|
210
749
|
cluster_stack_name = "ecs-cluster-qa-#{deploy_id}"
|
|
750
|
+
|
|
751
|
+
if stack_exists?(cluster_stack_name)
|
|
752
|
+
tags = get_stack_tags(cluster_stack_name)
|
|
753
|
+
hostname_pattern_priority = tags.detect do |tag|
|
|
754
|
+
tag.key == 'hostname_pattern_priority'
|
|
755
|
+
end.value
|
|
756
|
+
end
|
|
757
|
+
|
|
758
|
+
stack_name_alb = @base_stack_name_alb + deploy_id[0..5]
|
|
759
|
+
stack_name_alb_ws = @base_stack_name_alb_ws + deploy_id[0..5]
|
|
760
|
+
|
|
211
761
|
create_cluster_stack(cluster_stack_name, tags) unless stack_exists?(cluster_stack_name)
|
|
212
762
|
wait_for_stack_ready(cluster_stack_name) unless stack_ready?(cluster_stack_name)
|
|
213
763
|
|
|
764
|
+
create_alb_stack(stack_name_alb, "http", deploy_id, 'qa-minimal') unless stack_exists?(stack_name_alb)
|
|
765
|
+
create_alb_stack(stack_name_alb_ws, "websocket", deploy_id, 'qa-minimal') unless stack_exists?(stack_name_alb_ws)
|
|
766
|
+
|
|
214
767
|
resp = @cf.describe_stack_resource({stack_name: cluster_stack_name, logical_resource_id: 'ECSCluster'})
|
|
215
768
|
@ecs_cluster_name = resp.stack_resource_detail.physical_resource_id
|
|
216
769
|
|
|
217
770
|
asg_stack_name = "ecs-asg-allinone-qa-#{deploy_id}"
|
|
218
771
|
create_asg_stack(asg_stack_name, tags) unless stack_exists?(asg_stack_name)
|
|
219
772
|
|
|
220
|
-
|
|
221
|
-
|
|
773
|
+
deploy_id = get_deploy_id
|
|
774
|
+
create_pyxis_artifact(@projects["pyxis-npm"][:revision], deploy_id)
|
|
775
|
+
create_prima_artifact(@projects["prima"][:revision], @projects["prima"][:name], deploy_id, true) unless artifact_exists?('prima-artifacts-encrypted', "prima/#{@projects["prima"][:revision]}.tar.gz")
|
|
776
|
+
|
|
777
|
+
wait_for_stack_ready(stack_name_alb) unless stack_ready?(stack_name_alb)
|
|
778
|
+
wait_for_stack_ready(stack_name_alb_ws) unless stack_ready?(stack_name_alb_ws)
|
|
779
|
+
|
|
780
|
+
stack_name_route53 = "ecs-route53-qa-#{deploy_id}"
|
|
781
|
+
stack_body = IO.read('cloudformation/stacks/route53/minimal_qa.yml')
|
|
222
782
|
parameters = [
|
|
223
783
|
{
|
|
224
|
-
parameter_key: "
|
|
225
|
-
parameter_value:
|
|
784
|
+
parameter_key: "DnsRecordIdentifier",
|
|
785
|
+
parameter_value: @dns_record_identifier
|
|
226
786
|
},
|
|
227
787
|
{
|
|
228
|
-
parameter_key: "
|
|
229
|
-
parameter_value:
|
|
788
|
+
parameter_key: "PrimaElbHostname",
|
|
789
|
+
parameter_value: get_alb_host(stack_name_alb)
|
|
790
|
+
},
|
|
791
|
+
{
|
|
792
|
+
parameter_key: 'CrashElbHostname',
|
|
793
|
+
parameter_value: get_alb_host(stack_name_alb_ws)
|
|
230
794
|
}
|
|
231
795
|
]
|
|
232
|
-
create_stack(stack_name_db, stack_body, parameters, tags) unless stack_exists?(stack_name_db)
|
|
233
796
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
create_ermes_artifact(@projects["ermes"][:revision]) unless artifact_exists?('prima-artifacts', "microservices/ermes/#{@projects["ermes"][:revision]}-qa.tar.gz")
|
|
237
|
-
create_bburago_artifact(@projects["bburago"][:revision]) unless artifact_exists?('prima-artifacts', "microservices/bburago/#{@projects["bburago"][:revision]}-qa.tar.gz")
|
|
238
|
-
create_hal9000_artifact(@projects["hal9000"][:revision]) unless artifact_exists?('prima-artifacts', "microservices/hal9000/#{@projects["hal9000"][:revision]}-qa.tar.gz")
|
|
239
|
-
create_fidaty_artifact(@projects["fidaty"][:revision], deploy_id) unless artifact_exists?('prima-artifacts', "microservices/fidaty/#{@projects["fidaty"][:revision]}-#{deploy_id}-qa.tar.gz")
|
|
240
|
-
create_backoffice_artifact(@projects["backoffice"][:revision], deploy_id) unless artifact_exists?('prima-artifacts', "backoffice/#{@projects["backoffice"][:revision]}-#{deploy_id}.zip")
|
|
241
|
-
|
|
242
|
-
wait_for_stack_ready(stack_name_db) unless stack_ready?(stack_name_db)
|
|
243
|
-
import_dbs(ec2_ip_address(asg_stack_name)) unless stack_exists?("ecs-task-web-qa-#{deploy_id}")
|
|
797
|
+
create_stack(stack_name_route53, stack_body, parameters, tags, @cf_role) unless stack_exists?(stack_name_route53)
|
|
798
|
+
wait_for_stack_ready(stack_name_route53) unless stack_ready?(stack_name_route53)
|
|
244
799
|
|
|
245
800
|
stack_name_web = "ecs-task-web-qa-#{deploy_id}"
|
|
246
801
|
git_checkout_version('prima', @projects["prima"][:revision])
|
|
@@ -248,11 +803,11 @@ class Release
|
|
|
248
803
|
parameters = [
|
|
249
804
|
{
|
|
250
805
|
parameter_key: "Environment",
|
|
251
|
-
parameter_value: "qa"
|
|
806
|
+
parameter_value: "qa-minimal"
|
|
252
807
|
},
|
|
253
808
|
{
|
|
254
809
|
parameter_key: "ReleaseVersion",
|
|
255
|
-
parameter_value: "#{@projects["prima"][:revision]}
|
|
810
|
+
parameter_value: "#{@projects["prima"][:revision]}"
|
|
256
811
|
},
|
|
257
812
|
{
|
|
258
813
|
parameter_key: "TaskDesiredCount",
|
|
@@ -264,22 +819,255 @@ class Release
|
|
|
264
819
|
},
|
|
265
820
|
{
|
|
266
821
|
parameter_key: "ALBShortName",
|
|
267
|
-
parameter_value: "
|
|
822
|
+
parameter_value: "web-qa-#{deploy_id}"[0..27]
|
|
268
823
|
},
|
|
269
824
|
{
|
|
270
825
|
parameter_key: "WebQaBaseHostname",
|
|
271
826
|
parameter_value: "#{@dns_record_identifier}.qa.colaster.com"
|
|
827
|
+
},
|
|
828
|
+
{
|
|
829
|
+
parameter_key: "HostnamePattern",
|
|
830
|
+
parameter_value: "ww*-#{@dns_record_identifier}.qa.colaster.com"
|
|
831
|
+
},
|
|
832
|
+
{
|
|
833
|
+
parameter_key: "HostnamePatternPriority",
|
|
834
|
+
parameter_value: hostname_pattern_priority
|
|
835
|
+
},
|
|
836
|
+
{
|
|
837
|
+
parameter_key: "HostnamePatternAggregatorPriority",
|
|
838
|
+
parameter_value: (hostname_pattern_priority.to_i + 1).to_s
|
|
839
|
+
},
|
|
840
|
+
{
|
|
841
|
+
parameter_key: "EnvHash",
|
|
842
|
+
parameter_value: deploy_id
|
|
843
|
+
},
|
|
844
|
+
{
|
|
845
|
+
parameter_key: "AssangeHostname",
|
|
846
|
+
parameter_value: "assange-#{@dns_record_identifier}.qa.colaster.com"
|
|
847
|
+
},
|
|
848
|
+
{
|
|
849
|
+
parameter_key: "BackofficeHostname",
|
|
850
|
+
parameter_value: "backoffice-#{@dns_record_identifier}.qa.colaster.com"
|
|
851
|
+
},
|
|
852
|
+
{
|
|
853
|
+
parameter_key: "WebHostname",
|
|
854
|
+
parameter_value: "www-#{@dns_record_identifier}.qa.colaster.com"
|
|
272
855
|
}
|
|
273
856
|
]
|
|
274
857
|
if stack_exists?(stack_name_web)
|
|
275
|
-
|
|
858
|
+
cur_version = get_currently_deployed_version(stack_name_web)
|
|
859
|
+
update_stack(stack_name_web, stack_body, parameters, tags, @cf_role) unless cur_version.include?(@projects["prima"][:revision])
|
|
276
860
|
else
|
|
277
|
-
create_stack(stack_name_web, stack_body, parameters, tags)
|
|
861
|
+
create_stack(stack_name_web, stack_body, parameters, tags, @cf_role)
|
|
862
|
+
end
|
|
863
|
+
wait_for_stack_ready(stack_name_web) unless stack_ready?(stack_name_web)
|
|
864
|
+
update_service_defaults(stack_name_web)
|
|
865
|
+
prima_hostname = get_route53_hostname(stack_name_web)
|
|
866
|
+
|
|
867
|
+
projects_text = "
|
|
868
|
+
> Prima url: https://#{prima_hostname}
|
|
869
|
+
> SSH connection: ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no githubUsername@#{ec2_ip_address(asg_stack_name)}\n"
|
|
870
|
+
|
|
871
|
+
output projects_text.cyan
|
|
872
|
+
output "Deploy effettuato, everything is awesome!\n".green
|
|
873
|
+
if @qainit
|
|
874
|
+
qainit_write_output(projects_text, 'Indirizzi scritti su ')
|
|
278
875
|
end
|
|
876
|
+
end
|
|
279
877
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
878
|
+
def deploy_feature!
|
|
879
|
+
`git pull && git submodule init && git submodule update`
|
|
880
|
+
@ami_id = get_ami_id("ecs-fleet-allinone-staging")
|
|
881
|
+
deploy_id = get_deploy_id
|
|
882
|
+
stack_name_alb = 'ecs-alb-http-public-qa-' + deploy_id[0..5]
|
|
883
|
+
stack_name_alb_ws = 'ecs-alb-ws-public-qa-' + deploy_id[0..5]
|
|
884
|
+
unless @qainit
|
|
885
|
+
@projects.each_key do |project_key|
|
|
886
|
+
if @projects[project_key][:revision]
|
|
887
|
+
git_checkout_version(project_key, @projects[project_key][:revision])
|
|
888
|
+
end
|
|
889
|
+
end
|
|
890
|
+
end
|
|
891
|
+
@dns_record_identifier = deploy_id
|
|
892
|
+
@git_branch = ENV['DRONE_BRANCH']
|
|
893
|
+
hostname_pattern_priority = hostname_pattern_priority()
|
|
894
|
+
tags = [
|
|
895
|
+
{
|
|
896
|
+
key: "qainit",
|
|
897
|
+
value: @git_branch
|
|
898
|
+
},
|
|
899
|
+
{
|
|
900
|
+
key: "hostname_pattern_priority",
|
|
901
|
+
value: hostname_pattern_priority
|
|
902
|
+
}
|
|
903
|
+
]
|
|
904
|
+
@projects.each do |key, value|
|
|
905
|
+
case key.to_s
|
|
906
|
+
when 'crash'
|
|
907
|
+
tags << { key: 'crash', value: @projects['crash'][:name] } if deploy_crash?
|
|
908
|
+
when 'starsky', 'hutch'
|
|
909
|
+
tags << { key: key.to_s, value: @projects[key.to_s][:name] } if deploy_starsky_hutch?
|
|
910
|
+
else
|
|
911
|
+
tags << { key: key, value: value[:name] }
|
|
912
|
+
end
|
|
913
|
+
end
|
|
914
|
+
|
|
915
|
+
cluster_stack_name = "ecs-cluster-qa-#{deploy_id}"
|
|
916
|
+
|
|
917
|
+
if stack_exists?(cluster_stack_name)
|
|
918
|
+
tags = get_stack_tags(cluster_stack_name)
|
|
919
|
+
hostname_pattern_priority = tags.detect do |tag|
|
|
920
|
+
tag.key == 'hostname_pattern_priority'
|
|
921
|
+
end.value
|
|
922
|
+
end
|
|
923
|
+
|
|
924
|
+
create_cluster_stack(cluster_stack_name, tags) unless stack_exists?(cluster_stack_name)
|
|
925
|
+
wait_for_stack_ready(cluster_stack_name) unless stack_ready?(cluster_stack_name)
|
|
926
|
+
|
|
927
|
+
create_alb_stack(stack_name_alb, "http", deploy_id) unless stack_exists?(stack_name_alb)
|
|
928
|
+
create_alb_stack(stack_name_alb_ws, "websocket", deploy_id) unless stack_exists?(stack_name_alb_ws)
|
|
929
|
+
|
|
930
|
+
resp = @cf.describe_stack_resource({stack_name: cluster_stack_name, logical_resource_id: 'ECSCluster'})
|
|
931
|
+
@ecs_cluster_name = resp.stack_resource_detail.physical_resource_id
|
|
932
|
+
|
|
933
|
+
asg_stack_name = "ecs-asg-allinone-qa-#{deploy_id}"
|
|
934
|
+
create_asg_stack(asg_stack_name, tags) unless stack_exists?(asg_stack_name)
|
|
935
|
+
|
|
936
|
+
stack_name_db = "ecs-task-db-qa-#{deploy_id}"
|
|
937
|
+
stack_body = IO.read('cloudformation/stacks/task/db.yml')
|
|
938
|
+
parameters = [
|
|
939
|
+
{
|
|
940
|
+
parameter_key: "Environment",
|
|
941
|
+
parameter_value: "qa"
|
|
942
|
+
},
|
|
943
|
+
{
|
|
944
|
+
parameter_key: "ECSClusterName",
|
|
945
|
+
parameter_value: @ecs_cluster_name
|
|
946
|
+
}
|
|
947
|
+
]
|
|
948
|
+
create_stack(stack_name_db, stack_body, parameters, tags, @cf_role) unless stack_exists?(stack_name_db) # creazione asincrona stack dei db (~4 min)
|
|
949
|
+
|
|
950
|
+
output "check pyxis \n".yellow
|
|
951
|
+
|
|
952
|
+
create_pyxis_artifact(@projects["pyxis-npm"][:revision], deploy_id) unless @projects["pyxis-npm"].nil? # deve essere creato prima di quello di prima, per avere la versione
|
|
953
|
+
create_prima_artifact(@projects["prima"][:revision], @projects["prima"][:name], deploy_id) unless artifact_exists?('prima-artifacts-encrypted', "prima/#{@projects["prima"][:revision]}.tar.gz")
|
|
954
|
+
# l'artefatto di prima viene creato sempre (puntamenti all'ambiente compilati nel js) e richiede molto più di 4 minuti
|
|
955
|
+
wait_for_stack_ready(stack_name_db) unless stack_ready?(stack_name_db) # dovrebbe essere istantaneo
|
|
956
|
+
db_task = ''
|
|
957
|
+
db_task = import_dbs(ec2_ip_address(asg_stack_name)) unless stack_exists?("ecs-route53-qa-#{deploy_id}") # import asincrono dei dati
|
|
958
|
+
|
|
959
|
+
create_crash_artifact(@projects['crash'][:revision], deploy_id) unless !deploy_crash? || artifact_exists?('prima-artifacts-encrypted', "microservices/crash/#{@projects['crash'][:revision]}-qa.tar.gz")
|
|
960
|
+
create_urania_artifact(@projects["urania"][:revision]) unless artifact_exists?('prima-artifacts-encrypted', "microservices/urania/#{@projects["urania"][:revision]}-qa.tar.gz")
|
|
961
|
+
create_roger_artifact(@projects["roger"][:revision]) unless artifact_exists?('prima-artifacts-encrypted', "microservices/roger/#{@projects["roger"][:revision]}-qa.tar.gz")
|
|
962
|
+
create_ermes_artifact(@projects["ermes"][:revision]) unless artifact_exists?('prima-artifacts-encrypted', "microservices/ermes/#{@projects["ermes"][:revision]}-qa.tar.gz")
|
|
963
|
+
create_bburago_artifact(@projects["bburago"][:revision]) unless artifact_exists?('prima-artifacts-encrypted', "microservices/bburago/#{@projects["bburago"][:revision]}-qa.tar.gz")
|
|
964
|
+
create_hal9000_artifact(@projects["hal9000"][:revision]) unless artifact_exists?('prima-artifacts-encrypted', "microservices/hal9000/#{@projects["hal9000"][:revision]}-qa.tar.gz")
|
|
965
|
+
create_rachele_artifact(@projects["rachele"][:revision]) unless artifact_exists?('prima-artifacts-encrypted', "microservices/rachele/#{@projects["rachele"][:revision]}-qa.tar.gz")
|
|
966
|
+
create_fidaty_artifact(@projects["fidaty"][:revision]) unless artifact_exists?('prima-artifacts-encrypted', "microservices/fidaty/#{@projects["fidaty"][:revision]}-qa.tar.gz")
|
|
967
|
+
create_peano_artifact(@projects["peano"][:revision]) unless artifact_exists?('prima-artifacts-encrypted', "microservices/peano/#{@projects["peano"][:revision]}-qa.tar.gz")
|
|
968
|
+
create_rogoreport_artifact(@projects["rogoreport"][:revision]) unless artifact_exists?('prima-artifacts-encrypted', "microservices/rogoreport/rogoreport-#{@projects["rogoreport"][:revision]}-qa.tar.gz")
|
|
969
|
+
create_assange_artifact(@projects["assange"][:revision]) unless artifact_exists?('prima-artifacts-encrypted', "microservices/assange/#{@projects["assange"][:revision]}-qa.tar.gz")
|
|
970
|
+
create_borat_artifact(@projects["borat"][:revision]) unless artifact_exists?('prima-artifacts-encrypted', "microservices/borat/#{@projects["borat"][:revision]}-qa.tar.gz")
|
|
971
|
+
create_activia_artifact(@projects["activia"][:revision]) unless artifact_exists?('prima-artifacts-encrypted', "microservices/activia/#{@projects["activia"][:revision]}-qa.tar.gz")
|
|
972
|
+
create_leftorium_artifact(@projects["leftorium"][:revision]) unless artifact_exists?('prima-artifacts-encrypted', "microservices/leftorium/#{@projects["leftorium"][:revision]}-qa.tar.gz")
|
|
973
|
+
create_skynet_artifact(@projects["skynet"][:revision]) unless artifact_exists?('prima-artifacts-encrypted', "microservices/skynet/#{@projects["skynet"][:revision]}-qa.tar.gz")
|
|
974
|
+
create_starsky_artifact(@projects["starsky"][:revision]) unless !deploy_starsky_hutch? || artifact_exists?('prima-artifacts-encrypted', "microservices/starsky/#{@projects["starsky"][:revision]}-qa.tar.gz")
|
|
975
|
+
create_hutch_artifact(@projects["hutch"][:revision]) unless !deploy_starsky_hutch? || artifact_exists?('prima-artifacts-encrypted', "microservices/hutch/#{@projects["hutch"][:revision]}-qa.tar.gz")
|
|
976
|
+
|
|
977
|
+
wait_for_db_import(db_task) unless stack_exists?("ecs-route53-qa-#{deploy_id}") # dovrebbe essere istantaneo
|
|
978
|
+
|
|
979
|
+
import_redis_crash(ec2_ip_address(asg_stack_name)) if deploy_crash? && !stack_exists?("ecs-task-web-qa-#{deploy_id}")
|
|
980
|
+
|
|
981
|
+
wait_for_stack_ready(stack_name_alb) unless stack_ready?(stack_name_alb)
|
|
982
|
+
wait_for_stack_ready(stack_name_alb_ws) unless stack_ready?(stack_name_alb_ws)
|
|
983
|
+
|
|
984
|
+
stack_name_route53 = "ecs-route53-qa-#{deploy_id}"
|
|
985
|
+
stack_body = IO.read('cloudformation/stacks/route53/qa.yml')
|
|
986
|
+
parameters = [
|
|
987
|
+
{
|
|
988
|
+
parameter_key: "DnsRecordIdentifier",
|
|
989
|
+
parameter_value: @dns_record_identifier
|
|
990
|
+
},
|
|
991
|
+
{
|
|
992
|
+
parameter_key: "PrimaElbHostname",
|
|
993
|
+
parameter_value: get_alb_host(stack_name_alb)
|
|
994
|
+
},
|
|
995
|
+
{
|
|
996
|
+
parameter_key: "UraniaIp",
|
|
997
|
+
parameter_value: ec2_ip_address(asg_stack_name)
|
|
998
|
+
},
|
|
999
|
+
{
|
|
1000
|
+
parameter_key: "BburagoIp",
|
|
1001
|
+
parameter_value: ec2_ip_address(asg_stack_name)
|
|
1002
|
+
},
|
|
1003
|
+
{
|
|
1004
|
+
parameter_key: "Hal9000Ip",
|
|
1005
|
+
parameter_value: ec2_ip_address(asg_stack_name)
|
|
1006
|
+
},
|
|
1007
|
+
{
|
|
1008
|
+
parameter_key: "FidatyIp",
|
|
1009
|
+
parameter_value: ec2_ip_address(asg_stack_name)
|
|
1010
|
+
},
|
|
1011
|
+
{
|
|
1012
|
+
parameter_key: "PeanoIp",
|
|
1013
|
+
parameter_value: ec2_ip_address(asg_stack_name)
|
|
1014
|
+
},
|
|
1015
|
+
{
|
|
1016
|
+
parameter_key: "ErmesIp",
|
|
1017
|
+
parameter_value: ec2_ip_address(asg_stack_name)
|
|
1018
|
+
},
|
|
1019
|
+
{
|
|
1020
|
+
parameter_key: "ActiviaIp",
|
|
1021
|
+
parameter_value: ec2_ip_address(asg_stack_name)
|
|
1022
|
+
},
|
|
1023
|
+
{
|
|
1024
|
+
parameter_key: "SkynetIp",
|
|
1025
|
+
parameter_value: ec2_ip_address(asg_stack_name)
|
|
1026
|
+
},
|
|
1027
|
+
{
|
|
1028
|
+
parameter_key: "RogerIp",
|
|
1029
|
+
parameter_value: ec2_ip_address(asg_stack_name)
|
|
1030
|
+
},
|
|
1031
|
+
{
|
|
1032
|
+
parameter_key: "LeftoriumIp",
|
|
1033
|
+
parameter_value: ec2_ip_address(asg_stack_name)
|
|
1034
|
+
},
|
|
1035
|
+
{
|
|
1036
|
+
parameter_key: "RacheleIp",
|
|
1037
|
+
parameter_value: ec2_ip_address(asg_stack_name)
|
|
1038
|
+
},
|
|
1039
|
+
{
|
|
1040
|
+
parameter_key: "RedisIp",
|
|
1041
|
+
parameter_value: ec2_ip_address(asg_stack_name)
|
|
1042
|
+
},
|
|
1043
|
+
{
|
|
1044
|
+
parameter_key: "AssangeElbHostname",
|
|
1045
|
+
parameter_value: get_alb_host(stack_name_alb)
|
|
1046
|
+
},
|
|
1047
|
+
{
|
|
1048
|
+
parameter_key: "BoratElbHostname",
|
|
1049
|
+
parameter_value: get_alb_host(stack_name_alb_ws)
|
|
1050
|
+
},
|
|
1051
|
+
{
|
|
1052
|
+
parameter_key: 'CrashElbHostname',
|
|
1053
|
+
parameter_value: get_alb_host(stack_name_alb_ws)
|
|
1054
|
+
},
|
|
1055
|
+
{
|
|
1056
|
+
parameter_key: 'StarskyElbHostname',
|
|
1057
|
+
parameter_value: get_alb_host(stack_name_alb)
|
|
1058
|
+
},
|
|
1059
|
+
{
|
|
1060
|
+
parameter_key: 'HutchElbHostname',
|
|
1061
|
+
parameter_value: get_alb_host(stack_name_alb)
|
|
1062
|
+
}
|
|
1063
|
+
]
|
|
1064
|
+
|
|
1065
|
+
create_stack(stack_name_route53, stack_body, parameters, tags, @cf_role) unless stack_exists?(stack_name_route53)
|
|
1066
|
+
wait_for_stack_ready(stack_name_route53) unless stack_ready?(stack_name_route53)
|
|
1067
|
+
|
|
1068
|
+
stack_name_skynet = "ecs-task-skynet-qa-#{deploy_id}"
|
|
1069
|
+
git_checkout_version('skynet', @projects["skynet"][:revision])
|
|
1070
|
+
stack_body = File.read('projects/skynet/deploy/task.yml')
|
|
283
1071
|
parameters = [
|
|
284
1072
|
{
|
|
285
1073
|
parameter_key: "Environment",
|
|
@@ -287,22 +1075,35 @@ class Release
|
|
|
287
1075
|
},
|
|
288
1076
|
{
|
|
289
1077
|
parameter_key: "ReleaseVersion",
|
|
290
|
-
parameter_value:
|
|
1078
|
+
parameter_value: @projects["skynet"][:revision]
|
|
1079
|
+
},
|
|
1080
|
+
{
|
|
1081
|
+
parameter_key: "TaskDesiredCount",
|
|
1082
|
+
parameter_value: "1"
|
|
291
1083
|
},
|
|
292
1084
|
{
|
|
293
1085
|
parameter_key: "ECSClusterName",
|
|
294
1086
|
parameter_value: @ecs_cluster_name
|
|
1087
|
+
},
|
|
1088
|
+
{
|
|
1089
|
+
parameter_key: "HostnamePattern",
|
|
1090
|
+
parameter_value: "skynet-#{@dns_record_identifier}.qa.colaster.com"
|
|
1091
|
+
},
|
|
1092
|
+
{
|
|
1093
|
+
parameter_key: "HostnamePatternPriority",
|
|
1094
|
+
parameter_value: hostname_pattern_priority
|
|
295
1095
|
}
|
|
296
1096
|
]
|
|
297
|
-
if stack_exists?(
|
|
298
|
-
|
|
1097
|
+
if stack_exists?(stack_name_skynet)
|
|
1098
|
+
cur_version = get_currently_deployed_version(stack_name_skynet)
|
|
1099
|
+
update_stack(stack_name_skynet, stack_body, parameters, tags, @cf_role) unless cur_version.include?(@projects["skynet"][:revision])
|
|
299
1100
|
else
|
|
300
|
-
create_stack(
|
|
1101
|
+
create_stack(stack_name_skynet, stack_body, parameters, tags, @cf_role)
|
|
301
1102
|
end
|
|
302
1103
|
|
|
303
1104
|
stack_name_urania = "ecs-task-urania-qa-#{deploy_id}"
|
|
304
1105
|
git_checkout_version('urania', @projects["urania"][:revision])
|
|
305
|
-
stack_body =
|
|
1106
|
+
stack_body = File.read('projects/urania/deploy/task.yml')
|
|
306
1107
|
parameters = [
|
|
307
1108
|
{
|
|
308
1109
|
parameter_key: "Environment",
|
|
@@ -321,19 +1122,24 @@ class Release
|
|
|
321
1122
|
parameter_value: @ecs_cluster_name
|
|
322
1123
|
},
|
|
323
1124
|
{
|
|
324
|
-
parameter_key: "
|
|
325
|
-
parameter_value: "
|
|
1125
|
+
parameter_key: "HostnamePattern",
|
|
1126
|
+
parameter_value: "urania-#{@dns_record_identifier}.qa.colaster.com"
|
|
1127
|
+
},
|
|
1128
|
+
{
|
|
1129
|
+
parameter_key: "HostnamePatternPriority",
|
|
1130
|
+
parameter_value: hostname_pattern_priority
|
|
326
1131
|
}
|
|
327
1132
|
]
|
|
328
1133
|
if stack_exists?(stack_name_urania)
|
|
329
|
-
|
|
1134
|
+
cur_version = get_currently_deployed_version(stack_name_urania)
|
|
1135
|
+
update_stack(stack_name_urania, stack_body, parameters, tags, @cf_role) unless cur_version.include?(@projects["urania"][:revision])
|
|
330
1136
|
else
|
|
331
|
-
create_stack(stack_name_urania, stack_body, parameters, tags)
|
|
1137
|
+
create_stack(stack_name_urania, stack_body, parameters, tags, @cf_role)
|
|
332
1138
|
end
|
|
333
1139
|
|
|
334
1140
|
stack_name_ermes = "ecs-task-ermes-qa-#{deploy_id}"
|
|
335
1141
|
git_checkout_version('ermes', @projects["ermes"][:revision])
|
|
336
|
-
stack_body =
|
|
1142
|
+
stack_body = File.read('projects/ermes/deploy/task.yml')
|
|
337
1143
|
parameters = [
|
|
338
1144
|
{
|
|
339
1145
|
parameter_key: "Environment",
|
|
@@ -341,84 +1147,637 @@ class Release
|
|
|
341
1147
|
},
|
|
342
1148
|
{
|
|
343
1149
|
parameter_key: "ReleaseVersion",
|
|
344
|
-
parameter_value: @projects[
|
|
1150
|
+
parameter_value: "#{@projects['ermes'][:revision]}"
|
|
1151
|
+
},
|
|
1152
|
+
{
|
|
1153
|
+
parameter_key: "TaskDesiredCount",
|
|
1154
|
+
parameter_value: "1"
|
|
345
1155
|
},
|
|
346
1156
|
{
|
|
347
1157
|
parameter_key: "ECSClusterName",
|
|
348
1158
|
parameter_value: @ecs_cluster_name
|
|
1159
|
+
},
|
|
1160
|
+
{
|
|
1161
|
+
parameter_key: "HostnamePattern",
|
|
1162
|
+
parameter_value: "ermes-#{@dns_record_identifier}.qa.colaster.com"
|
|
1163
|
+
},
|
|
1164
|
+
{
|
|
1165
|
+
parameter_key: "HostnamePatternPriority",
|
|
1166
|
+
parameter_value: hostname_pattern_priority
|
|
1167
|
+
},
|
|
1168
|
+
{
|
|
1169
|
+
parameter_key: "WebHost",
|
|
1170
|
+
parameter_value: get_route53_hostname('ecs-task-web-qa-notneeded')
|
|
1171
|
+
},
|
|
1172
|
+
{
|
|
1173
|
+
parameter_key: "PeanoHost",
|
|
1174
|
+
parameter_value: get_route53_hostname('ecs-task-peano-qa-notneeded')
|
|
349
1175
|
}
|
|
350
1176
|
]
|
|
351
1177
|
if stack_exists?(stack_name_ermes)
|
|
352
|
-
|
|
1178
|
+
cur_version = get_currently_deployed_version(stack_name_ermes)
|
|
1179
|
+
update_stack(stack_name_ermes, stack_body, parameters, tags, @cf_role) unless cur_version.include?(@projects["ermes"][:revision])
|
|
353
1180
|
else
|
|
354
|
-
create_stack(stack_name_ermes, stack_body, parameters, tags)
|
|
1181
|
+
create_stack(stack_name_ermes, stack_body, parameters, tags, @cf_role)
|
|
355
1182
|
end
|
|
356
1183
|
|
|
357
1184
|
stack_name_bburago = "ecs-task-bburago-qa-#{deploy_id}"
|
|
358
1185
|
git_checkout_version('bburago', @projects["bburago"][:revision])
|
|
359
|
-
stack_body =
|
|
1186
|
+
stack_body = File.read('projects/bburago/deploy/task.yml')
|
|
1187
|
+
parameters = [
|
|
1188
|
+
{
|
|
1189
|
+
parameter_key: "Environment",
|
|
1190
|
+
parameter_value: "qa"
|
|
1191
|
+
},
|
|
1192
|
+
{
|
|
1193
|
+
parameter_key: "ReleaseVersion",
|
|
1194
|
+
parameter_value: @projects["bburago"][:revision]
|
|
1195
|
+
},
|
|
1196
|
+
{
|
|
1197
|
+
parameter_key: "ECSClusterName",
|
|
1198
|
+
parameter_value: @ecs_cluster_name
|
|
1199
|
+
},
|
|
1200
|
+
{
|
|
1201
|
+
parameter_key: "TaskDesiredCount",
|
|
1202
|
+
parameter_value: "1"
|
|
1203
|
+
},
|
|
1204
|
+
{
|
|
1205
|
+
parameter_key: "HostnamePattern",
|
|
1206
|
+
parameter_value: "bburago-#{@dns_record_identifier}.qa.colaster.com"
|
|
1207
|
+
},
|
|
1208
|
+
{
|
|
1209
|
+
parameter_key: "HostnamePatternPriority",
|
|
1210
|
+
parameter_value: hostname_pattern_priority
|
|
1211
|
+
}
|
|
1212
|
+
]
|
|
1213
|
+
if stack_exists?(stack_name_bburago)
|
|
1214
|
+
cur_version = get_currently_deployed_version(stack_name_bburago)
|
|
1215
|
+
update_stack(stack_name_bburago, stack_body, parameters, tags, @cf_role) unless cur_version.include?(@projects["bburago"][:revision])
|
|
1216
|
+
else
|
|
1217
|
+
create_stack(stack_name_bburago, stack_body, parameters, tags, @cf_role)
|
|
1218
|
+
end
|
|
1219
|
+
|
|
1220
|
+
stack_name_hal9000 = "ecs-task-hal9000-qa-#{deploy_id}"
|
|
1221
|
+
git_checkout_version('hal9000', @projects["hal9000"][:revision])
|
|
1222
|
+
stack_body = File.read('projects/hal9000/deploy/task.yml')
|
|
1223
|
+
parameters = [
|
|
1224
|
+
{
|
|
1225
|
+
parameter_key: "Environment",
|
|
1226
|
+
parameter_value: "qa"
|
|
1227
|
+
},
|
|
1228
|
+
{
|
|
1229
|
+
parameter_key: "ReleaseVersion",
|
|
1230
|
+
parameter_value: @projects["hal9000"][:revision]
|
|
1231
|
+
},
|
|
1232
|
+
{
|
|
1233
|
+
parameter_key: "ECSClusterName",
|
|
1234
|
+
parameter_value: @ecs_cluster_name
|
|
1235
|
+
},
|
|
1236
|
+
{
|
|
1237
|
+
parameter_key: "TaskDesiredCount",
|
|
1238
|
+
parameter_value: "1"
|
|
1239
|
+
},
|
|
1240
|
+
{
|
|
1241
|
+
parameter_key: "HostnamePattern",
|
|
1242
|
+
parameter_value: "hal9000-#{@dns_record_identifier}.qa.colaster.com"
|
|
1243
|
+
},
|
|
1244
|
+
{
|
|
1245
|
+
parameter_key: "HostnamePatternPriority",
|
|
1246
|
+
parameter_value: hostname_pattern_priority
|
|
1247
|
+
}
|
|
1248
|
+
]
|
|
1249
|
+
if stack_exists?(stack_name_hal9000)
|
|
1250
|
+
cur_version = get_currently_deployed_version(stack_name_hal9000)
|
|
1251
|
+
update_stack(stack_name_hal9000, stack_body, parameters, tags, @cf_role) unless cur_version.include?(@projects["hal9000"][:revision])
|
|
1252
|
+
else
|
|
1253
|
+
create_stack(stack_name_hal9000, stack_body, parameters, tags, @cf_role)
|
|
1254
|
+
end
|
|
1255
|
+
|
|
1256
|
+
stack_name_fidaty = "ecs-task-fidaty-qa-#{deploy_id}"
|
|
1257
|
+
git_checkout_version('fidaty', @projects["fidaty"][:revision])
|
|
1258
|
+
stack_body = File.read('projects/fidaty/deploy/task.yml')
|
|
1259
|
+
parameters = [
|
|
1260
|
+
{
|
|
1261
|
+
parameter_key: "Environment",
|
|
1262
|
+
parameter_value: "qa"
|
|
1263
|
+
},
|
|
1264
|
+
{
|
|
1265
|
+
parameter_key: "ReleaseVersion",
|
|
1266
|
+
parameter_value: "#{@projects["fidaty"][:revision]}"
|
|
1267
|
+
},
|
|
1268
|
+
{
|
|
1269
|
+
parameter_key: "ECSClusterName",
|
|
1270
|
+
parameter_value: @ecs_cluster_name
|
|
1271
|
+
},
|
|
1272
|
+
{
|
|
1273
|
+
parameter_key: "TaskDesiredCount",
|
|
1274
|
+
parameter_value: "1"
|
|
1275
|
+
},
|
|
1276
|
+
{
|
|
1277
|
+
parameter_key: "HostnamePattern",
|
|
1278
|
+
parameter_value: "fidaty-#{@dns_record_identifier}.qa.colaster.com"
|
|
1279
|
+
},
|
|
1280
|
+
{
|
|
1281
|
+
parameter_key: "HostnamePatternPriority",
|
|
1282
|
+
parameter_value: hostname_pattern_priority
|
|
1283
|
+
},
|
|
1284
|
+
{
|
|
1285
|
+
parameter_key: "PeanoHost",
|
|
1286
|
+
parameter_value: get_route53_hostname("ecs-task-peano-qa-notneeded")
|
|
1287
|
+
}
|
|
1288
|
+
]
|
|
1289
|
+
if stack_exists?(stack_name_fidaty)
|
|
1290
|
+
cur_version = get_currently_deployed_version(stack_name_fidaty)
|
|
1291
|
+
update_stack(stack_name_fidaty, stack_body, parameters, tags, @cf_role) unless cur_version.include?(@projects["fidaty"][:revision])
|
|
1292
|
+
else
|
|
1293
|
+
create_stack(stack_name_fidaty, stack_body, parameters, tags, @cf_role)
|
|
1294
|
+
end
|
|
1295
|
+
|
|
1296
|
+
stack_name_peano = "ecs-task-peano-qa-#{deploy_id}"
|
|
1297
|
+
git_checkout_version('peano', @projects["peano"][:revision])
|
|
1298
|
+
stack_body = File.read('projects/peano/deploy/task.yml')
|
|
1299
|
+
parameters = [
|
|
1300
|
+
{
|
|
1301
|
+
parameter_key: "Environment",
|
|
1302
|
+
parameter_value: "qa"
|
|
1303
|
+
},
|
|
1304
|
+
{
|
|
1305
|
+
parameter_key: "ReleaseVersion",
|
|
1306
|
+
parameter_value: "#{@projects['peano'][:revision]}"
|
|
1307
|
+
},
|
|
1308
|
+
{
|
|
1309
|
+
parameter_key: "ECSClusterName",
|
|
1310
|
+
parameter_value: @ecs_cluster_name
|
|
1311
|
+
},
|
|
1312
|
+
{
|
|
1313
|
+
parameter_key: "TaskDesiredCount",
|
|
1314
|
+
parameter_value: "1"
|
|
1315
|
+
},
|
|
1316
|
+
{
|
|
1317
|
+
parameter_key: "HostnamePattern",
|
|
1318
|
+
parameter_value: "peano-#{@dns_record_identifier}.qa.colaster.com"
|
|
1319
|
+
},
|
|
1320
|
+
{
|
|
1321
|
+
parameter_key: "HostnamePatternPriority",
|
|
1322
|
+
parameter_value: hostname_pattern_priority
|
|
1323
|
+
},
|
|
1324
|
+
{
|
|
1325
|
+
parameter_key: "WebHost",
|
|
1326
|
+
parameter_value: "www-#{@dns_record_identifier}.qa.colaster.com"
|
|
1327
|
+
},
|
|
1328
|
+
{
|
|
1329
|
+
parameter_key: "AssangeHost",
|
|
1330
|
+
parameter_value: "assange-#{@dns_record_identifier}.qa.colaster.com"
|
|
1331
|
+
}
|
|
1332
|
+
]
|
|
1333
|
+
if stack_exists?(stack_name_peano)
|
|
1334
|
+
cur_version = get_currently_deployed_version(stack_name_peano)
|
|
1335
|
+
update_stack(stack_name_peano, stack_body, parameters, tags, @cf_role) unless cur_version.include?(@projects["peano"][:revision])
|
|
1336
|
+
else
|
|
1337
|
+
create_stack(stack_name_peano, stack_body, parameters, tags, @cf_role)
|
|
1338
|
+
end
|
|
1339
|
+
|
|
1340
|
+
stack_name_rogoreport = "ecs-task-rogoreport-qa-#{deploy_id}"
|
|
1341
|
+
git_checkout_version('rogoreport', @projects["rogoreport"][:revision])
|
|
1342
|
+
stack_body = IO.read('projects/rogoreport/deploy/task.yml')
|
|
1343
|
+
parameters = [
|
|
1344
|
+
{
|
|
1345
|
+
parameter_key: "Environment",
|
|
1346
|
+
parameter_value: "qa"
|
|
1347
|
+
},
|
|
1348
|
+
{
|
|
1349
|
+
parameter_key: "ReleaseVersion",
|
|
1350
|
+
parameter_value: "#{@projects["rogoreport"][:revision]}"
|
|
1351
|
+
},
|
|
1352
|
+
{
|
|
1353
|
+
parameter_key: "ReleaseName",
|
|
1354
|
+
parameter_value: "rogoreport"
|
|
1355
|
+
},
|
|
1356
|
+
{
|
|
1357
|
+
parameter_key: "ECSClusterName",
|
|
1358
|
+
parameter_value: @ecs_cluster_name
|
|
1359
|
+
}
|
|
1360
|
+
]
|
|
1361
|
+
if stack_exists?(stack_name_rogoreport)
|
|
1362
|
+
cur_version = get_currently_deployed_version(stack_name_rogoreport)
|
|
1363
|
+
update_stack(stack_name_rogoreport, stack_body, parameters, tags, @cf_role) unless cur_version.include?(@projects["rogoreport"][:revision])
|
|
1364
|
+
else
|
|
1365
|
+
create_stack(stack_name_rogoreport, stack_body, parameters, tags, @cf_role)
|
|
1366
|
+
end
|
|
1367
|
+
|
|
1368
|
+
stack_name_assange = "ecs-task-assange-qa-#{deploy_id}"
|
|
1369
|
+
git_checkout_version('assange', @projects["assange"][:revision])
|
|
1370
|
+
stack_body = IO.read('projects/assange/deploy/task.yml')
|
|
1371
|
+
parameters = [
|
|
1372
|
+
{
|
|
1373
|
+
parameter_key: "Environment",
|
|
1374
|
+
parameter_value: "qa"
|
|
1375
|
+
},
|
|
1376
|
+
{
|
|
1377
|
+
parameter_key: "ReleaseVersion",
|
|
1378
|
+
parameter_value: "#{@projects["assange"][:revision]}"
|
|
1379
|
+
},
|
|
1380
|
+
{
|
|
1381
|
+
parameter_key: "ECSClusterName",
|
|
1382
|
+
parameter_value: @ecs_cluster_name
|
|
1383
|
+
},
|
|
1384
|
+
{
|
|
1385
|
+
parameter_key: "TaskDesiredCount",
|
|
1386
|
+
parameter_value: "1"
|
|
1387
|
+
},
|
|
1388
|
+
{
|
|
1389
|
+
parameter_key: "ALBShortName",
|
|
1390
|
+
parameter_value: "assange-qa-#{deploy_id}"[0..27]
|
|
1391
|
+
},
|
|
1392
|
+
{
|
|
1393
|
+
parameter_key: "HostnamePattern",
|
|
1394
|
+
parameter_value: "assange-#{@dns_record_identifier}.qa.colaster.com"
|
|
1395
|
+
},
|
|
1396
|
+
{
|
|
1397
|
+
parameter_key: "HostnamePatternPriority",
|
|
1398
|
+
parameter_value: (hostname_pattern_priority.to_i + 20).to_s
|
|
1399
|
+
},
|
|
1400
|
+
{
|
|
1401
|
+
parameter_key: "EnvHash",
|
|
1402
|
+
parameter_value: deploy_id
|
|
1403
|
+
},
|
|
1404
|
+
{
|
|
1405
|
+
parameter_key: "WebHost",
|
|
1406
|
+
parameter_value: "www-#{@dns_record_identifier}.qa.colaster.com"
|
|
1407
|
+
},
|
|
1408
|
+
{
|
|
1409
|
+
parameter_key: "AssangeHost",
|
|
1410
|
+
parameter_value: "assange-#{@dns_record_identifier}.qa.colaster.com"
|
|
1411
|
+
}
|
|
1412
|
+
]
|
|
1413
|
+
if stack_exists?(stack_name_assange)
|
|
1414
|
+
cur_version = get_currently_deployed_version(stack_name_assange)
|
|
1415
|
+
update_stack(stack_name_assange, stack_body, parameters, tags, @cf_role) unless cur_version.include?(@projects["assange"][:revision])
|
|
1416
|
+
else
|
|
1417
|
+
create_stack(stack_name_assange, stack_body, parameters, tags, @cf_role)
|
|
1418
|
+
end
|
|
1419
|
+
|
|
1420
|
+
stack_name_leftorium = "ecs-task-leftorium-qa-#{deploy_id}"
|
|
1421
|
+
git_checkout_version('leftorium', @projects["leftorium"][:revision])
|
|
1422
|
+
stack_body = File.read('projects/leftorium/deploy/task.yml')
|
|
1423
|
+
parameters = [
|
|
1424
|
+
{
|
|
1425
|
+
parameter_key: "Environment",
|
|
1426
|
+
parameter_value: "qa"
|
|
1427
|
+
},
|
|
1428
|
+
{
|
|
1429
|
+
parameter_key: "ReleaseVersion",
|
|
1430
|
+
parameter_value: "#{@projects["leftorium"][:revision]}"
|
|
1431
|
+
},
|
|
1432
|
+
{
|
|
1433
|
+
parameter_key: "ECSClusterName",
|
|
1434
|
+
parameter_value: @ecs_cluster_name
|
|
1435
|
+
},
|
|
1436
|
+
{
|
|
1437
|
+
parameter_key: "TaskDesiredCount",
|
|
1438
|
+
parameter_value: "1"
|
|
1439
|
+
},
|
|
1440
|
+
{
|
|
1441
|
+
parameter_key: "HostnamePattern",
|
|
1442
|
+
parameter_value: "leftorium-#{@dns_record_identifier}.qa.colaster.com"
|
|
1443
|
+
},
|
|
1444
|
+
{
|
|
1445
|
+
parameter_key: "HostnamePatternPriority",
|
|
1446
|
+
parameter_value: hostname_pattern_priority
|
|
1447
|
+
}
|
|
1448
|
+
]
|
|
1449
|
+
if stack_exists?(stack_name_leftorium)
|
|
1450
|
+
cur_version = get_currently_deployed_version(stack_name_leftorium)
|
|
1451
|
+
update_stack(stack_name_leftorium, stack_body, parameters, tags, @cf_role) unless cur_version.include?(@projects["leftorium"][:revision])
|
|
1452
|
+
else
|
|
1453
|
+
create_stack(stack_name_leftorium, stack_body, parameters, tags, @cf_role)
|
|
1454
|
+
end
|
|
1455
|
+
|
|
1456
|
+
stack_name_rachele = "ecs-task-rachele-qa-#{deploy_id}"
|
|
1457
|
+
git_checkout_version('rachele', @projects["rachele"][:revision])
|
|
1458
|
+
stack_body = File.read('projects/rachele/deploy/task.yml')
|
|
1459
|
+
parameters = [
|
|
1460
|
+
{
|
|
1461
|
+
parameter_key: "Environment",
|
|
1462
|
+
parameter_value: "qa"
|
|
1463
|
+
},
|
|
1464
|
+
{
|
|
1465
|
+
parameter_key: "ReleaseVersion",
|
|
1466
|
+
parameter_value: "#{@projects["rachele"][:revision]}"
|
|
1467
|
+
},
|
|
1468
|
+
{
|
|
1469
|
+
parameter_key: "ECSClusterName",
|
|
1470
|
+
parameter_value: @ecs_cluster_name
|
|
1471
|
+
},
|
|
1472
|
+
{
|
|
1473
|
+
parameter_key: "TaskDesiredCount",
|
|
1474
|
+
parameter_value: "1"
|
|
1475
|
+
},
|
|
1476
|
+
{
|
|
1477
|
+
parameter_key: "WebHost",
|
|
1478
|
+
parameter_value: "www-#{@dns_record_identifier}.qa.colaster.com"
|
|
1479
|
+
},
|
|
1480
|
+
{
|
|
1481
|
+
parameter_key: "HostnamePattern",
|
|
1482
|
+
parameter_value: "rachele-#{@dns_record_identifier}.qa.colaster.com"
|
|
1483
|
+
},
|
|
1484
|
+
{
|
|
1485
|
+
parameter_key: "HostnamePatternPriority",
|
|
1486
|
+
parameter_value: hostname_pattern_priority
|
|
1487
|
+
}
|
|
1488
|
+
]
|
|
1489
|
+
if stack_exists?(stack_name_rachele)
|
|
1490
|
+
cur_version = get_currently_deployed_version(stack_name_rachele)
|
|
1491
|
+
update_stack(stack_name_rachele, stack_body, parameters, tags, @cf_role) unless cur_version.include?(@projects["rachele"][:revision])
|
|
1492
|
+
else
|
|
1493
|
+
create_stack(stack_name_rachele, stack_body, parameters, tags, @cf_role)
|
|
1494
|
+
end
|
|
1495
|
+
|
|
1496
|
+
stack_name_borat = "ecs-task-borat-qa-#{deploy_id}"
|
|
1497
|
+
git_checkout_version('borat', @projects["borat"][:revision])
|
|
1498
|
+
stack_body = IO.read('projects/borat/deploy/task.yml')
|
|
1499
|
+
parameters = [
|
|
1500
|
+
{
|
|
1501
|
+
parameter_key: "Environment",
|
|
1502
|
+
parameter_value: "qa"
|
|
1503
|
+
},
|
|
1504
|
+
{
|
|
1505
|
+
parameter_key: "ReleaseVersion",
|
|
1506
|
+
parameter_value: "#{@projects["borat"][:revision]}"
|
|
1507
|
+
},
|
|
1508
|
+
{
|
|
1509
|
+
parameter_key: "ECSClusterName",
|
|
1510
|
+
parameter_value: @ecs_cluster_name
|
|
1511
|
+
},
|
|
1512
|
+
{
|
|
1513
|
+
parameter_key: "TaskDesiredCount",
|
|
1514
|
+
parameter_value: "1"
|
|
1515
|
+
},
|
|
1516
|
+
{
|
|
1517
|
+
parameter_key: "ALBShortName",
|
|
1518
|
+
parameter_value: "borat-qa-#{deploy_id}"[0..27]
|
|
1519
|
+
},
|
|
1520
|
+
{
|
|
1521
|
+
parameter_key: "HostnamePattern",
|
|
1522
|
+
parameter_value: "backoffice-#{@dns_record_identifier}.qa.colaster.com"
|
|
1523
|
+
},
|
|
1524
|
+
{
|
|
1525
|
+
parameter_key: "HostnamePatternPriority",
|
|
1526
|
+
parameter_value: (hostname_pattern_priority.to_i + 30).to_s
|
|
1527
|
+
},
|
|
1528
|
+
{
|
|
1529
|
+
parameter_key: "EnvHash",
|
|
1530
|
+
parameter_value: deploy_id
|
|
1531
|
+
},
|
|
1532
|
+
{
|
|
1533
|
+
parameter_key: "WsEndpoint",
|
|
1534
|
+
parameter_value: "wss://backoffice-#{@dns_record_identifier}.qa.colaster.com/socket/websocket?vsn=1.0.0"
|
|
1535
|
+
},
|
|
1536
|
+
{
|
|
1537
|
+
parameter_key: "GraphqlEndpoint",
|
|
1538
|
+
parameter_value: "https://backoffice-#{@dns_record_identifier}.qa.colaster.com/graphql"
|
|
1539
|
+
},
|
|
1540
|
+
{
|
|
1541
|
+
parameter_key: "AuthEndpoint",
|
|
1542
|
+
parameter_value: "https://backoffice-#{@dns_record_identifier}.qa.colaster.com/auth"
|
|
1543
|
+
},
|
|
1544
|
+
{
|
|
1545
|
+
parameter_key: "FrontendEndpoint",
|
|
1546
|
+
parameter_value: "https://www-#{@dns_record_identifier}.qa.colaster.com/"
|
|
1547
|
+
}
|
|
1548
|
+
]
|
|
1549
|
+
if stack_exists?(stack_name_borat)
|
|
1550
|
+
cur_version = get_currently_deployed_version(stack_name_borat)
|
|
1551
|
+
update_stack(stack_name_borat, stack_body, parameters, tags, @cf_role) unless cur_version.include?(@projects["borat"][:revision])
|
|
1552
|
+
else
|
|
1553
|
+
create_stack(stack_name_borat, stack_body, parameters, tags, @cf_role)
|
|
1554
|
+
end
|
|
1555
|
+
|
|
1556
|
+
if deploy_crash?
|
|
1557
|
+
git_checkout_version('crash', @projects['crash'][:revision])
|
|
1558
|
+
stack_name_crash = "ecs-task-crash-qa-#{deploy_id}"
|
|
1559
|
+
stack_body = IO.read('projects/crash/deploy/task.yml')
|
|
1560
|
+
parameters = [
|
|
1561
|
+
{
|
|
1562
|
+
parameter_key: 'Environment',
|
|
1563
|
+
parameter_value: 'qa'
|
|
1564
|
+
},
|
|
1565
|
+
{
|
|
1566
|
+
parameter_key: 'ReleaseVersion',
|
|
1567
|
+
parameter_value: "#{@projects['crash'][:revision]}"
|
|
1568
|
+
},
|
|
1569
|
+
{
|
|
1570
|
+
parameter_key: 'TaskDesiredCount',
|
|
1571
|
+
parameter_value: '1'
|
|
1572
|
+
},
|
|
1573
|
+
{
|
|
1574
|
+
parameter_key: 'ECSClusterName',
|
|
1575
|
+
parameter_value: @ecs_cluster_name
|
|
1576
|
+
},
|
|
1577
|
+
{
|
|
1578
|
+
parameter_key: 'ALBShortName',
|
|
1579
|
+
parameter_value: "crash-qa-#{deploy_id}"[0..27]
|
|
1580
|
+
},
|
|
1581
|
+
{
|
|
1582
|
+
parameter_key: 'HostnamePattern',
|
|
1583
|
+
parameter_value: "crash-#{@dns_record_identifier}.qa.colaster.com"
|
|
1584
|
+
},
|
|
1585
|
+
{
|
|
1586
|
+
parameter_key: 'HostnamePatternPriority',
|
|
1587
|
+
parameter_value: (hostname_pattern_priority.to_i + 10).to_s
|
|
1588
|
+
},
|
|
1589
|
+
{
|
|
1590
|
+
parameter_key: "EnvHash",
|
|
1591
|
+
parameter_value: deploy_id
|
|
1592
|
+
},
|
|
1593
|
+
{
|
|
1594
|
+
parameter_key: "WsEndpoint",
|
|
1595
|
+
parameter_value: "wss://crash-#{@dns_record_identifier}.qa.colaster.com/socket/websocket?vsn=1.0.0"
|
|
1596
|
+
},
|
|
1597
|
+
{
|
|
1598
|
+
parameter_key: "GraphqlEndpoint",
|
|
1599
|
+
parameter_value: "https://crash-#{@dns_record_identifier}.qa.colaster.com/graphql"
|
|
1600
|
+
},
|
|
1601
|
+
{
|
|
1602
|
+
parameter_key: "AuthDomain",
|
|
1603
|
+
parameter_value: "https://www-#{@dns_record_identifier}.qa.colaster.com/"
|
|
1604
|
+
},
|
|
1605
|
+
]
|
|
1606
|
+
if stack_exists?(stack_name_crash)
|
|
1607
|
+
cur_version = get_currently_deployed_version(stack_name_crash)
|
|
1608
|
+
update_stack(stack_name_crash, stack_body, parameters, tags, @cf_role) unless cur_version.include?(@projects["crash"][:revision])
|
|
1609
|
+
else
|
|
1610
|
+
create_stack(stack_name_crash, stack_body, parameters, tags, @cf_role)
|
|
1611
|
+
end
|
|
1612
|
+
end
|
|
1613
|
+
|
|
1614
|
+
if deploy_starsky_hutch?
|
|
1615
|
+
stack_name_starsky = "ecs-task-starsky-qa-#{deploy_id}"
|
|
1616
|
+
git_checkout_version('starsky', @projects["starsky"][:revision])
|
|
1617
|
+
stack_body = IO.read('projects/starsky/deploy/task.yml')
|
|
1618
|
+
parameters = [
|
|
1619
|
+
{
|
|
1620
|
+
parameter_key: "Environment",
|
|
1621
|
+
parameter_value: "qa"
|
|
1622
|
+
},
|
|
1623
|
+
{
|
|
1624
|
+
parameter_key: "ReleaseVersion",
|
|
1625
|
+
parameter_value: "#{@projects["starsky"][:revision]}"
|
|
1626
|
+
},
|
|
1627
|
+
{
|
|
1628
|
+
parameter_key: "TaskDesiredCount",
|
|
1629
|
+
parameter_value: "1"
|
|
1630
|
+
},
|
|
1631
|
+
{
|
|
1632
|
+
parameter_key: "ECSClusterName",
|
|
1633
|
+
parameter_value: @ecs_cluster_name
|
|
1634
|
+
},
|
|
1635
|
+
{
|
|
1636
|
+
parameter_key: "ALBShortName",
|
|
1637
|
+
parameter_value: "starsky-qa-#{deploy_id}"[0..27]
|
|
1638
|
+
},
|
|
1639
|
+
{
|
|
1640
|
+
parameter_key: "EnvHash",
|
|
1641
|
+
parameter_value: deploy_id
|
|
1642
|
+
},
|
|
1643
|
+
{
|
|
1644
|
+
parameter_key: "HostnamePattern",
|
|
1645
|
+
parameter_value: "starsky-#{@dns_record_identifier}.qa.colaster.com"
|
|
1646
|
+
},
|
|
1647
|
+
{
|
|
1648
|
+
parameter_key: "HostnamePatternPriority",
|
|
1649
|
+
parameter_value: (hostname_pattern_priority.to_i + 74).to_s
|
|
1650
|
+
}
|
|
1651
|
+
]
|
|
1652
|
+
if stack_exists?(stack_name_starsky)
|
|
1653
|
+
cur_version = get_currently_deployed_version(stack_name_starsky)
|
|
1654
|
+
update_stack(stack_name_starsky, stack_body, parameters, tags, @cf_role) unless cur_version.include?(@projects["starsky"][:revision])
|
|
1655
|
+
else
|
|
1656
|
+
create_stack(stack_name_starsky, stack_body, parameters, tags, @cf_role)
|
|
1657
|
+
end
|
|
1658
|
+
end
|
|
1659
|
+
|
|
1660
|
+
stack_name_activia = "ecs-task-activia-qa-#{deploy_id}"
|
|
1661
|
+
git_checkout_version('activia', @projects["activia"][:revision])
|
|
1662
|
+
stack_body = File.read('projects/activia/deploy/task.yml')
|
|
1663
|
+
parameters = [
|
|
1664
|
+
{
|
|
1665
|
+
parameter_key: "Environment",
|
|
1666
|
+
parameter_value: "qa"
|
|
1667
|
+
},
|
|
1668
|
+
{
|
|
1669
|
+
parameter_key: "ReleaseVersion",
|
|
1670
|
+
parameter_value: "#{@projects["activia"][:revision]}"
|
|
1671
|
+
},
|
|
1672
|
+
{
|
|
1673
|
+
parameter_key: "ECSClusterName",
|
|
1674
|
+
parameter_value: @ecs_cluster_name
|
|
1675
|
+
},
|
|
1676
|
+
{
|
|
1677
|
+
parameter_key: "TaskDesiredCount",
|
|
1678
|
+
parameter_value: "1"
|
|
1679
|
+
},
|
|
1680
|
+
{
|
|
1681
|
+
parameter_key: "HostnamePattern",
|
|
1682
|
+
parameter_value: "activia-#{@dns_record_identifier}.qa.colaster.com"
|
|
1683
|
+
},
|
|
1684
|
+
{
|
|
1685
|
+
parameter_key: "HostnamePatternPriority",
|
|
1686
|
+
parameter_value: hostname_pattern_priority
|
|
1687
|
+
},
|
|
1688
|
+
{
|
|
1689
|
+
parameter_key: "WebHost",
|
|
1690
|
+
parameter_value: get_route53_hostname('ecs-task-web-qa-notneeded')
|
|
1691
|
+
},
|
|
1692
|
+
{
|
|
1693
|
+
parameter_key: "PeanoHost",
|
|
1694
|
+
parameter_value: get_route53_hostname('ecs-task-peano-qa-notneeded')
|
|
1695
|
+
}
|
|
1696
|
+
]
|
|
1697
|
+
if stack_exists?(stack_name_activia)
|
|
1698
|
+
cur_version = get_currently_deployed_version(stack_name_activia)
|
|
1699
|
+
update_stack(stack_name_activia, stack_body, parameters, tags, @cf_role) unless cur_version.include?(@projects["activia"][:revision])
|
|
1700
|
+
else
|
|
1701
|
+
create_stack(stack_name_activia, stack_body, parameters, tags, @cf_role)
|
|
1702
|
+
end
|
|
1703
|
+
|
|
1704
|
+
# Waiting for prima healtcheck dependencies
|
|
1705
|
+
wait_for_stack_ready(stack_name_skynet) unless stack_ready?(stack_name_skynet)
|
|
1706
|
+
wait_for_stack_ready(stack_name_urania) unless stack_ready?(stack_name_urania)
|
|
1707
|
+
wait_for_stack_ready(stack_name_bburago) unless stack_ready?(stack_name_bburago)
|
|
1708
|
+
wait_for_stack_ready(stack_name_hal9000) unless stack_ready?(stack_name_hal9000)
|
|
1709
|
+
wait_for_stack_ready(stack_name_assange) unless stack_ready?(stack_name_assange)
|
|
1710
|
+
wait_for_stack_ready(stack_name_fidaty) unless stack_ready?(stack_name_fidaty)
|
|
1711
|
+
wait_for_stack_ready(stack_name_leftorium) unless stack_ready?(stack_name_leftorium)
|
|
1712
|
+
wait_for_stack_ready(stack_name_rachele) unless stack_ready?(stack_name_rachele)
|
|
1713
|
+
|
|
1714
|
+
stack_name_web = "ecs-task-web-qa-#{deploy_id}"
|
|
1715
|
+
git_checkout_version('prima', @projects["prima"][:revision])
|
|
1716
|
+
stack_body = IO.read('projects/prima/app/cloudformation/tasks/web.yml')
|
|
360
1717
|
parameters = [
|
|
361
1718
|
{
|
|
362
1719
|
parameter_key: "Environment",
|
|
363
1720
|
parameter_value: "qa"
|
|
364
1721
|
},
|
|
365
1722
|
{
|
|
366
|
-
parameter_key: "ReleaseVersion",
|
|
367
|
-
parameter_value: @projects["
|
|
1723
|
+
parameter_key: "ReleaseVersion",
|
|
1724
|
+
parameter_value: "#{@projects["prima"][:revision]}"
|
|
1725
|
+
},
|
|
1726
|
+
{
|
|
1727
|
+
parameter_key: "TaskDesiredCount",
|
|
1728
|
+
parameter_value: "1"
|
|
368
1729
|
},
|
|
369
1730
|
{
|
|
370
1731
|
parameter_key: "ECSClusterName",
|
|
371
1732
|
parameter_value: @ecs_cluster_name
|
|
372
1733
|
},
|
|
373
1734
|
{
|
|
374
|
-
parameter_key: "
|
|
375
|
-
parameter_value: "
|
|
1735
|
+
parameter_key: "ALBShortName",
|
|
1736
|
+
parameter_value: "web-qa-#{deploy_id}"[0..27]
|
|
376
1737
|
},
|
|
377
1738
|
{
|
|
378
|
-
parameter_key: "
|
|
379
|
-
parameter_value: "
|
|
380
|
-
}
|
|
381
|
-
]
|
|
382
|
-
if stack_exists?(stack_name_bburago)
|
|
383
|
-
update_stack(stack_name_bburago, stack_body, parameters) if @bburago_built
|
|
384
|
-
else
|
|
385
|
-
create_stack(stack_name_bburago, stack_body, parameters, tags)
|
|
386
|
-
end
|
|
387
|
-
|
|
388
|
-
stack_name_hal9000 = "ecs-task-hal9000-qa-#{deploy_id}"
|
|
389
|
-
git_checkout_version('hal9000', @projects["hal9000"][:revision])
|
|
390
|
-
stack_body = IO.read('projects/hal9000/deploy/task.yml')
|
|
391
|
-
parameters = [
|
|
1739
|
+
parameter_key: "WebQaBaseHostname",
|
|
1740
|
+
parameter_value: "#{@dns_record_identifier}.qa.colaster.com"
|
|
1741
|
+
},
|
|
392
1742
|
{
|
|
393
|
-
parameter_key: "
|
|
394
|
-
parameter_value: "qa"
|
|
1743
|
+
parameter_key: "HostnamePattern",
|
|
1744
|
+
parameter_value: "ww*-#{@dns_record_identifier}.qa.colaster.com"
|
|
395
1745
|
},
|
|
396
1746
|
{
|
|
397
|
-
parameter_key: "
|
|
398
|
-
parameter_value:
|
|
1747
|
+
parameter_key: "HostnamePatternPriority",
|
|
1748
|
+
parameter_value: hostname_pattern_priority
|
|
399
1749
|
},
|
|
400
1750
|
{
|
|
401
|
-
parameter_key: "
|
|
402
|
-
parameter_value:
|
|
1751
|
+
parameter_key: "HostnamePatternAggregatorPriority",
|
|
1752
|
+
parameter_value: (hostname_pattern_priority.to_i + 1).to_s
|
|
403
1753
|
},
|
|
404
1754
|
{
|
|
405
|
-
parameter_key: "
|
|
406
|
-
parameter_value:
|
|
1755
|
+
parameter_key: "EnvHash",
|
|
1756
|
+
parameter_value: deploy_id
|
|
407
1757
|
},
|
|
408
1758
|
{
|
|
409
|
-
parameter_key: "
|
|
410
|
-
parameter_value: "
|
|
1759
|
+
parameter_key: "AssangeHostname",
|
|
1760
|
+
parameter_value: "assange-#{@dns_record_identifier}.qa.colaster.com"
|
|
1761
|
+
},
|
|
1762
|
+
{
|
|
1763
|
+
parameter_key: "BackofficeHostname",
|
|
1764
|
+
parameter_value: "backoffice-#{@dns_record_identifier}.qa.colaster.com"
|
|
1765
|
+
},
|
|
1766
|
+
{
|
|
1767
|
+
parameter_key: "WebHostname",
|
|
1768
|
+
parameter_value: "www-#{@dns_record_identifier}.qa.colaster.com"
|
|
411
1769
|
}
|
|
412
1770
|
]
|
|
413
|
-
if stack_exists?(
|
|
414
|
-
|
|
1771
|
+
if stack_exists?(stack_name_web)
|
|
1772
|
+
cur_version = get_currently_deployed_version(stack_name_web)
|
|
1773
|
+
update_stack(stack_name_web, stack_body, parameters, tags, @cf_role) unless cur_version.include?(@projects["prima"][:revision])
|
|
415
1774
|
else
|
|
416
|
-
create_stack(
|
|
1775
|
+
create_stack(stack_name_web, stack_body, parameters, tags, @cf_role)
|
|
417
1776
|
end
|
|
418
1777
|
|
|
419
|
-
|
|
420
|
-
git_checkout_version('
|
|
421
|
-
stack_body = IO.read('projects/
|
|
1778
|
+
stack_name_consumer = "ecs-task-consumer-qa-#{deploy_id}"
|
|
1779
|
+
git_checkout_version('prima', @projects["prima"][:revision])
|
|
1780
|
+
stack_body = IO.read('projects/prima/app/cloudformation/tasks/consumer.yml')
|
|
422
1781
|
parameters = [
|
|
423
1782
|
{
|
|
424
1783
|
parameter_key: "Environment",
|
|
@@ -426,30 +1785,39 @@ class Release
|
|
|
426
1785
|
},
|
|
427
1786
|
{
|
|
428
1787
|
parameter_key: "ReleaseVersion",
|
|
429
|
-
parameter_value: "#{@projects["
|
|
1788
|
+
parameter_value: "#{@projects["prima"][:revision]}"
|
|
430
1789
|
},
|
|
431
1790
|
{
|
|
432
1791
|
parameter_key: "ECSClusterName",
|
|
433
1792
|
parameter_value: @ecs_cluster_name
|
|
434
1793
|
},
|
|
435
1794
|
{
|
|
436
|
-
parameter_key: "
|
|
437
|
-
parameter_value: "
|
|
1795
|
+
parameter_key: "NginxHttpHost",
|
|
1796
|
+
parameter_value: "www-#{@dns_record_identifier}.qa.colaster.com"
|
|
438
1797
|
},
|
|
439
1798
|
{
|
|
440
|
-
parameter_key: "
|
|
441
|
-
parameter_value: "
|
|
1799
|
+
parameter_key: "AssangeHostname",
|
|
1800
|
+
parameter_value: "assange-#{@dns_record_identifier}.qa.colaster.com"
|
|
1801
|
+
},
|
|
1802
|
+
{
|
|
1803
|
+
parameter_key: "BackofficeHostname",
|
|
1804
|
+
parameter_value: "backoffice-#{@dns_record_identifier}.qa.colaster.com"
|
|
1805
|
+
},
|
|
1806
|
+
{
|
|
1807
|
+
parameter_key: "WebHostname",
|
|
1808
|
+
parameter_value: "www-#{@dns_record_identifier}.qa.colaster.com"
|
|
442
1809
|
}
|
|
443
1810
|
]
|
|
444
|
-
if stack_exists?(
|
|
445
|
-
|
|
1811
|
+
if stack_exists?(stack_name_consumer)
|
|
1812
|
+
cur_version = get_currently_deployed_version(stack_name_consumer)
|
|
1813
|
+
update_stack(stack_name_consumer, stack_body, parameters, tags, @cf_role) unless cur_version.include?(@projects["prima"][:revision])
|
|
446
1814
|
else
|
|
447
|
-
create_stack(
|
|
1815
|
+
create_stack(stack_name_consumer, stack_body, parameters, tags, @cf_role)
|
|
448
1816
|
end
|
|
449
1817
|
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
stack_body =
|
|
1818
|
+
stack_name_roger = "ecs-task-roger-qa-#{deploy_id}"
|
|
1819
|
+
git_checkout_version('roger', @projects["roger"][:revision])
|
|
1820
|
+
stack_body = File.read('projects/roger/deploy/task.yml')
|
|
453
1821
|
parameters = [
|
|
454
1822
|
{
|
|
455
1823
|
parameter_key: "Environment",
|
|
@@ -457,7 +1825,7 @@ class Release
|
|
|
457
1825
|
},
|
|
458
1826
|
{
|
|
459
1827
|
parameter_key: "ReleaseVersion",
|
|
460
|
-
parameter_value:
|
|
1828
|
+
parameter_value: @projects["roger"][:revision]
|
|
461
1829
|
},
|
|
462
1830
|
{
|
|
463
1831
|
parameter_key: "TaskDesiredCount",
|
|
@@ -468,86 +1836,149 @@ class Release
|
|
|
468
1836
|
parameter_value: @ecs_cluster_name
|
|
469
1837
|
},
|
|
470
1838
|
{
|
|
471
|
-
parameter_key: "
|
|
472
|
-
parameter_value: "
|
|
1839
|
+
parameter_key: "HostnamePattern",
|
|
1840
|
+
parameter_value: "roger-#{@dns_record_identifier}.qa.colaster.com"
|
|
1841
|
+
},
|
|
1842
|
+
{
|
|
1843
|
+
parameter_key: "HostnamePatternPriority",
|
|
1844
|
+
parameter_value: hostname_pattern_priority
|
|
473
1845
|
}
|
|
474
1846
|
]
|
|
475
|
-
if stack_exists?(
|
|
476
|
-
|
|
1847
|
+
if stack_exists?(stack_name_roger)
|
|
1848
|
+
cur_version = get_currently_deployed_version(stack_name_roger)
|
|
1849
|
+
update_stack(stack_name_roger, stack_body, parameters, tags, @cf_role) unless cur_version.include?(@projects["roger"][:revision])
|
|
477
1850
|
else
|
|
478
|
-
create_stack(
|
|
1851
|
+
create_stack(stack_name_roger, stack_body, parameters, tags, @cf_role)
|
|
1852
|
+
end
|
|
1853
|
+
|
|
1854
|
+
|
|
1855
|
+
if deploy_starsky_hutch?
|
|
1856
|
+
wait_for_stack_ready(stack_name_starsky) unless stack_ready?(stack_name_starsky) unless !deploy_starsky_hutch?
|
|
1857
|
+
|
|
1858
|
+
stack_name_hutch = "ecs-task-hutch-qa-#{deploy_id}"
|
|
1859
|
+
git_checkout_version('hutch', @projects["hutch"][:revision])
|
|
1860
|
+
stack_body = File.read('projects/hutch/deploy/task.yml')
|
|
1861
|
+
parameters = [
|
|
1862
|
+
{
|
|
1863
|
+
parameter_key: "Environment",
|
|
1864
|
+
parameter_value: "qa"
|
|
1865
|
+
},
|
|
1866
|
+
{
|
|
1867
|
+
parameter_key: "ReleaseVersion",
|
|
1868
|
+
parameter_value: "#{@projects["hutch"][:revision]}"
|
|
1869
|
+
},
|
|
1870
|
+
{
|
|
1871
|
+
parameter_key: "ALBShortName",
|
|
1872
|
+
parameter_value: "hutch-qa-#{deploy_id}"[0..27]
|
|
1873
|
+
},
|
|
1874
|
+
{
|
|
1875
|
+
parameter_key: "ECSClusterName",
|
|
1876
|
+
parameter_value: @ecs_cluster_name
|
|
1877
|
+
},
|
|
1878
|
+
{
|
|
1879
|
+
parameter_key: "EnvHash",
|
|
1880
|
+
parameter_value: deploy_id
|
|
1881
|
+
},
|
|
1882
|
+
{
|
|
1883
|
+
parameter_key: "HostnamePattern",
|
|
1884
|
+
parameter_value: "hutch-#{@dns_record_identifier}.qa.colaster.com"
|
|
1885
|
+
},
|
|
1886
|
+
{
|
|
1887
|
+
parameter_key: "HostnamePatternPriority",
|
|
1888
|
+
parameter_value: (hostname_pattern_priority.to_i + 254).to_s
|
|
1889
|
+
},
|
|
1890
|
+
{
|
|
1891
|
+
parameter_key: "StarskyUrl",
|
|
1892
|
+
parameter_value: "https://#{get_route53_hostname('ecs-task-starsky-qa-notneeded')}"
|
|
1893
|
+
}
|
|
1894
|
+
]
|
|
1895
|
+
if stack_exists?(stack_name_hutch)
|
|
1896
|
+
cur_version = get_currently_deployed_version(stack_name_hutch)
|
|
1897
|
+
update_stack(stack_name_hutch, stack_body, parameters, tags, @cf_role) unless cur_version.include?(@projects["hutch"][:revision])
|
|
1898
|
+
else
|
|
1899
|
+
create_stack(stack_name_hutch, stack_body, parameters, tags, @cf_role)
|
|
1900
|
+
end
|
|
479
1901
|
end
|
|
480
1902
|
|
|
481
1903
|
wait_for_stack_ready(stack_name_web) unless stack_ready?(stack_name_web)
|
|
482
1904
|
wait_for_stack_ready(stack_name_consumer) unless stack_ready?(stack_name_consumer)
|
|
483
|
-
wait_for_stack_ready(stack_name_urania) unless stack_ready?(stack_name_urania)
|
|
484
|
-
wait_for_stack_ready(stack_name_backoffice) unless stack_ready?(stack_name_backoffice)
|
|
485
1905
|
wait_for_stack_ready(stack_name_ermes) unless stack_ready?(stack_name_ermes)
|
|
486
|
-
wait_for_stack_ready(stack_name_bburago) unless stack_ready?(stack_name_bburago)
|
|
487
|
-
wait_for_stack_ready(stack_name_hal9000) unless stack_ready?(stack_name_hal9000)
|
|
488
1906
|
wait_for_stack_ready(stack_name_fidaty) unless stack_ready?(stack_name_fidaty)
|
|
1907
|
+
wait_for_stack_ready(stack_name_peano) unless stack_ready?(stack_name_peano)
|
|
1908
|
+
wait_for_stack_ready(stack_name_rogoreport) unless stack_ready?(stack_name_rogoreport)
|
|
1909
|
+
wait_for_stack_ready(stack_name_borat) unless stack_ready?(stack_name_borat)
|
|
1910
|
+
wait_for_stack_ready(stack_name_activia) unless stack_ready?(stack_name_activia)
|
|
1911
|
+
wait_for_stack_ready(stack_name_crash) unless stack_ready?(stack_name_crash) unless !deploy_crash?
|
|
1912
|
+
wait_for_stack_ready(stack_name_hutch) unless stack_ready?(stack_name_hutch) unless !deploy_starsky_hutch?
|
|
489
1913
|
|
|
490
1914
|
update_service_defaults(stack_name_web)
|
|
491
1915
|
update_service_defaults(stack_name_consumer)
|
|
492
1916
|
update_service_defaults(stack_name_urania)
|
|
493
|
-
update_service_defaults(stack_name_backoffice)
|
|
494
1917
|
update_service_defaults(stack_name_ermes)
|
|
495
1918
|
update_service_defaults(stack_name_bburago)
|
|
496
1919
|
update_service_defaults(stack_name_hal9000)
|
|
497
1920
|
update_service_defaults(stack_name_fidaty)
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
parameter_value: get_alb_host(stack_name_backoffice)
|
|
513
|
-
},
|
|
514
|
-
{
|
|
515
|
-
parameter_key: "UraniaElbHostname",
|
|
516
|
-
parameter_value: get_alb_host(stack_name_urania)
|
|
517
|
-
},
|
|
518
|
-
{
|
|
519
|
-
parameter_key: "BburagoElbHostname",
|
|
520
|
-
parameter_value: get_alb_host(stack_name_bburago)
|
|
521
|
-
},
|
|
522
|
-
{
|
|
523
|
-
parameter_key: "Hal9000ElbHostname",
|
|
524
|
-
parameter_value: get_alb_host(stack_name_hal9000)
|
|
525
|
-
},
|
|
526
|
-
{
|
|
527
|
-
parameter_key: "FidatyElbHostname",
|
|
528
|
-
parameter_value: get_alb_host(stack_name_fidaty)
|
|
529
|
-
}
|
|
530
|
-
]
|
|
531
|
-
create_stack(stack_name_route53, stack_body, parameters, tags) unless stack_exists?(stack_name_route53)
|
|
532
|
-
|
|
533
|
-
prima_hostname = get_route53_hostname(stack_name_web)
|
|
534
|
-
urania_hostname = get_route53_hostname(stack_name_urania)
|
|
1921
|
+
update_service_defaults(stack_name_peano)
|
|
1922
|
+
update_service_defaults(stack_name_rogoreport)
|
|
1923
|
+
update_service_defaults(stack_name_assange)
|
|
1924
|
+
update_service_defaults(stack_name_borat)
|
|
1925
|
+
update_service_defaults(stack_name_activia)
|
|
1926
|
+
update_service_defaults(stack_name_skynet)
|
|
1927
|
+
update_service_defaults(stack_name_leftorium)
|
|
1928
|
+
update_service_defaults(stack_name_rachele)
|
|
1929
|
+
update_service_defaults(stack_name_starsky) unless !deploy_starsky_hutch?
|
|
1930
|
+
update_service_defaults(stack_name_hutch) unless !deploy_starsky_hutch?
|
|
1931
|
+
update_service_defaults(stack_name_crash) unless !deploy_crash?
|
|
1932
|
+
|
|
1933
|
+
activia_hostname = get_route53_hostname(stack_name_activia)
|
|
1934
|
+
assange_hostname = get_route53_hostname(stack_name_assange)
|
|
535
1935
|
bburago_hostname = get_route53_hostname(stack_name_bburago)
|
|
536
|
-
|
|
1936
|
+
borat_hostname = get_route53_hostname(stack_name_borat)
|
|
1937
|
+
ermes_hostname = get_route53_hostname(stack_name_ermes)
|
|
537
1938
|
fidaty_hostname = get_route53_hostname(stack_name_fidaty)
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
1939
|
+
hal9000_hostname = get_route53_hostname(stack_name_hal9000)
|
|
1940
|
+
prima_hostname = get_route53_hostname(stack_name_web)
|
|
1941
|
+
peano_hostname = get_route53_hostname(stack_name_peano)
|
|
1942
|
+
skynet_hostname = get_route53_hostname(stack_name_skynet)
|
|
1943
|
+
urania_hostname = get_route53_hostname(stack_name_urania)
|
|
1944
|
+
roger_hostname = get_route53_hostname(stack_name_roger)
|
|
1945
|
+
leftorium_hostname = get_route53_hostname(stack_name_leftorium)
|
|
1946
|
+
rachele_hostname = get_route53_hostname(stack_name_rachele)
|
|
1947
|
+
crash_hostname = get_route53_hostname(stack_name_crash) unless !deploy_crash?
|
|
1948
|
+
starsky_hostname = get_route53_hostname(stack_name_starsky) unless !deploy_starsky_hutch?
|
|
1949
|
+
hutch_hostname = get_route53_hostname(stack_name_hutch) unless !deploy_starsky_hutch?
|
|
1950
|
+
|
|
1951
|
+
# launch_marley ec2_ip_address(asg_stack_name), prima_hostname, borat_hostname
|
|
1952
|
+
|
|
1953
|
+
projects_text = "
|
|
1954
|
+
> Prima url: https://#{prima_hostname}
|
|
1955
|
+
> Backoffice (Borat) url: https://#{borat_hostname}
|
|
1956
|
+
> Urania url: http://#{urania_hostname}:81
|
|
1957
|
+
> Bburago url: http://#{bburago_hostname}:83
|
|
1958
|
+
> Ermes url: http://#{ermes_hostname}:10002
|
|
1959
|
+
> Hal9000 url: http://#{hal9000_hostname}:10031
|
|
1960
|
+
> Fidaty url: http://#{fidaty_hostname}:10021
|
|
1961
|
+
> Peano url: http://#{peano_hostname}:10039
|
|
1962
|
+
> Assange url: https://#{assange_hostname}
|
|
1963
|
+
> Activia url: http://#{activia_hostname}:10041
|
|
1964
|
+
> Skynet url: http://#{skynet_hostname}:8050
|
|
1965
|
+
> Roger url: http://#{roger_hostname}:10051
|
|
1966
|
+
> Leftorium url: http://#{leftorium_hostname}:10061
|
|
1967
|
+
> Rachele url: http://#{rachele_hostname}:10040"
|
|
1968
|
+
projects_text.concat "
|
|
1969
|
+
> Crash url: https://#{crash_hostname}" if deploy_crash?
|
|
1970
|
+
projects_text.concat "
|
|
1971
|
+
> Starsky url: https://#{starsky_hostname}
|
|
1972
|
+
> Hutch url: https://#{hutch_hostname}" if deploy_starsky_hutch?
|
|
1973
|
+
projects_text.concat "
|
|
1974
|
+
> RabbitMQ url: http://#{ec2_ip_address(asg_stack_name)}:15672
|
|
1975
|
+
> Supervisor url: http://#{ec2_ip_address(asg_stack_name)}:9001
|
|
1976
|
+
> Elasticsearch url: http://#{ec2_ip_address(asg_stack_name)}:9200
|
|
1977
|
+
> SSH connection: ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no githubUsername@#{ec2_ip_address(asg_stack_name)}\n"
|
|
1978
|
+
output projects_text.cyan
|
|
550
1979
|
output "Deploy effettuato, everything is awesome!\n".green
|
|
1980
|
+
|
|
1981
|
+
qainit_write_output(projects_text, 'Indirizzi scritti su ')
|
|
551
1982
|
end
|
|
552
1983
|
|
|
553
1984
|
def get_route53_hostname(stack_name)
|
|
@@ -556,14 +1987,36 @@ class Release
|
|
|
556
1987
|
host = "www-#{@dns_record_identifier}.qa.colaster.com"
|
|
557
1988
|
when stack_name.include?('urania')
|
|
558
1989
|
host = "urania-#{@dns_record_identifier}.qa.colaster.com"
|
|
559
|
-
when stack_name.include?('backoffice')
|
|
560
|
-
host = "backoffice-#{@dns_record_identifier}.qa.colaster.com"
|
|
561
1990
|
when stack_name.include?('bburago')
|
|
562
1991
|
host = "bburago-#{@dns_record_identifier}.qa.colaster.com"
|
|
563
1992
|
when stack_name.include?('hal9000')
|
|
564
1993
|
host = "hal9000-#{@dns_record_identifier}.qa.colaster.com"
|
|
565
1994
|
when stack_name.include?('fidaty')
|
|
566
1995
|
host = "fidaty-#{@dns_record_identifier}.qa.colaster.com"
|
|
1996
|
+
when stack_name.include?('peano')
|
|
1997
|
+
host = "peano-#{@dns_record_identifier}.qa.colaster.com"
|
|
1998
|
+
when stack_name.include?('assange')
|
|
1999
|
+
host = "assange-#{@dns_record_identifier}.qa.colaster.com"
|
|
2000
|
+
when stack_name.include?('borat')
|
|
2001
|
+
host = "backoffice-#{@dns_record_identifier}.qa.colaster.com"
|
|
2002
|
+
when stack_name.include?('crash')
|
|
2003
|
+
host = "crash-#{@dns_record_identifier}.qa.colaster.com"
|
|
2004
|
+
when stack_name.include?('ermes')
|
|
2005
|
+
host = "ermes-#{@dns_record_identifier}.qa.colaster.com"
|
|
2006
|
+
when stack_name.include?('activia')
|
|
2007
|
+
host = "activia-#{@dns_record_identifier}.qa.colaster.com"
|
|
2008
|
+
when stack_name.include?('skynet')
|
|
2009
|
+
host = "skynet-#{@dns_record_identifier}.qa.colaster.com"
|
|
2010
|
+
when stack_name.include?('roger')
|
|
2011
|
+
host = "roger-#{@dns_record_identifier}.qa.colaster.com"
|
|
2012
|
+
when stack_name.include?('leftorium')
|
|
2013
|
+
host = "leftorium-#{@dns_record_identifier}.qa.colaster.com"
|
|
2014
|
+
when stack_name.include?('rachele')
|
|
2015
|
+
host = "rachele-#{@dns_record_identifier}.qa.colaster.com"
|
|
2016
|
+
when stack_name.include?('starsky')
|
|
2017
|
+
host = "starsky-#{@dns_record_identifier}.qa.colaster.com"
|
|
2018
|
+
when stack_name.include?('hutch')
|
|
2019
|
+
host = "hutch-#{@dns_record_identifier}.qa.colaster.com"
|
|
567
2020
|
end
|
|
568
2021
|
host
|
|
569
2022
|
end
|
|
@@ -596,6 +2049,32 @@ class Release
|
|
|
596
2049
|
logical_resource_id = 'EcsApplicationLoadBalancerInternal'
|
|
597
2050
|
when stack_name.include?('fidaty')
|
|
598
2051
|
logical_resource_id = 'EcsApplicationLoadBalancerInternal'
|
|
2052
|
+
when stack_name.include?('activia')
|
|
2053
|
+
logical_resource_id = 'EcsApplicationLoadBalancerInternal'
|
|
2054
|
+
when stack_name.include?('skynet')
|
|
2055
|
+
logical_resource_id = 'EcsApplicationLoadBalancerInternal'
|
|
2056
|
+
when stack_name.include?('roger')
|
|
2057
|
+
logical_resource_id = 'EcsApplicationLoadBalancerInternal'
|
|
2058
|
+
when stack_name.include?('alb-http-public')
|
|
2059
|
+
logical_resource_id = 'EcsApplicationLoadBalancerPublic'
|
|
2060
|
+
when stack_name.include?('alb-ws-public')
|
|
2061
|
+
logical_resource_id = 'EcsApplicationLoadBalancerPublic'
|
|
2062
|
+
when stack_name.include?('peano')
|
|
2063
|
+
logical_resource_id = 'EcsApplicationLoadBalancerInternal'
|
|
2064
|
+
when stack_name.include?('leftorium')
|
|
2065
|
+
logical_resource_id = 'EcsApplicationLoadBalancerInternal'
|
|
2066
|
+
when stack_name.include?('assange')
|
|
2067
|
+
logical_resource_id = 'EcsApplicationLoadBalancerPublic'
|
|
2068
|
+
when stack_name.include?('borat')
|
|
2069
|
+
logical_resource_id = 'EcsApplicationLoadBalancerPublic'
|
|
2070
|
+
when stack_name.include?('crash')
|
|
2071
|
+
logical_resource_id = 'EcsApplicationLoadBalancerPublic'
|
|
2072
|
+
when stack_name.include?('rachele')
|
|
2073
|
+
logical_resource_id = 'EcsApplicationLoadBalancerInternal'
|
|
2074
|
+
when stack_name.include?('starsky')
|
|
2075
|
+
logical_resource_id = 'EcsApplicationLoadBalancerPublic'
|
|
2076
|
+
when stack_name.include?('hutch')
|
|
2077
|
+
logical_resource_id = 'EcsApplicationLoadBalancerPublic'
|
|
599
2078
|
end
|
|
600
2079
|
resp = @cf.describe_stack_resource({
|
|
601
2080
|
stack_name: stack_name,
|
|
@@ -607,377 +2086,723 @@ class Release
|
|
|
607
2086
|
resp.load_balancers[0].dns_name
|
|
608
2087
|
end
|
|
609
2088
|
|
|
610
|
-
def get_elb_host(stack_name)
|
|
611
|
-
case
|
|
612
|
-
when stack_name.include?('web')
|
|
613
|
-
logical_resource_id = 'EcsElasticLoadBalancerPublic'
|
|
614
|
-
when stack_name.include?('urania')
|
|
615
|
-
logical_resource_id = 'EcsElasticLoadBalancerInternal'
|
|
616
|
-
when stack_name.include?('backoffice')
|
|
617
|
-
logical_resource_id = 'EcsElasticLoadBalancerPublic'
|
|
618
|
-
when stack_name.include?('bburago')
|
|
619
|
-
logical_resource_id = 'EcsElasticLoadBalancerInternal'
|
|
620
|
-
when stack_name.include?('hal9000')
|
|
621
|
-
logical_resource_id = 'EcsElasticLoadBalancerInternal'
|
|
622
|
-
when stack_name.include?('fidaty')
|
|
623
|
-
logical_resource_id = 'EcsElasticLoadBalancerInternal'
|
|
624
|
-
end
|
|
625
|
-
resp = @cf.describe_stack_resource({
|
|
626
|
-
stack_name: stack_name,
|
|
627
|
-
logical_resource_id: logical_resource_id
|
|
628
|
-
})
|
|
629
|
-
resp = @elb.describe_load_balancers({
|
|
630
|
-
load_balancer_names: [resp.stack_resource_detail.physical_resource_id],
|
|
631
|
-
page_size: 1
|
|
632
|
-
})
|
|
633
|
-
resp.load_balancer_descriptions[0].dns_name
|
|
634
|
-
end
|
|
635
|
-
|
|
636
2089
|
def update_service_defaults(stack_name)
|
|
637
2090
|
case
|
|
638
2091
|
when stack_name.include?('web')
|
|
639
|
-
logical_resource_id = '
|
|
2092
|
+
logical_resource_id = 'ECSServiceWebQA'
|
|
640
2093
|
when stack_name.include?('consumer')
|
|
641
2094
|
logical_resource_id = 'ECSServiceConsumer'
|
|
642
2095
|
when stack_name.include?('urania')
|
|
643
|
-
logical_resource_id = '
|
|
2096
|
+
logical_resource_id = 'ECSServiceUraniaQA'
|
|
644
2097
|
when stack_name.include?('backoffice')
|
|
645
2098
|
logical_resource_id = 'ECSServiceBackoffice'
|
|
646
2099
|
when stack_name.include?('ermes')
|
|
647
|
-
logical_resource_id = '
|
|
2100
|
+
logical_resource_id = 'ECSServiceErmesQA'
|
|
648
2101
|
when stack_name.include?('bburago')
|
|
649
|
-
logical_resource_id = '
|
|
2102
|
+
logical_resource_id = 'ECSServiceBburagoQA'
|
|
650
2103
|
when stack_name.include?('hal9000')
|
|
651
|
-
logical_resource_id = '
|
|
2104
|
+
logical_resource_id = 'ECSServiceHal9000QA'
|
|
652
2105
|
when stack_name.include?('fidaty')
|
|
653
|
-
logical_resource_id = '
|
|
2106
|
+
logical_resource_id = 'ECSServiceFidatyQA'
|
|
2107
|
+
when stack_name.include?('skynet')
|
|
2108
|
+
logical_resource_id = 'ECSServiceSkynetQA'
|
|
2109
|
+
when stack_name.include?('roger')
|
|
2110
|
+
logical_resource_id = 'ECSServiceRogerQA'
|
|
2111
|
+
when stack_name.include?('activia')
|
|
2112
|
+
logical_resource_id = 'ECSServiceActiviaQA'
|
|
2113
|
+
when stack_name.include?('peano')
|
|
2114
|
+
logical_resource_id = 'ECSServicePeanoQA'
|
|
2115
|
+
when stack_name.include?('rogoreport')
|
|
2116
|
+
logical_resource_id = 'ECSServiceRogoreport'
|
|
2117
|
+
when stack_name.include?('assange')
|
|
2118
|
+
logical_resource_id = 'ECSServiceAssangeQA'
|
|
2119
|
+
when stack_name.include?('borat')
|
|
2120
|
+
logical_resource_id = 'ECSServiceBorat'
|
|
2121
|
+
when stack_name.include?('leftorium')
|
|
2122
|
+
logical_resource_id = 'ECSServiceLeftoriumQA'
|
|
2123
|
+
when stack_name.include?('rachele')
|
|
2124
|
+
logical_resource_id = 'ECSServiceRacheleQA'
|
|
2125
|
+
when stack_name.include?('crash')
|
|
2126
|
+
logical_resource_id = 'ECSServiceCrashQA'
|
|
2127
|
+
when stack_name.include?('starsky')
|
|
2128
|
+
logical_resource_id = 'ECSServiceStarskyQA'
|
|
2129
|
+
when stack_name.include?('hutch')
|
|
2130
|
+
logical_resource_id = 'ECSServiceHutch'
|
|
654
2131
|
else
|
|
655
2132
|
raise "Service name non gestito per lo stack #{stack_name}"
|
|
656
2133
|
end
|
|
657
|
-
resp = @cf.describe_stack_resource(
|
|
2134
|
+
resp = @cf.describe_stack_resource(
|
|
658
2135
|
stack_name: stack_name,
|
|
659
2136
|
logical_resource_id: logical_resource_id
|
|
660
|
-
|
|
661
|
-
|
|
2137
|
+
)
|
|
2138
|
+
@ecs.update_service(
|
|
662
2139
|
cluster: @ecs_cluster_name,
|
|
663
2140
|
service: resp.stack_resource_detail.physical_resource_id,
|
|
664
2141
|
deployment_configuration: {
|
|
665
2142
|
minimum_healthy_percent: 0,
|
|
666
2143
|
maximum_percent: 100
|
|
667
2144
|
}
|
|
668
|
-
|
|
2145
|
+
)
|
|
669
2146
|
end
|
|
670
2147
|
|
|
671
|
-
def
|
|
672
|
-
|
|
673
|
-
|
|
2148
|
+
def create_activia_artifact(revision)
|
|
2149
|
+
output "Preparo l'artifact activia .zip\n".yellow
|
|
2150
|
+
|
|
2151
|
+
git_checkout_version('activia', revision)
|
|
2152
|
+
|
|
2153
|
+
Dir.chdir 'projects/activia'
|
|
2154
|
+
|
|
2155
|
+
decrypt_secrets()
|
|
2156
|
+
|
|
2157
|
+
exec_step 'cp docker-compose.yml docker-compose-ci.yml'
|
|
2158
|
+
exec_step 'prepare-docker-compose --directory activia && cp docker-compose-qainit.yml docker-compose.yml'
|
|
2159
|
+
[
|
|
2160
|
+
"docker-compose build web",
|
|
2161
|
+
"docker-compose run -w $PWD -u root -e MIX_ENV=qa --entrypoint /bin/sh web \
|
|
2162
|
+
'-c' 'mix local.hex --force && mix hex.info && \
|
|
2163
|
+
mix deps.get && mix compile && mix deps.compile && \
|
|
2164
|
+
cd assets && \
|
|
2165
|
+
rm -rf node_modules && \
|
|
2166
|
+
yarn --cache-folder ~/.cache/yarn && \
|
|
2167
|
+
sysconfcpus -n 2 ./node_modules/.bin/webpack --mode production && \
|
|
2168
|
+
cd .. && \
|
|
2169
|
+
mix phx.digest && \
|
|
2170
|
+
rm -rf _build/qa/rel/ && \
|
|
2171
|
+
mix release --env=qa'"
|
|
2172
|
+
].each do |cmd|
|
|
2173
|
+
execute_command cmd
|
|
2174
|
+
end
|
|
2175
|
+
|
|
2176
|
+
cleanup_containers
|
|
2177
|
+
|
|
2178
|
+
artifact_path = Dir.glob("_build/qa/rel/activia/releases/*/activia.tar.gz").first
|
|
2179
|
+
|
|
2180
|
+
upload_artifact(artifact_path, "microservices/activia/#{revision}-qa.tar.gz", "#{@s3_bucket}-encrypted")
|
|
2181
|
+
|
|
2182
|
+
Dir.chdir '../../'
|
|
2183
|
+
end
|
|
2184
|
+
|
|
2185
|
+
def create_assange_artifact(revision)
|
|
2186
|
+
output "Preparo l'artifact assange .zip\n".yellow
|
|
2187
|
+
|
|
2188
|
+
git_checkout_version('assange', revision)
|
|
2189
|
+
|
|
2190
|
+
Dir.chdir 'projects/assange'
|
|
2191
|
+
|
|
2192
|
+
decrypt_secrets()
|
|
2193
|
+
|
|
2194
|
+
exec_step 'cp docker-compose.yml docker-compose-ci.yml'
|
|
2195
|
+
exec_step 'prepare-docker-compose --directory assange && cp docker-compose-qainit.yml docker-compose.yml'
|
|
2196
|
+
[
|
|
2197
|
+
"docker-compose build web",
|
|
2198
|
+
"docker-compose run -w $PWD -u root -e MIX_ENV=qa --entrypoint /bin/sh web \
|
|
2199
|
+
'-c' 'mix local.hex --force && mix hex.info && \
|
|
2200
|
+
mix deps.get && mix compile && mix deps.compile && \
|
|
2201
|
+
mix phx.digest && \
|
|
2202
|
+
rm -rf _build/qa/rel/ && \
|
|
2203
|
+
mix release --env=qa'"
|
|
2204
|
+
].each do |cmd|
|
|
2205
|
+
execute_command cmd
|
|
2206
|
+
end
|
|
2207
|
+
|
|
2208
|
+
cleanup_containers
|
|
2209
|
+
|
|
2210
|
+
artifact_path = Dir.glob("_build/qa/rel/assange/releases/*/assange.tar.gz").first
|
|
2211
|
+
upload_artifact(artifact_path, "microservices/assange/#{revision}-qa.tar.gz", "#{@s3_bucket}-encrypted")
|
|
2212
|
+
|
|
2213
|
+
Dir.chdir '../../'
|
|
2214
|
+
end
|
|
2215
|
+
|
|
2216
|
+
def create_bburago_artifact(revision)
|
|
2217
|
+
output "Preparo l'artifact bburago .zip\n".yellow
|
|
2218
|
+
|
|
2219
|
+
git_checkout_version('bburago', revision)
|
|
2220
|
+
|
|
2221
|
+
Dir.chdir 'projects/bburago'
|
|
2222
|
+
|
|
2223
|
+
decrypt_secrets()
|
|
2224
|
+
|
|
2225
|
+
exec_step 'cp docker-compose.yml docker-compose-ci.yml'
|
|
2226
|
+
exec_step 'prepare-docker-compose --directory bburago && cp docker-compose-qainit.yml docker-compose.yml'
|
|
2227
|
+
[
|
|
2228
|
+
"docker-compose build web",
|
|
2229
|
+
"docker-compose run -w $PWD -u root -e MIX_ENV=qa --entrypoint deploy/create_qa_artifact web"
|
|
2230
|
+
].each do |cmd|
|
|
2231
|
+
execute_command cmd
|
|
2232
|
+
end
|
|
2233
|
+
|
|
2234
|
+
cleanup_containers
|
|
2235
|
+
|
|
2236
|
+
artifact_path = Dir.glob('_build/qa/rel/bburago/releases/*/bburago.tar.gz').first
|
|
2237
|
+
upload_artifact(artifact_path, "microservices/bburago/#{revision}-qa.tar.gz", "#{@s3_bucket}-encrypted")
|
|
2238
|
+
|
|
2239
|
+
Dir.chdir '../../'
|
|
2240
|
+
end
|
|
2241
|
+
|
|
2242
|
+
def create_borat_artifact(revision)
|
|
2243
|
+
output "Preparo l'artifact borat .zip\n".yellow
|
|
2244
|
+
|
|
2245
|
+
git_checkout_version('borat', revision)
|
|
2246
|
+
|
|
2247
|
+
Dir.chdir 'projects/borat'
|
|
2248
|
+
|
|
2249
|
+
decrypt_secrets()
|
|
2250
|
+
|
|
2251
|
+
exec_step 'cp docker-compose.yml docker-compose-ci.yml'
|
|
2252
|
+
exec_step 'prepare-docker-compose --directory borat && cp docker-compose-qainit.yml docker-compose.yml'
|
|
2253
|
+
[
|
|
2254
|
+
"docker network create borat_network || true",
|
|
2255
|
+
"docker-compose build web",
|
|
2256
|
+
"docker-compose run -w $PWD -u root -e MIX_ENV=qa --entrypoint /bin/sh web \
|
|
2257
|
+
'-c' 'mix local.hex --force && mix hex.info && \
|
|
2258
|
+
mix deps.get && \
|
|
2259
|
+
cd assets && \
|
|
2260
|
+
yarn --cache-folder ~/.cache/yarn && \
|
|
2261
|
+
sysconfcpus -n 2 ./node_modules/.bin/webpack -p --config config/webpack.config.prod.js && \
|
|
2262
|
+
cd ../ && \
|
|
2263
|
+
mix phx.digest && \
|
|
2264
|
+
mix compile && mix deps.compile && \
|
|
2265
|
+
rm -rf _build/qa/rel/ && \
|
|
2266
|
+
mix distillery.release --env=qa'"
|
|
2267
|
+
].each do |cmd|
|
|
2268
|
+
execute_command cmd
|
|
2269
|
+
end
|
|
2270
|
+
|
|
2271
|
+
cleanup_containers
|
|
2272
|
+
|
|
2273
|
+
artifact_path = Dir.glob("_build/qa/rel/borat/releases/*/borat.tar.gz").first
|
|
2274
|
+
upload_artifact(artifact_path, "microservices/borat/#{revision}-qa.tar.gz", "#{@s3_bucket}-encrypted")
|
|
2275
|
+
|
|
2276
|
+
Dir.chdir '../../'
|
|
2277
|
+
end
|
|
2278
|
+
|
|
2279
|
+
def create_crash_artifact(revision, deploy_id)
|
|
2280
|
+
output "Preparo l'artifact crash .zip\n".yellow
|
|
2281
|
+
|
|
2282
|
+
git_checkout_version('crash', revision)
|
|
2283
|
+
|
|
2284
|
+
Dir.chdir 'projects/crash'
|
|
2285
|
+
|
|
2286
|
+
crash_qa_host = get_route53_hostname('ecs-task-crash-qa-notneeded')
|
|
2287
|
+
|
|
2288
|
+
decrypt_secrets()
|
|
2289
|
+
|
|
2290
|
+
`mv docker-compose-ci.yml docker-compose.yml`
|
|
2291
|
+
exec_step 'prepare-docker-compose --directory crash && cp docker-compose-qainit.yml docker-compose.yml'
|
|
2292
|
+
[
|
|
2293
|
+
'docker-compose build web',
|
|
2294
|
+
"docker-compose run -w $PWD -u root -e MIX_ENV=qa -e ENV_HASH=#{deploy_id} web \
|
|
2295
|
+
'-c' 'mix local.hex --force && mix hex.info && \
|
|
2296
|
+
mix deps.get && \
|
|
2297
|
+
cd assets && \
|
|
2298
|
+
yarn --cache-folder ~/.cache/yarn && \
|
|
2299
|
+
NODE_ENV=production sysconfcpus -n 1 yarn run build && \
|
|
2300
|
+
cd ../ && \
|
|
2301
|
+
mix release.clean --implode --no-confirm && \
|
|
2302
|
+
mix phx.digest && \
|
|
2303
|
+
mix deps.clean --all && \
|
|
2304
|
+
mix deps.get && \
|
|
2305
|
+
mix compile && mix release --env=qa'",
|
|
2306
|
+
'docker-compose down'
|
|
2307
|
+
].each do |cmd|
|
|
2308
|
+
execute_command cmd
|
|
2309
|
+
end
|
|
2310
|
+
|
|
2311
|
+
cleanup_containers
|
|
2312
|
+
|
|
2313
|
+
artifact_path = Dir.glob('_build/qa/rel/crash/releases/*/crash.tar.gz').first
|
|
2314
|
+
upload_artifact(artifact_path, "microservices/crash/#{revision}-qa.tar.gz", "#{@s3_bucket}-encrypted")
|
|
2315
|
+
|
|
2316
|
+
Dir.chdir '../../'
|
|
2317
|
+
end
|
|
2318
|
+
|
|
2319
|
+
def create_ermes_artifact(revision)
|
|
2320
|
+
output "Preparo l'artifact ermes .zip\n".yellow
|
|
2321
|
+
|
|
2322
|
+
git_checkout_version('ermes', revision)
|
|
2323
|
+
|
|
2324
|
+
Dir.chdir 'projects/ermes'
|
|
2325
|
+
|
|
2326
|
+
decrypt_secrets()
|
|
2327
|
+
|
|
2328
|
+
exec_step 'cp docker-compose.yml docker-compose-ci.yml'
|
|
2329
|
+
exec_step 'prepare-docker-compose --directory ermes && cp docker-compose-qainit.yml docker-compose.yml'
|
|
2330
|
+
|
|
2331
|
+
[
|
|
2332
|
+
"if echo `docker network ls` | grep crash_default; \
|
|
2333
|
+
then echo 'crash_default network already existing'; \
|
|
2334
|
+
else docker network create crash_default; fi",
|
|
2335
|
+
'docker-compose build web'
|
|
2336
|
+
].each do |cmd|
|
|
2337
|
+
execute_command cmd
|
|
2338
|
+
end
|
|
2339
|
+
|
|
2340
|
+
[ "docker-compose run --rm -w $PWD -u root -e MIX_ENV=qa --entrypoint /bin/sh web \
|
|
2341
|
+
'-c' 'mix local.hex --force && mix hex.info && \
|
|
2342
|
+
mix deps.get && mix compile && mix deps.compile && \
|
|
2343
|
+
mix phx.digest && \
|
|
2344
|
+
MIX_ENV=dev mix compile.sms && \
|
|
2345
|
+
MIX_ENV=dev mix compile.html && \
|
|
2346
|
+
MIX_ENV=dev mix compile.heml && \
|
|
2347
|
+
rm -rf _build/qa/rel/ && \
|
|
2348
|
+
mix release --env=qa'"
|
|
2349
|
+
].each do |cmd|
|
|
2350
|
+
execute_command cmd
|
|
2351
|
+
end
|
|
2352
|
+
|
|
2353
|
+
cleanup_containers
|
|
2354
|
+
|
|
2355
|
+
artifact_path = Dir.glob("_build/qa/rel/ermes/releases/*/ermes.tar.gz").first
|
|
2356
|
+
upload_artifact(artifact_path, "microservices/ermes/#{revision}-qa.tar.gz", "#{@s3_bucket}-encrypted")
|
|
2357
|
+
|
|
2358
|
+
Dir.chdir '../../'
|
|
2359
|
+
end
|
|
2360
|
+
|
|
2361
|
+
def create_fidaty_artifact(revision)
|
|
2362
|
+
output "Preparo l'artifact fidaty .zip\n".yellow
|
|
2363
|
+
|
|
2364
|
+
git_checkout_version('fidaty', revision)
|
|
2365
|
+
|
|
2366
|
+
Dir.chdir 'projects/fidaty'
|
|
2367
|
+
|
|
2368
|
+
decrypt_secrets()
|
|
2369
|
+
|
|
2370
|
+
exec_step 'cp docker-compose.yml docker-compose-ci.yml'
|
|
2371
|
+
exec_step 'prepare-docker-compose --directory fidaty && cp docker-compose-qainit.yml docker-compose.yml'
|
|
2372
|
+
[
|
|
2373
|
+
"docker-compose build web",
|
|
2374
|
+
"docker-compose run -w $PWD -u root -e MIX_ENV=qa --entrypoint /bin/sh web \
|
|
2375
|
+
'-c' 'mix local.hex --force && mix hex.info && \
|
|
2376
|
+
mix deps.get && mix compile && mix deps.compile && \
|
|
2377
|
+
mix phx.digest && \
|
|
2378
|
+
rm -rf _build/qa/rel/ && \
|
|
2379
|
+
mix release --env=qa'"
|
|
2380
|
+
].each do |cmd|
|
|
2381
|
+
execute_command cmd
|
|
2382
|
+
end
|
|
2383
|
+
|
|
2384
|
+
cleanup_containers
|
|
2385
|
+
|
|
2386
|
+
artifact_path = Dir.glob("_build/qa/rel/fidaty/releases/*/fidaty.tar.gz").first
|
|
2387
|
+
upload_artifact(artifact_path, "microservices/fidaty/#{revision}-qa.tar.gz", "#{@s3_bucket}-encrypted")
|
|
2388
|
+
|
|
2389
|
+
Dir.chdir '../../'
|
|
2390
|
+
end
|
|
2391
|
+
|
|
2392
|
+
def create_hal9000_artifact(revision)
|
|
2393
|
+
output "Preparo l'artifact hal9000 .zip\n".yellow
|
|
2394
|
+
|
|
2395
|
+
git_checkout_version('hal9000', revision)
|
|
674
2396
|
|
|
675
|
-
|
|
2397
|
+
Dir.chdir 'projects/hal9000'
|
|
676
2398
|
|
|
677
|
-
|
|
2399
|
+
decrypt_secrets()
|
|
678
2400
|
|
|
2401
|
+
exec_step 'cp docker-compose.yml docker-compose-ci.yml'
|
|
2402
|
+
exec_step 'prepare-docker-compose --directory hal9000 && cp docker-compose-qainit.yml docker-compose.yml'
|
|
679
2403
|
[
|
|
680
2404
|
"docker-compose build web",
|
|
681
|
-
"docker run -
|
|
2405
|
+
"docker-compose run -w $PWD -u root -e MIX_ENV=qa --entrypoint /bin/sh web \
|
|
682
2406
|
'-c' 'mix local.hex --force && mix hex.info && \
|
|
683
2407
|
mix deps.get && mix compile && mix deps.compile && \
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
2408
|
+
mix phx.digest assets -o priv/static && \
|
|
2409
|
+
rm -rf _build/qa/rel/ && \
|
|
2410
|
+
mix release --env=qa'"
|
|
687
2411
|
].each do |cmd|
|
|
688
|
-
|
|
689
|
-
res = %x[ #{cmd} ]
|
|
690
|
-
if $?.exitstatus != 0
|
|
691
|
-
color = 'red'
|
|
692
|
-
else
|
|
693
|
-
color = 'green'
|
|
694
|
-
end
|
|
695
|
-
output res.send color
|
|
696
|
-
stop_if (color == 'red'), "Errore durante la build dell'artifact".red
|
|
2412
|
+
execute_command cmd
|
|
697
2413
|
end
|
|
698
2414
|
|
|
699
|
-
|
|
700
|
-
|
|
2415
|
+
cleanup_containers
|
|
2416
|
+
|
|
2417
|
+
artifact_path = Dir.glob("_build/qa/rel/hal9000/releases/*/hal9000.tar.gz").first
|
|
2418
|
+
upload_artifact(artifact_path, "microservices/hal9000/#{revision}-qa.tar.gz", "#{@s3_bucket}-encrypted")
|
|
701
2419
|
|
|
702
2420
|
Dir.chdir '../../'
|
|
703
2421
|
end
|
|
704
2422
|
|
|
705
|
-
def
|
|
706
|
-
|
|
707
|
-
output "Preparo l'artifact ermes .zip\n".yellow
|
|
2423
|
+
def create_hutch_artifact(revision)
|
|
2424
|
+
output "Preparo l'artifact hutch\n".yellow
|
|
708
2425
|
|
|
709
|
-
git_checkout_version('
|
|
2426
|
+
git_checkout_version('hutch', revision)
|
|
710
2427
|
|
|
711
|
-
Dir.chdir 'projects/
|
|
2428
|
+
Dir.chdir 'projects/hutch'
|
|
2429
|
+
|
|
2430
|
+
version = `git rev-parse HEAD`
|
|
2431
|
+
|
|
2432
|
+
decrypt_secrets() unless File.exist?('config/secrets.yml')
|
|
712
2433
|
|
|
2434
|
+
exec_step 'cp docker-compose-ci.yml docker-compose.yml'
|
|
2435
|
+
exec_step 'prepare-docker-compose --directory hutch && cp docker-compose-qainit.yml docker-compose.yml'
|
|
2436
|
+
exec_step "sed s/qa_deploy_id/#{get_deploy_id}/ .env.dist.qa"
|
|
2437
|
+
exec_step "cp .env.dist.qa .env"
|
|
2438
|
+
exec_step "rm -fr peano"
|
|
2439
|
+
|
|
2440
|
+
[
|
|
2441
|
+
"sed -i 's/USER app/USER root/g' Dockerfile",
|
|
2442
|
+
"docker-compose build web",
|
|
2443
|
+
"docker-compose run -w $PWD -u root -e ELM_APP_STARSKY_URL=https://#{get_route53_hostname("starsky")} --entrypoint /bin/sh web \
|
|
2444
|
+
'-c' 'yarn && yarn run build \
|
|
2445
|
+
&& tar cfz #{revision}-qa.tar.gz *'"
|
|
2446
|
+
].each do |cmd|
|
|
2447
|
+
execute_command cmd
|
|
2448
|
+
end
|
|
2449
|
+
|
|
2450
|
+
artifact_path = "./#{revision}-qa.tar.gz"
|
|
2451
|
+
|
|
2452
|
+
upload_artifact(artifact_path, "microservices/hutch/#{revision}-qa.tar.gz", "#{@s3_bucket}-encrypted")
|
|
2453
|
+
|
|
2454
|
+
Dir.chdir '../../'
|
|
2455
|
+
end
|
|
2456
|
+
|
|
2457
|
+
def create_leftorium_artifact(revision)
|
|
2458
|
+
output "Preparo l'artifact leftorium .zip\n".yellow
|
|
2459
|
+
|
|
2460
|
+
git_checkout_version('leftorium', revision)
|
|
2461
|
+
|
|
2462
|
+
Dir.chdir 'projects/leftorium'
|
|
2463
|
+
|
|
2464
|
+
decrypt_secrets()
|
|
2465
|
+
|
|
2466
|
+
exec_step 'cp docker-compose.yml docker-compose-ci.yml'
|
|
2467
|
+
exec_step 'prepare-docker-compose --directory leftorium && cp docker-compose-qainit.yml docker-compose.yml'
|
|
713
2468
|
[
|
|
714
|
-
"docker-compose build
|
|
715
|
-
"docker run -
|
|
2469
|
+
"docker-compose build web",
|
|
2470
|
+
"docker-compose run -w $PWD -u root -e MIX_ENV=qa --entrypoint /bin/sh web \
|
|
716
2471
|
'-c' 'mix local.hex --force && mix hex.info && \
|
|
717
2472
|
mix deps.get && mix compile && mix deps.compile && \
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
"sudo chown -R `whoami` ."
|
|
2473
|
+
rm -rf _build/qa/rel/ && \
|
|
2474
|
+
mix release --env=qa'"
|
|
721
2475
|
].each do |cmd|
|
|
722
|
-
|
|
723
|
-
res = %x[ #{cmd} ]
|
|
724
|
-
if $?.exitstatus != 0
|
|
725
|
-
color = 'red'
|
|
726
|
-
else
|
|
727
|
-
color = 'green'
|
|
728
|
-
end
|
|
729
|
-
output res.send color
|
|
730
|
-
stop_if (color == 'red'), "Errore durante la build dell'artifact".red
|
|
2476
|
+
execute_command cmd
|
|
731
2477
|
end
|
|
732
2478
|
|
|
733
|
-
|
|
734
|
-
|
|
2479
|
+
cleanup_containers
|
|
2480
|
+
|
|
2481
|
+
artifact_path = Dir.glob('_build/qa/rel/leftorium/releases/*/leftorium.tar.gz').first
|
|
2482
|
+
upload_artifact(artifact_path, "microservices/leftorium/#{revision}-qa.tar.gz", "#{@s3_bucket}-encrypted")
|
|
735
2483
|
|
|
736
2484
|
Dir.chdir '../../'
|
|
737
2485
|
end
|
|
738
2486
|
|
|
739
|
-
def
|
|
740
|
-
|
|
741
|
-
output "Preparo l'artifact bburago .zip\n".yellow
|
|
2487
|
+
def create_peano_artifact(revision)
|
|
2488
|
+
output "Preparo l'artifact peano .zip\n".yellow
|
|
742
2489
|
|
|
743
|
-
git_checkout_version('
|
|
2490
|
+
git_checkout_version('peano', revision)
|
|
744
2491
|
|
|
745
|
-
Dir.chdir 'projects/
|
|
2492
|
+
Dir.chdir 'projects/peano'
|
|
746
2493
|
|
|
2494
|
+
decrypt_secrets() unless File.exist?('config/secrets.yml')
|
|
2495
|
+
|
|
2496
|
+
exec_step 'cp docker-compose.yml docker-compose-ci.yml'
|
|
2497
|
+
exec_step 'prepare-docker-compose --directory peano && cp docker-compose-qainit.yml docker-compose.yml'
|
|
747
2498
|
[
|
|
748
2499
|
"docker-compose build web",
|
|
749
|
-
"docker run -
|
|
2500
|
+
"docker-compose run -w $PWD -u root -e MIX_ENV=qa --entrypoint /bin/sh web \
|
|
750
2501
|
'-c' 'mix local.hex --force && mix hex.info && \
|
|
751
2502
|
mix deps.get && mix compile && mix deps.compile && \
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
"sudo chown -R `whoami` ."
|
|
2503
|
+
rm -rf _build/qa/rel/ && \
|
|
2504
|
+
mix release --env=qa'"
|
|
755
2505
|
].each do |cmd|
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
2506
|
+
execute_command cmd
|
|
2507
|
+
end
|
|
2508
|
+
|
|
2509
|
+
cleanup_containers
|
|
2510
|
+
|
|
2511
|
+
artifact_path = Dir.glob("_build/qa/rel/peano/releases/*/peano.tar.gz").first
|
|
2512
|
+
upload_artifact(artifact_path, "microservices/peano/#{revision}-qa.tar.gz", "#{@s3_bucket}-encrypted")
|
|
2513
|
+
|
|
2514
|
+
Dir.chdir '../../'
|
|
2515
|
+
end
|
|
2516
|
+
|
|
2517
|
+
def create_prima_artifact(revision, branch_name, deploy_id, minimal = false)
|
|
2518
|
+
output "Preparo l'artifact prima .zip\n".yellow
|
|
2519
|
+
|
|
2520
|
+
git_checkout_version('prima', revision)
|
|
2521
|
+
|
|
2522
|
+
Dir.chdir 'projects/prima'
|
|
2523
|
+
|
|
2524
|
+
['vendor'].each do |dir|
|
|
2525
|
+
unless File.directory?(dir)
|
|
2526
|
+
if File.directory?("../../../prima/#{dir}")
|
|
2527
|
+
exec_step "rsync -a ../../../prima/#{dir} ."
|
|
2528
|
+
end
|
|
2529
|
+
end
|
|
2530
|
+
end
|
|
2531
|
+
|
|
2532
|
+
exec_step 'mv docker-compose-ci.yml docker-compose.yml'
|
|
2533
|
+
exec_step 'prepare-docker-compose --directory prima'
|
|
2534
|
+
exec_step 'sed -i "s/\\/home\\/app/\\/root/g" docker-compose.yml'
|
|
2535
|
+
`sed -i 's/"@prima-assicurazioni/pyxis-npm": ".*",/"@prima-assicurazioni/pyxis-npm": "#{@pyxis_version}",/' package.json` if deploy_pyxis?
|
|
2536
|
+
[
|
|
2537
|
+
"bin/qa_build_artifact.sh #{branch_name} #{'update' if @deploy_update}"
|
|
2538
|
+
].each do |cmd|
|
|
2539
|
+
execute_command cmd
|
|
2540
|
+
end
|
|
2541
|
+
|
|
2542
|
+
cleanup_containers
|
|
2543
|
+
|
|
2544
|
+
Dir.chdir "../../"
|
|
2545
|
+
end
|
|
2546
|
+
|
|
2547
|
+
def create_pyxis_artifact(revision, deploy_id)
|
|
2548
|
+
if (deploy_pyxis?)
|
|
2549
|
+
output "Preparo l'artifact pyxis\n".yellow
|
|
2550
|
+
|
|
2551
|
+
git_checkout_version('pyxis-npm', revision)
|
|
2552
|
+
|
|
2553
|
+
Dir.chdir 'projects/pyxis-npm'
|
|
2554
|
+
|
|
2555
|
+
decrypt_secrets()
|
|
2556
|
+
|
|
2557
|
+
exec_step 'mv .fakenpmrc .npmrc'
|
|
2558
|
+
exec_step 'cp docker-compose.yml docker-compose-ci.yml'
|
|
2559
|
+
exec_step 'prepare-docker-compose --directory pyxis-npm && cp docker-compose-qainit.yml docker-compose.yml'
|
|
2560
|
+
exec_step 'docker-compose build web'
|
|
2561
|
+
|
|
2562
|
+
exec_step "docker-compose run -w $PWD -u root -e NPM_TOKEN=$NPM_TOKEN --entrypoint /bin/sh web \
|
|
2563
|
+
'-c' 'npm view prima-assicurazioni/pyxis-npm versions --json > versions.json'" # posso recuperare le versioni pubblicate solo da dentro al container, scrivo su un file che leggo subito dopo
|
|
2564
|
+
published_versions = `cat versions.json`
|
|
2565
|
+
qa_versions = JSON.parse(published_versions).select{ |version| version.include? get_pyxis_version(deploy_id) }
|
|
2566
|
+
|
|
2567
|
+
@pyxis_version = "0.#{get_pyxis_version(deploy_id)}.#{qa_versions.size}"
|
|
2568
|
+
|
|
2569
|
+
`sed -i '3s/".*/"version": "#{@pyxis_version}",/' package.json`
|
|
2570
|
+
[
|
|
2571
|
+
"docker-compose run -w $PWD -u root -e NPM_TOKEN=$NPM_TOKEN --entrypoint /bin/sh web \
|
|
2572
|
+
'-c' 'yarn install && \
|
|
2573
|
+
yarn build:prod && \
|
|
2574
|
+
npm publish'"
|
|
2575
|
+
].each do |cmd|
|
|
2576
|
+
execute_command cmd
|
|
762
2577
|
end
|
|
763
|
-
|
|
764
|
-
|
|
2578
|
+
|
|
2579
|
+
cleanup_containers
|
|
2580
|
+
Dir.chdir '../../'
|
|
2581
|
+
end
|
|
2582
|
+
end
|
|
2583
|
+
|
|
2584
|
+
def create_rachele_artifact(revision)
|
|
2585
|
+
output "Preparo l'artifact rachele .zip\n".yellow
|
|
2586
|
+
|
|
2587
|
+
git_checkout_version('rachele', revision)
|
|
2588
|
+
|
|
2589
|
+
Dir.chdir 'projects/rachele'
|
|
2590
|
+
|
|
2591
|
+
decrypt_secrets()
|
|
2592
|
+
|
|
2593
|
+
exec_step 'cp docker-compose.yml docker-compose-ci.yml'
|
|
2594
|
+
exec_step 'prepare-docker-compose --directory rachele && cp docker-compose-qainit.yml docker-compose.yml'
|
|
2595
|
+
|
|
2596
|
+
execute_command "docker-compose build web"
|
|
2597
|
+
|
|
2598
|
+
[ "docker-compose run -w $PWD -u root -e MIX_ENV=qa --entrypoint /bin/sh web \
|
|
2599
|
+
'-c' 'mix local.hex --force && mix hex.info && \
|
|
2600
|
+
mix deps.get && mix compile && mix deps.compile && \
|
|
2601
|
+
rm -rf _build/qa/rel/ && \
|
|
2602
|
+
mix release --env=qa'"
|
|
2603
|
+
].each do |cmd|
|
|
2604
|
+
execute_command cmd
|
|
765
2605
|
end
|
|
766
2606
|
|
|
767
|
-
|
|
768
|
-
|
|
2607
|
+
cleanup_containers
|
|
2608
|
+
|
|
2609
|
+
artifact_path = Dir.glob("_build/qa/rel/rachele/releases/*/rachele.tar.gz").first
|
|
2610
|
+
upload_artifact(artifact_path, "microservices/rachele/#{revision}-qa.tar.gz", "#{@s3_bucket}-encrypted")
|
|
769
2611
|
|
|
770
2612
|
Dir.chdir '../../'
|
|
771
2613
|
end
|
|
772
2614
|
|
|
773
|
-
def
|
|
774
|
-
|
|
775
|
-
output "Preparo l'artifact hal9000 .zip\n".yellow
|
|
2615
|
+
def create_roger_artifact(revision)
|
|
2616
|
+
output "Preparo l'artifact roger .zip\n".yellow
|
|
776
2617
|
|
|
777
|
-
git_checkout_version('
|
|
2618
|
+
git_checkout_version('roger', revision)
|
|
778
2619
|
|
|
779
|
-
Dir.chdir 'projects/
|
|
2620
|
+
Dir.chdir 'projects/roger'
|
|
780
2621
|
|
|
2622
|
+
decrypt_secrets()
|
|
2623
|
+
|
|
2624
|
+
exec_step 'cp docker-compose.yml docker-compose-ci.yml'
|
|
2625
|
+
exec_step 'prepare-docker-compose --directory roger && cp docker-compose-qainit.yml docker-compose.yml'
|
|
781
2626
|
[
|
|
782
2627
|
"docker-compose build web",
|
|
783
|
-
"docker run -
|
|
2628
|
+
"docker-compose run -w $PWD -u root -e MIX_ENV=qa --entrypoint /bin/sh web \
|
|
784
2629
|
'-c' 'mix local.hex --force && mix hex.info && \
|
|
785
2630
|
mix deps.get && mix compile && mix deps.compile && \
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
mix
|
|
789
|
-
cp rel/vm.args rel/config.exs /tmp/ && mix release.clean --implode --no-confirm && \
|
|
790
|
-
mkdir -p rel && mv /tmp/vm.args /tmp/config.exs rel/ && mix release --env=qa'",
|
|
791
|
-
"sudo chown -R `whoami` ."
|
|
2631
|
+
mix phx.digest && \
|
|
2632
|
+
rm -rf _build/qa/rel/ && \
|
|
2633
|
+
mix distillery.release --env=qa'"
|
|
792
2634
|
].each do |cmd|
|
|
793
|
-
|
|
794
|
-
res = %x[ #{cmd} ]
|
|
795
|
-
if $?.exitstatus != 0
|
|
796
|
-
color = 'red'
|
|
797
|
-
else
|
|
798
|
-
color = 'green'
|
|
799
|
-
end
|
|
800
|
-
output res.send color
|
|
801
|
-
stop_if (color == 'red'), "Errore durante la build dell'artifact".red
|
|
2635
|
+
execute_command cmd
|
|
802
2636
|
end
|
|
803
2637
|
|
|
804
|
-
|
|
805
|
-
|
|
2638
|
+
cleanup_containers
|
|
2639
|
+
|
|
2640
|
+
artifact_path = Dir.glob("_build/qa/rel/roger/releases/*/roger.tar.gz").first
|
|
2641
|
+
upload_artifact(artifact_path, "microservices/roger/#{revision}-qa.tar.gz", "#{@s3_bucket}-encrypted")
|
|
806
2642
|
|
|
807
2643
|
Dir.chdir '../../'
|
|
808
2644
|
end
|
|
809
2645
|
|
|
810
|
-
def
|
|
811
|
-
|
|
812
|
-
output "Preparo l'artifact fidaty .zip\n".yellow
|
|
2646
|
+
def create_rogoreport_artifact(revision)
|
|
2647
|
+
output "Preparo l'artifact rogoreport .zip\n".yellow
|
|
813
2648
|
|
|
814
|
-
git_checkout_version('
|
|
2649
|
+
git_checkout_version('rogoreport', revision)
|
|
815
2650
|
|
|
816
|
-
Dir.chdir 'projects/
|
|
2651
|
+
Dir.chdir 'projects/rogoreport'
|
|
817
2652
|
|
|
818
|
-
|
|
819
|
-
web_qa_host = get_route53_hostname(stack_name_web)
|
|
2653
|
+
decrypt_secrets() unless File.exist?('config/secrets.yml')
|
|
820
2654
|
|
|
2655
|
+
exec_step 'cp docker-compose.yml docker-compose-ci.yml'
|
|
2656
|
+
exec_step 'prepare-docker-compose --directory rogoreport && cp docker-compose-qainit.yml docker-compose.yml'
|
|
821
2657
|
[
|
|
822
2658
|
"docker-compose build web",
|
|
823
|
-
"docker run -
|
|
824
|
-
'-c' '
|
|
825
|
-
mix local.hex --force && mix hex.info && \
|
|
2659
|
+
"docker-compose run -w $PWD -u root -e MIX_ENV=qa --entrypoint /bin/sh web \
|
|
2660
|
+
'-c' 'mix local.hex --force && mix hex.info && \
|
|
826
2661
|
mix deps.get && mix compile && mix deps.compile && \
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
mkdir -p rel && mv /tmp/vm.args /tmp/config.exs rel/ && mix release --env=qa'",
|
|
830
|
-
"sudo chown -R `whoami` ."
|
|
2662
|
+
rm -rf _build/qa/rel/ && \
|
|
2663
|
+
mix release --name=rogoreport --env=qa'"
|
|
831
2664
|
].each do |cmd|
|
|
832
|
-
|
|
833
|
-
res = %x[ #{cmd} ]
|
|
834
|
-
if $?.exitstatus != 0
|
|
835
|
-
color = 'red'
|
|
836
|
-
else
|
|
837
|
-
color = 'green'
|
|
838
|
-
end
|
|
839
|
-
output res.send color
|
|
840
|
-
stop_if (color == 'red'), "Errore durante la build dell'artifact".red
|
|
2665
|
+
execute_command cmd
|
|
841
2666
|
end
|
|
842
2667
|
|
|
843
|
-
|
|
844
|
-
|
|
2668
|
+
cleanup_containers
|
|
2669
|
+
|
|
2670
|
+
artifact_path = Dir.glob("_build/qa/rel/rogoreport/releases/*/rogoreport.tar.gz").first
|
|
2671
|
+
upload_artifact(artifact_path, "microservices/rogoreport/rogoreport-#{revision}-qa.tar.gz", "#{@s3_bucket}-encrypted")
|
|
845
2672
|
|
|
846
2673
|
Dir.chdir '../../'
|
|
847
2674
|
end
|
|
848
2675
|
|
|
849
|
-
def
|
|
850
|
-
|
|
851
|
-
output "Preparo l'artifact backoffice .zip\n".yellow
|
|
2676
|
+
def create_skynet_artifact(revision)
|
|
2677
|
+
output "Preparo l'artifact skynet\n".yellow
|
|
852
2678
|
|
|
853
|
-
git_checkout_version('
|
|
2679
|
+
git_checkout_version('skynet', revision)
|
|
854
2680
|
|
|
855
|
-
Dir.chdir 'projects/
|
|
2681
|
+
Dir.chdir 'projects/skynet'
|
|
856
2682
|
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
2683
|
+
version = `git rev-parse HEAD`
|
|
2684
|
+
|
|
2685
|
+
artifact_path = "/tmp/skynet-#{revision}-qa.tar.gz"
|
|
2686
|
+
|
|
2687
|
+
exec_step "tar cfz #{artifact_path} core config oracles pickles web tests logstash application_log configuration.py wsgi.py requirements.txt requirements_training.txt"
|
|
2688
|
+
|
|
2689
|
+
upload_artifact(artifact_path, "microservices/skynet/#{revision}-qa.tar.gz", "#{@s3_bucket}-encrypted")
|
|
2690
|
+
|
|
2691
|
+
Dir.chdir '../../'
|
|
2692
|
+
end
|
|
2693
|
+
|
|
2694
|
+
def create_starsky_artifact(revision)
|
|
2695
|
+
output "Preparo l'artifact starsky\n".yellow
|
|
864
2696
|
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
2697
|
+
git_checkout_version('starsky', revision)
|
|
2698
|
+
|
|
2699
|
+
Dir.chdir 'projects/starsky'
|
|
2700
|
+
|
|
2701
|
+
version = `git rev-parse HEAD`
|
|
2702
|
+
|
|
2703
|
+
#artifact_path = "/tmp/starsky-#{revision}-qa.tar.gz"
|
|
2704
|
+
|
|
2705
|
+
decrypt_secrets() unless File.exist?('config/secrets.yml')
|
|
2706
|
+
|
|
2707
|
+
`mv docker-compose-ci.yml docker-compose.yml`
|
|
2708
|
+
exec_step 'prepare-docker-compose --directory starsky && cp docker-compose-qainit.yml docker-compose.yml'
|
|
2709
|
+
exec_step "sed s/qa_deploy_id/#{get_deploy_id}/ .env.dist.qa"
|
|
2710
|
+
exec_step "cp .env.dist.qa .env"
|
|
868
2711
|
|
|
869
2712
|
[
|
|
870
|
-
"
|
|
871
|
-
"
|
|
872
|
-
|
|
873
|
-
|
|
2713
|
+
"sed -i 's/USER app/USER root/g' Dockerfile",
|
|
2714
|
+
"if echo `docker network ls` | grep peano_default; \
|
|
2715
|
+
then echo 'peano_default network already existing'; \
|
|
2716
|
+
else docker network create peano_default; fi",
|
|
2717
|
+
"docker-compose build web",
|
|
2718
|
+
"docker-compose run -w $PWD -e BUILD_ENV=qa -u root --entrypoint /bin/sh web \
|
|
2719
|
+
'-c' 'cargo build --release -vv --features=qa \
|
|
2720
|
+
&& cargo build --bin migrate --release --features=qa \
|
|
2721
|
+
&& cargo build --bin rabbit_worker --release --features=qa \
|
|
2722
|
+
&& cp -p target/release/starsky . \
|
|
2723
|
+
&& cp -p target/release/migrate . \
|
|
2724
|
+
&& cp -p target/release/rabbit_worker . \
|
|
2725
|
+
&& tar cfz #{revision}-qa.tar.gz config starsky migrate rabbit_worker .env.dist.*'"
|
|
874
2726
|
].each do |cmd|
|
|
875
|
-
|
|
876
|
-
res = %x[ #{cmd} ]
|
|
877
|
-
if $?.exitstatus != 0
|
|
878
|
-
color = 'red'
|
|
879
|
-
else
|
|
880
|
-
color = 'green'
|
|
881
|
-
end
|
|
882
|
-
output res.send color
|
|
883
|
-
stop_if (color == 'red'), "Errore durante la build dell'artifact".red
|
|
2727
|
+
execute_command cmd
|
|
884
2728
|
end
|
|
885
2729
|
|
|
886
|
-
artifact_path =
|
|
887
|
-
|
|
888
|
-
upload_artifact(artifact_path, "
|
|
2730
|
+
artifact_path = "./#{revision}-qa.tar.gz"
|
|
2731
|
+
|
|
2732
|
+
upload_artifact(artifact_path, "microservices/starsky/#{revision}-qa.tar.gz", "#{@s3_bucket}-encrypted")
|
|
889
2733
|
|
|
890
2734
|
Dir.chdir '../../'
|
|
891
2735
|
end
|
|
892
2736
|
|
|
893
|
-
def
|
|
894
|
-
|
|
895
|
-
output "Preparo l'artifact prima .zip\n".yellow
|
|
2737
|
+
def create_urania_artifact(revision)
|
|
2738
|
+
output "Preparo l'artifact urania .zip\n".yellow
|
|
896
2739
|
|
|
897
|
-
git_checkout_version('
|
|
2740
|
+
git_checkout_version('urania', revision)
|
|
898
2741
|
|
|
899
|
-
Dir.chdir 'projects/
|
|
2742
|
+
Dir.chdir 'projects/urania'
|
|
900
2743
|
|
|
901
|
-
|
|
2744
|
+
decrypt_secrets()
|
|
902
2745
|
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
if File.directory?("../../../prima/#{dir}")
|
|
906
|
-
exec_step "rsync -a ../../../prima/#{dir} ."
|
|
907
|
-
end
|
|
908
|
-
end
|
|
909
|
-
end
|
|
2746
|
+
exec_step 'cp docker-compose.yml docker-compose-ci.yml'
|
|
2747
|
+
exec_step 'prepare-docker-compose --directory urania && cp docker-compose-qainit.yml docker-compose.yml'
|
|
910
2748
|
|
|
911
|
-
|
|
912
|
-
web_qa_host = get_route53_hostname("ecs-task-web-qa-notneeded")
|
|
2749
|
+
execute_command "docker-compose build web"
|
|
913
2750
|
|
|
914
|
-
[
|
|
915
|
-
|
|
2751
|
+
[ "docker-compose run -w $PWD -u root -e MIX_ENV=qa --entrypoint /bin/sh web \
|
|
2752
|
+
'-c' 'mix local.hex --force && mix hex.info && \
|
|
2753
|
+
mix deps.get && mix compile && mix deps.compile && \
|
|
2754
|
+
rm -rf _build/qa/rel/ && \
|
|
2755
|
+
mix release --env=qa'"
|
|
916
2756
|
].each do |cmd|
|
|
917
|
-
|
|
918
|
-
res = %x[ #{cmd} ]
|
|
919
|
-
if $?.exitstatus != 0
|
|
920
|
-
color = 'red'
|
|
921
|
-
else
|
|
922
|
-
color = 'green'
|
|
923
|
-
end
|
|
924
|
-
output res.send color
|
|
925
|
-
stop_if (color == 'red'), "Errore durante la build dell'artifact".red
|
|
2757
|
+
execute_command cmd
|
|
926
2758
|
end
|
|
927
2759
|
|
|
928
|
-
|
|
929
|
-
end
|
|
2760
|
+
cleanup_containers
|
|
930
2761
|
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
Dir.chdir
|
|
2762
|
+
artifact_path = Dir.glob("_build/qa/rel/urania/releases/*/urania.tar.gz").first
|
|
2763
|
+
upload_artifact(artifact_path, "microservices/urania/#{revision}-qa.tar.gz", "#{@s3_bucket}-encrypted")
|
|
2764
|
+
|
|
2765
|
+
Dir.chdir '../../'
|
|
935
2766
|
end
|
|
936
2767
|
|
|
937
|
-
def
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
2768
|
+
def deploy_pyxis?
|
|
2769
|
+
if defined? @deploy_pyxis
|
|
2770
|
+
@deploy_pyxis
|
|
2771
|
+
else
|
|
2772
|
+
pyxis_updated = `git log -p -1 --unified=0 | grep pyxis-npm:`.length > 0
|
|
942
2773
|
|
|
943
|
-
|
|
944
|
-
end
|
|
2774
|
+
update_pyxis = !@projects['pyxis-npm'].empty? && @projects['pyxis-npm'][:name] != 'master' && pyxis_updated
|
|
945
2775
|
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
sleep_seconds = 10
|
|
949
|
-
output "Attendo che lo stack #{stack_name} finisca di essere inizializzato...\n".yellow
|
|
950
|
-
while !ready
|
|
951
|
-
ready = true if stack_ready?(stack_name)
|
|
952
|
-
seconds_elapsed = 0
|
|
953
|
-
while true
|
|
954
|
-
break if seconds_elapsed >= sleep_seconds
|
|
955
|
-
print '.'.yellow; STDOUT.flush
|
|
956
|
-
sleep 1
|
|
957
|
-
seconds_elapsed += 1
|
|
958
|
-
end
|
|
2776
|
+
@deploy_pyxis = update_pyxis
|
|
2777
|
+
return update_pyxis
|
|
959
2778
|
end
|
|
2779
|
+
end
|
|
960
2780
|
|
|
961
|
-
|
|
2781
|
+
def deploy_crash?
|
|
2782
|
+
crash_present = !@projects['crash'].empty? && @projects['crash'][:name] != 'master' && !@projects['crash'][:default_branch]
|
|
2783
|
+
leftorium_present = !@projects['leftorium'].empty? && @projects['leftorium'][:name] != 'master' && !@projects['leftorium'][:default_branch]
|
|
2784
|
+
crash_present || leftorium_present
|
|
962
2785
|
end
|
|
963
2786
|
|
|
964
|
-
def
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
stacks
|
|
2787
|
+
def deploy_starsky_hutch?
|
|
2788
|
+
starsky_present = !@projects['starsky'].nil? && !@projects['starsky'].empty? && @projects['starsky'][:name] != 'master' && !@projects['starsky'][:default_branch]
|
|
2789
|
+
hutch_present = !@projects['hutch'].nil? && !@projects['hutch'].empty? && @projects['hutch'][:name] != 'master' && !@projects['hutch'][:default_branch]
|
|
2790
|
+
starsky_present || hutch_present
|
|
969
2791
|
end
|
|
970
2792
|
|
|
971
|
-
def
|
|
972
|
-
|
|
973
|
-
output "Stack #{stack_name} spenta con successo\n".green
|
|
2793
|
+
def get_pyxis_version(deploy_id)
|
|
2794
|
+
(deploy_id.delete '[a-z0]')[0..9]
|
|
974
2795
|
end
|
|
975
2796
|
|
|
976
|
-
def
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
2797
|
+
def cleanup_containers
|
|
2798
|
+
`docker-compose kill && docker-compose down -v --remove-orphans`
|
|
2799
|
+
`docker rm $(docker ps -q -f status=exited)`
|
|
2800
|
+
end
|
|
2801
|
+
|
|
2802
|
+
def git_checkout_version(project, revision)
|
|
2803
|
+
Dir.chdir "projects/#{project}"
|
|
2804
|
+
exec_step "git checkout -- . && git checkout #{revision}"
|
|
2805
|
+
Dir.chdir "../../"
|
|
981
2806
|
end
|
|
982
2807
|
|
|
983
2808
|
def create_asg_stack(stack_name, tags = [])
|
|
@@ -989,14 +2814,18 @@ class Release
|
|
|
989
2814
|
},
|
|
990
2815
|
{
|
|
991
2816
|
parameter_key: "InstanceType",
|
|
992
|
-
parameter_value: "
|
|
2817
|
+
parameter_value: "t3.large"
|
|
993
2818
|
},
|
|
994
2819
|
{
|
|
995
2820
|
parameter_key: "ECSClusterName",
|
|
996
2821
|
parameter_value: @ecs_cluster_name
|
|
2822
|
+
},
|
|
2823
|
+
{
|
|
2824
|
+
parameter_key: "AMIID",
|
|
2825
|
+
parameter_value: @ami_id
|
|
997
2826
|
}
|
|
998
2827
|
]
|
|
999
|
-
create_stack(stack_name, stack_body, parameters, tags)
|
|
2828
|
+
create_stack(stack_name, stack_body, parameters, tags, @cf_role)
|
|
1000
2829
|
end
|
|
1001
2830
|
|
|
1002
2831
|
def create_cluster_stack(stack_name, tags = [])
|
|
@@ -1004,6 +2833,47 @@ class Release
|
|
|
1004
2833
|
create_stack(stack_name, stack_body, [], tags)
|
|
1005
2834
|
end
|
|
1006
2835
|
|
|
2836
|
+
def update_cluster_stack(stack_name, tags = [])
|
|
2837
|
+
stack_body = IO.read('cloudformation/stacks/ecs-cluster.yml')
|
|
2838
|
+
update_stack(stack_name, stack_body, [], tags)
|
|
2839
|
+
end
|
|
2840
|
+
|
|
2841
|
+
def create_alb_stack(stack_name, role, hash, environment = 'qa')
|
|
2842
|
+
stack_body = IO.read('cloudformation/stacks/elb/alb-public-qa.yml')
|
|
2843
|
+
parameters = [
|
|
2844
|
+
{
|
|
2845
|
+
parameter_key: "Environment",
|
|
2846
|
+
parameter_value: environment
|
|
2847
|
+
},
|
|
2848
|
+
{
|
|
2849
|
+
parameter_key: "Role",
|
|
2850
|
+
parameter_value: role
|
|
2851
|
+
},
|
|
2852
|
+
{
|
|
2853
|
+
parameter_key: "EnvHash",
|
|
2854
|
+
parameter_value: hash
|
|
2855
|
+
}
|
|
2856
|
+
]
|
|
2857
|
+
create_stack(stack_name, stack_body, parameters, [], @cf_role)
|
|
2858
|
+
end
|
|
2859
|
+
|
|
2860
|
+
def import_redis_crash(qa_ip_address)
|
|
2861
|
+
output "Importo chiavi di Redis da staging\n".yellow
|
|
2862
|
+
|
|
2863
|
+
prefixes = ['CODICI', 'fun_with_flags']
|
|
2864
|
+
redis_qa = Redis.new(:url => "redis://#{qa_ip_address}:6379/10")
|
|
2865
|
+
redis_staging = Redis.new(:url => 'redis://staging.cache-1.prima.it:6379/10')
|
|
2866
|
+
|
|
2867
|
+
prefixes.each do |prefix|
|
|
2868
|
+
redis_staging.keys("#{prefix}*").each do |key|
|
|
2869
|
+
next unless redis_qa.keys(key).empty?
|
|
2870
|
+
output "Importo #{key} dal Redis di staging\n".yellow
|
|
2871
|
+
dump_staging = redis_staging.dump key
|
|
2872
|
+
redis_qa.restore key, 0, dump_staging
|
|
2873
|
+
end
|
|
2874
|
+
end
|
|
2875
|
+
end
|
|
2876
|
+
|
|
1007
2877
|
def import_dbs(ip_address)
|
|
1008
2878
|
resp = @ecs.run_task({
|
|
1009
2879
|
cluster: @ecs_cluster_name,
|
|
@@ -1015,7 +2885,7 @@ class Release
|
|
|
1015
2885
|
environment: [
|
|
1016
2886
|
{
|
|
1017
2887
|
name: 'EC2_IP_ADDRESS',
|
|
1018
|
-
value: ip_address
|
|
2888
|
+
value: ip_address
|
|
1019
2889
|
}
|
|
1020
2890
|
]
|
|
1021
2891
|
}
|
|
@@ -1023,14 +2893,24 @@ class Release
|
|
|
1023
2893
|
},
|
|
1024
2894
|
count: 1
|
|
1025
2895
|
})
|
|
2896
|
+
return resp
|
|
2897
|
+
end
|
|
2898
|
+
|
|
2899
|
+
def wait_for_db_import(task)
|
|
1026
2900
|
output "Attendo che i DB vengano importati...\n".yellow
|
|
1027
2901
|
stopped_at = nil
|
|
2902
|
+
sleep 15 # altrimenti non trova il task appena avviato...
|
|
1028
2903
|
while stopped_at.nil?
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
2904
|
+
if task.tasks[0].nil?
|
|
2905
|
+
pp @ecs_cluster_name
|
|
2906
|
+
pp task
|
|
2907
|
+
stop_if true, "Task di import DB lanciato, ma risposta vuota!".red
|
|
2908
|
+
end
|
|
2909
|
+
task = @ecs.describe_tasks({
|
|
2910
|
+
cluster: task.tasks[0].cluster_arn,
|
|
2911
|
+
tasks: [task.tasks[0].task_arn]
|
|
1032
2912
|
})
|
|
1033
|
-
stopped_at =
|
|
2913
|
+
stopped_at = task.tasks[0].stopped_at unless task.tasks[0].nil?
|
|
1034
2914
|
sleep_seconds = 10
|
|
1035
2915
|
seconds_elapsed = 0
|
|
1036
2916
|
while true && stopped_at.nil?
|
|
@@ -1043,69 +2923,14 @@ class Release
|
|
|
1043
2923
|
print "\n"
|
|
1044
2924
|
end
|
|
1045
2925
|
|
|
1046
|
-
def stack_exists?(stack_name)
|
|
1047
|
-
begin
|
|
1048
|
-
res = @cf.describe_stacks({
|
|
1049
|
-
stack_name: stack_name
|
|
1050
|
-
})
|
|
1051
|
-
rescue Aws::CloudFormation::Errors::ValidationError => e
|
|
1052
|
-
if e.message.include? 'does not exist'
|
|
1053
|
-
false
|
|
1054
|
-
else
|
|
1055
|
-
raise e
|
|
1056
|
-
end
|
|
1057
|
-
else
|
|
1058
|
-
true
|
|
1059
|
-
end
|
|
1060
|
-
end
|
|
1061
|
-
|
|
1062
|
-
def create_stack(stack_name, stack_body, parameters = [], tags = [])
|
|
1063
|
-
@cf.create_stack({
|
|
1064
|
-
stack_name: stack_name,
|
|
1065
|
-
template_body: stack_body,
|
|
1066
|
-
parameters: parameters,
|
|
1067
|
-
tags: tags,
|
|
1068
|
-
capabilities: ["CAPABILITY_IAM"],
|
|
1069
|
-
on_failure: "ROLLBACK"
|
|
1070
|
-
})
|
|
1071
|
-
output "La creazione dello stack #{stack_name} è stata avviata".green
|
|
1072
|
-
end
|
|
1073
|
-
|
|
1074
|
-
def update_stack(stack_name, stack_body, parameters = [])
|
|
1075
|
-
begin
|
|
1076
|
-
@cf.update_stack({
|
|
1077
|
-
stack_name: stack_name,
|
|
1078
|
-
template_body: stack_body,
|
|
1079
|
-
parameters: parameters,
|
|
1080
|
-
capabilities: ["CAPABILITY_IAM"]
|
|
1081
|
-
})
|
|
1082
|
-
rescue Aws::CloudFormation::Errors::ValidationError => e
|
|
1083
|
-
# if e.message.include? 'does not exist'
|
|
1084
|
-
# false
|
|
1085
|
-
# else
|
|
1086
|
-
# raise e
|
|
1087
|
-
# end
|
|
1088
|
-
raise e
|
|
1089
|
-
else
|
|
1090
|
-
output "L'update dello stack #{stack_name} è stato avviato".green
|
|
1091
|
-
end
|
|
1092
|
-
end
|
|
1093
|
-
|
|
1094
|
-
def artifact_exists?(bucket, path)
|
|
1095
|
-
resp = @s3.list_objects({
|
|
1096
|
-
bucket: bucket,
|
|
1097
|
-
max_keys: 1,
|
|
1098
|
-
prefix: path
|
|
1099
|
-
})
|
|
1100
|
-
!resp.contents.empty?
|
|
1101
|
-
end
|
|
1102
|
-
|
|
1103
2926
|
def choose_branch_to_deploy(project_name, select_master = false)
|
|
2927
|
+
return {} if project_name == 'crash' && select_master
|
|
1104
2928
|
Dir.chdir "projects/#{project_name}"
|
|
1105
2929
|
output "Recupero la lista dei branch del progetto #{project_name}..."
|
|
2930
|
+
`git remote prune origin`
|
|
1106
2931
|
out = %x[ git fetch ]
|
|
1107
|
-
branches = %x[ git for-each-ref --sort=-committerdate refs/remotes/ --format='%(refname) %(objectname)' | sed 's/refs\\/remotes\\/origin\\///g' ]
|
|
1108
|
-
.split("\n").delete_if { |b| b.include?('HEAD')
|
|
2932
|
+
branches = %x[ git for-each-ref --sort=-committerdate refs/remotes/ --format='%(refname) %(objectname) %(committeremail)' | sed 's/refs\\/remotes\\/origin\\///g' ]
|
|
2933
|
+
.split("\n").delete_if { |b| b.include?('HEAD') }[0..49]
|
|
1109
2934
|
|
|
1110
2935
|
master_branch = nil
|
|
1111
2936
|
|
|
@@ -1114,16 +2939,20 @@ class Release
|
|
|
1114
2939
|
break unless master_branch.nil?
|
|
1115
2940
|
end
|
|
1116
2941
|
|
|
1117
|
-
if select_master
|
|
2942
|
+
if select_master || branches.length == 1
|
|
1118
2943
|
branch_name = master_branch
|
|
1119
2944
|
else
|
|
2945
|
+
branches.insert(0, branches.delete(master_branch))
|
|
1120
2946
|
branch_name = choose do |menu|
|
|
1121
2947
|
menu.prompt = "Scegli il branch di #{project_name} da deployare: ".cyan
|
|
1122
2948
|
menu.shell = true
|
|
1123
2949
|
|
|
1124
|
-
|
|
2950
|
+
git_mail = get_git_mail
|
|
2951
|
+
|
|
2952
|
+
branches.each_with_index do |branch, index|
|
|
1125
2953
|
title = @prima.reduce_size(branch, 100)
|
|
1126
|
-
msg =
|
|
2954
|
+
msg = index.odd? ? title.white : title.light_yellow # uno bianco e uno giallo alternati
|
|
2955
|
+
msg = branch.include?(git_mail) ? msg.on_blue : msg.on_black # i branch aggiornati da chi lancia la creazione sono su sfondo blu
|
|
1127
2956
|
menu.choice(msg) { branch }
|
|
1128
2957
|
menu.default = branch if branch == master_branch
|
|
1129
2958
|
end
|
|
@@ -1132,60 +2961,145 @@ class Release
|
|
|
1132
2961
|
|
|
1133
2962
|
Dir.chdir "../../"
|
|
1134
2963
|
|
|
1135
|
-
name = branch_name.split(' ')
|
|
1136
|
-
revision = branch_name.split(' ')
|
|
1137
|
-
|
|
2964
|
+
name = branch_name.split(' ')[0]
|
|
2965
|
+
revision = branch_name.split(' ')[1]
|
|
2966
|
+
committer_email = branch_name.split(' ')[2].tr('<>', '')
|
|
2967
|
+
return { name: 'crash', default_branch: true } if project_name == 'crash' && branch_name == 'master' #rimuovere questa riga se mai nei qa servirà crash con un branch diverso da master
|
|
2968
|
+
{ name: name, revision: revision[0..14], committer: committer_email, default_branch: select_master }
|
|
1138
2969
|
end
|
|
1139
2970
|
|
|
1140
2971
|
def select_branch_to_deploy(project_name, branch_name)
|
|
1141
2972
|
Dir.chdir "projects/#{project_name}"
|
|
1142
2973
|
output "Recupero il branch #{project_name}:#{branch_name} ..."
|
|
2974
|
+
`git remote prune origin`
|
|
1143
2975
|
out = %x[ git fetch ]
|
|
1144
|
-
branch_name = %x[ git for-each-ref --sort=-committerdate refs/remotes/ --format='%(refname) %(objectname)' | sed 's/refs\\/remotes\\/origin\\///g' ]
|
|
1145
|
-
.split("\n").delete_if { |b| !b.
|
|
2976
|
+
branch_name = %x[ git for-each-ref --sort=-committerdate refs/remotes/ --format='%(refname) %(objectname) %(committeremail)' | sed 's/refs\\/remotes\\/origin\\///g' ]
|
|
2977
|
+
.split("\n").delete_if { |b| !b.match("^#{Regexp.escape(branch_name)}") }[0..49]
|
|
1146
2978
|
.first
|
|
1147
2979
|
|
|
1148
2980
|
Dir.chdir "../../"
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
{ name: name, revision: revision[0..14] }
|
|
1153
|
-
end
|
|
1154
|
-
|
|
1155
|
-
def is_branch_compatible_with_current_twig_version?
|
|
1156
|
-
File.readlines("bin/local_build_artifact.sh").grep(/DEPLOY_ID=\$4/).size > 0
|
|
2981
|
+
name = branch_name.split(' ')[0]
|
|
2982
|
+
revision = branch_name.split(' ')[1]
|
|
2983
|
+
committer_email = branch_name.split(' ')[2].tr('<>', '')
|
|
2984
|
+
{ name: name, revision: revision[0..14], committer: committer_email }
|
|
1157
2985
|
end
|
|
1158
2986
|
|
|
1159
2987
|
def get_stacks()
|
|
1160
2988
|
envs = {}
|
|
2989
|
+
stack_list = stack_list()
|
|
1161
2990
|
stack_list.each do |stack|
|
|
1162
2991
|
unless stack.stack_name.match(/spotfleet-allinone-qa-(\w+)$/)
|
|
1163
2992
|
env_hash = stack.stack_name.match(/qa-(\w+)$/)[0]
|
|
1164
|
-
envs[env_hash] = stack.tags unless envs.has_key?(env_hash)
|
|
2993
|
+
envs[env_hash] = stack.tags unless envs.has_key?(env_hash) || stack.tags.empty?
|
|
1165
2994
|
end
|
|
1166
2995
|
end
|
|
1167
2996
|
return stack_list, envs
|
|
1168
2997
|
end
|
|
1169
2998
|
|
|
1170
|
-
def
|
|
2999
|
+
def get_clusters()
|
|
3000
|
+
envs = {}
|
|
3001
|
+
cluster_list = cluster_list()
|
|
3002
|
+
cluster_list.each do |stack|
|
|
3003
|
+
unless stack.stack_name.match(/spotfleet-allinone-qa-(\w+)$/)
|
|
3004
|
+
env_hash = stack.stack_name.match(/qa-(\w+)$/)[0]
|
|
3005
|
+
envs[env_hash] = stack.tags unless envs.has_key?(env_hash) || stack.tags.empty?
|
|
3006
|
+
end
|
|
3007
|
+
end
|
|
3008
|
+
return cluster_list, envs
|
|
3009
|
+
end
|
|
3010
|
+
|
|
3011
|
+
def hostname_pattern_priority()
|
|
3012
|
+
(Time.now.to_i.to_s[-4..-1].to_i + Random.rand(40000)).to_s
|
|
3013
|
+
end
|
|
3014
|
+
|
|
3015
|
+
def launch_marley(ip_address, prima_hostname, borat_hostname)
|
|
3016
|
+
resp = @cf.describe_stack_resource({
|
|
3017
|
+
stack_name: 'batch-job-marley',
|
|
3018
|
+
logical_resource_id: 'JobDefinition'
|
|
3019
|
+
})
|
|
3020
|
+
|
|
3021
|
+
@batch.submit_job({
|
|
3022
|
+
job_name: "marley-#{@dns_record_identifier}", # required
|
|
3023
|
+
job_queue: "tools-production", # required
|
|
3024
|
+
job_definition: resp.stack_resource_detail.physical_resource_id, # required
|
|
3025
|
+
container_overrides: {
|
|
3026
|
+
environment: [
|
|
3027
|
+
{
|
|
3028
|
+
name: 'PRIMA_URL',
|
|
3029
|
+
value: "https://#{prima_hostname}/?superprima"
|
|
3030
|
+
},
|
|
3031
|
+
{
|
|
3032
|
+
name: 'PRIMA_IP',
|
|
3033
|
+
value: ip_address
|
|
3034
|
+
},
|
|
3035
|
+
{
|
|
3036
|
+
name: 'PROJECTS_JSON',
|
|
3037
|
+
value: @projects.to_json
|
|
3038
|
+
},
|
|
3039
|
+
{
|
|
3040
|
+
name: 'BACKOFFICE_URL',
|
|
3041
|
+
value: "https://#{borat_hostname}"
|
|
3042
|
+
}
|
|
3043
|
+
]
|
|
3044
|
+
}
|
|
3045
|
+
})
|
|
3046
|
+
|
|
3047
|
+
output "Marley lanciato con successo!\n".green
|
|
3048
|
+
end
|
|
3049
|
+
|
|
3050
|
+
def get_currently_deployed_version(stack_name)
|
|
3051
|
+
parameters = get_stack_parameters(stack_name)
|
|
3052
|
+
currently_deployed_version = nil
|
|
3053
|
+
parameters.each do |parameter|
|
|
3054
|
+
if parameter.parameter_key == "ReleaseVersion"
|
|
3055
|
+
currently_deployed_version = parameter.parameter_value
|
|
3056
|
+
end
|
|
3057
|
+
end
|
|
3058
|
+
currently_deployed_version
|
|
3059
|
+
end
|
|
3060
|
+
|
|
3061
|
+
def decrypt_secrets()
|
|
3062
|
+
docker_image = "prima/biscuit_populate_configs"
|
|
3063
|
+
[
|
|
3064
|
+
"docker pull #{docker_image}",
|
|
3065
|
+
"docker run -t --rm -v $HOME/.aws:/root/.aws -w $PWD --volumes-from #{get_host_container_name} #{docker_image}"
|
|
3066
|
+
].each do |cmd|
|
|
3067
|
+
execute_command cmd
|
|
3068
|
+
end
|
|
3069
|
+
end
|
|
3070
|
+
|
|
3071
|
+
def get_host_container_name()
|
|
3072
|
+
if @host_container_name
|
|
3073
|
+
@host_container_name
|
|
3074
|
+
else
|
|
3075
|
+
hostname = `cat /etc/hostname`.gsub("\n", '')
|
|
3076
|
+
execute_command "docker ps | grep #{hostname} | awk '{print $NF}'"
|
|
3077
|
+
@host_container_name = `docker ps | grep #{hostname} | awk '{print $NF}'`.gsub("\n", '')
|
|
3078
|
+
# @host_container_name = `docker ps | grep #{hostname} | sed -r "s/.+ ([^\s].+)$/\1/p"`
|
|
3079
|
+
end
|
|
3080
|
+
end
|
|
3081
|
+
|
|
3082
|
+
def select_branches(project_names = nil)
|
|
1171
3083
|
output "Deploy feature menu"
|
|
1172
|
-
if
|
|
1173
|
-
@projects[
|
|
1174
|
-
@projects["backoffice"] = choose_branch_to_deploy('backoffice')
|
|
1175
|
-
@projects["urania"] = choose_branch_to_deploy('urania')
|
|
1176
|
-
@projects["ermes"] = choose_branch_to_deploy('ermes')
|
|
1177
|
-
@projects["bburago"] = choose_branch_to_deploy('bburago')
|
|
1178
|
-
@projects["hal9000"] = choose_branch_to_deploy('hal9000')
|
|
1179
|
-
@projects["fidaty"] = choose_branch_to_deploy('fidaty')
|
|
3084
|
+
if project_names.nil?
|
|
3085
|
+
@projects.each{ |key, value| @projects[key] = choose_branch_to_deploy(key) }
|
|
1180
3086
|
else
|
|
1181
|
-
|
|
1182
|
-
|
|
3087
|
+
project_names.each do |project|
|
|
3088
|
+
@projects[project] = choose_branch_to_deploy(project)
|
|
3089
|
+
end
|
|
1183
3090
|
@projects.each_key do |branch_project|
|
|
1184
|
-
@projects[branch_project] = choose_branch_to_deploy(branch_project, true) unless branch_project
|
|
3091
|
+
@projects[branch_project] = choose_branch_to_deploy(branch_project, true) unless project_names.include? branch_project
|
|
1185
3092
|
end
|
|
1186
3093
|
end
|
|
1187
3094
|
end
|
|
1188
3095
|
|
|
3096
|
+
def get_ami_id(stack_name)
|
|
3097
|
+
get_stack_parameters(stack_name).each do |param|
|
|
3098
|
+
if param.parameter_key == "AMIID"
|
|
3099
|
+
return param.parameter_value
|
|
3100
|
+
end
|
|
3101
|
+
end
|
|
3102
|
+
end
|
|
1189
3103
|
end
|
|
1190
3104
|
|
|
1191
3105
|
def help_content
|
|
@@ -1202,15 +3116,25 @@ Synopsis
|
|
|
1202
3116
|
twig release start
|
|
1203
3117
|
twig release finish
|
|
1204
3118
|
twig release deploy
|
|
3119
|
+
twig release aggregator
|
|
1205
3120
|
|
|
1206
3121
|
Description
|
|
1207
3122
|
-----------
|
|
1208
3123
|
|
|
1209
|
-
start
|
|
1210
|
-
finish
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
3124
|
+
start creates a new feature branch
|
|
3125
|
+
finish finishes the feature by merging to dev and master
|
|
3126
|
+
qainit deploys a new environment with selected branches from every project
|
|
3127
|
+
qainit $PROJECT_NAME deploys a new environment allowing to selected a branch from the input project (everything else is master)
|
|
3128
|
+
qainit minimal prima deploys a new copy of prima project, using staging microservices and database
|
|
3129
|
+
qainit shutdown deletes a specific qa environment
|
|
3130
|
+
|
|
3131
|
+
Available only to devops (from artemide)
|
|
3132
|
+
-----------
|
|
3133
|
+
deploy deploys the feature branch to a temporary AWS Elastic Beanstalk env
|
|
3134
|
+
deploy stop destroys the AWS Elastic Beanstalk env
|
|
3135
|
+
deploy update updates a feature branch with current branches
|
|
3136
|
+
deploy lock protects a qa environment from automatic deletion
|
|
3137
|
+
aggregator enable/disable directs comparator's staging environments to a qa/staging
|
|
1214
3138
|
|
|
1215
3139
|
Subcommand for Twig: <http://rondevera.github.io/twig/>
|
|
1216
3140
|
Author: Andrea Usuelli <https://github.com/andreausu>
|
|
@@ -1225,4 +3149,11 @@ if args.include?('--help')
|
|
|
1225
3149
|
exit
|
|
1226
3150
|
end
|
|
1227
3151
|
|
|
1228
|
-
|
|
3152
|
+
gem_update = true
|
|
3153
|
+
if args.include?('no-gem-update')
|
|
3154
|
+
gem_update = false
|
|
3155
|
+
end
|
|
3156
|
+
|
|
3157
|
+
args.delete('no-gem-update')
|
|
3158
|
+
|
|
3159
|
+
Release.new(gem_update).execute!(args)
|