prima-twig 0.3.9 → 0.3.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/twig-feature +70 -14
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ed110c96e11b9841ce6a6c9b7930480367e67d8
|
4
|
+
data.tar.gz: a6afcc8d40e1ac6e506d73a83939b004d6eee5e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c81cd417c6122f8b181cfe44b67f5897f584cb7d676c11fd8ed94d960c12988c54abee1b8ace62ec10c0c7f29119ddb8f85742f115b1347a3f3ab5b9f9f8883
|
7
|
+
data.tar.gz: 2690a5366673fee0ed291de1fe998c17923f51b854da575d6375d60815126a82ee09fe662feb8c1cbf5d25a667bbd1310bb8d19c98b72885ef28f482aa4b6957
|
data/bin/twig-feature
CHANGED
@@ -24,6 +24,7 @@ class Release
|
|
24
24
|
@prima_built = false
|
25
25
|
@urania_built = false
|
26
26
|
@backoffice_built = false
|
27
|
+
@dns_record_identifier = nil
|
27
28
|
end
|
28
29
|
|
29
30
|
def execute! args
|
@@ -104,6 +105,7 @@ class Release
|
|
104
105
|
end
|
105
106
|
|
106
107
|
def deploy_feature!
|
108
|
+
`sudo true` # cosi' non chiede la password dopo
|
107
109
|
`git pull`
|
108
110
|
prima_branch = choose_branch_to_deploy('prima')
|
109
111
|
backoffice_branch = choose_branch_to_deploy('backoffice')
|
@@ -111,6 +113,8 @@ class Release
|
|
111
113
|
socket_branch = {name: "master"}
|
112
114
|
pamela_branch = {name: "master"}
|
113
115
|
|
116
|
+
@dns_record_identifier = "#{@prima.clean_branch_name(prima_branch[:name])}-#{@prima.clean_branch_name(backoffice_branch[:name])}-#{@prima.clean_branch_name(urania_branch[:name])}"
|
117
|
+
|
114
118
|
tags = [
|
115
119
|
{
|
116
120
|
key: "prima",
|
@@ -143,10 +147,11 @@ class Release
|
|
143
147
|
|
144
148
|
create_prima_artifact(prima_branch[:revision]) unless artifact_exists?('prima-artifacts', "prima/#{prima_branch[:revision]}")
|
145
149
|
create_urania_artifact(urania_branch[:revision]) unless artifact_exists?('prima-artifacts', "microservices/urania/#{urania_branch[:revision]}-qa.tar.gz")
|
150
|
+
create_backoffice_artifact(backoffice_branch[:revision], deploy_id) unless artifact_exists?('prima-artifacts', "backoffice/#{backoffice_branch[:revision]}-#{deploy_id}.zip")
|
146
151
|
|
147
152
|
wait_for_stack_ready(stack_name_db) unless stack_ready?(stack_name_db)
|
148
153
|
|
149
|
-
import_dbs unless stack_exists?("ecs-task-web-qa-#{deploy_id}")
|
154
|
+
import_dbs(ec2_ip_address(asg_stack_name)) unless stack_exists?("ecs-task-web-qa-#{deploy_id}")
|
150
155
|
|
151
156
|
stack_name_web = "ecs-task-web-qa-#{deploy_id}"
|
152
157
|
git_checkout_version('prima', prima_branch[:revision])
|
@@ -213,8 +218,6 @@ class Release
|
|
213
218
|
create_stack(stack_name_urania, stack_body, parameters, tags)
|
214
219
|
end
|
215
220
|
|
216
|
-
# Dev'essere fatto qua perche' dipende dall'url di web
|
217
|
-
create_backoffice_artifact(backoffice_branch[:revision], deploy_id) unless artifact_exists?('prima-artifacts', "backoffice/#{backoffice_branch[:revision]}-#{deploy_id}.zip")
|
218
221
|
git_checkout_version('backoffice', backoffice_branch[:revision])
|
219
222
|
stack_name_backoffice = "ecs-task-backoffice-qa-#{deploy_id}"
|
220
223
|
stack_body = IO.read('projects/backoffice/deploy/task.json')
|
@@ -248,17 +251,53 @@ class Release
|
|
248
251
|
update_service_defaults(stack_name_urania)
|
249
252
|
update_service_defaults(stack_name_backoffice)
|
250
253
|
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
+
stack_name_route53 = "ecs-route53-qa-#{deploy_id}"
|
255
|
+
stack_body = IO.read('cloudformation/stacks/route53/qa.json')
|
256
|
+
parameters = [
|
257
|
+
{
|
258
|
+
parameter_key: "DnsRecordIdentifier",
|
259
|
+
parameter_value: @dns_record_identifier
|
260
|
+
},
|
261
|
+
{
|
262
|
+
parameter_key: "PrimaElbHostname",
|
263
|
+
parameter_value: get_elb_host(stack_name_web)
|
264
|
+
},
|
265
|
+
{
|
266
|
+
parameter_key: "BackofficeElbHostname",
|
267
|
+
parameter_value: get_elb_host(stack_name_backoffice)
|
268
|
+
},
|
269
|
+
{
|
270
|
+
parameter_key: "UraniaElbHostname",
|
271
|
+
parameter_value: get_elb_host(stack_name_urania)
|
272
|
+
}
|
273
|
+
]
|
274
|
+
create_stack(stack_name_route53, stack_body, parameters, tags) unless stack_exists?(stack_name_route53)
|
275
|
+
|
276
|
+
prima_hostname = get_route53_hostname(stack_name_web)
|
277
|
+
urania_hostname = get_route53_hostname(stack_name_urania)
|
278
|
+
backoffice_hostname = get_route53_hostname(stack_name_backoffice)
|
279
|
+
|
280
|
+
wait_for_stack_ready(stack_name_route53) unless stack_ready?(stack_name_route53)
|
254
281
|
|
255
|
-
output "Prima url: #{
|
256
|
-
output "Urania url: #{
|
257
|
-
output "Backoffice url: #{
|
282
|
+
output "Prima url: #{prima_hostname}\n".cyan
|
283
|
+
output "Urania url: #{urania_hostname}\n".cyan
|
284
|
+
output "Backoffice url: #{backoffice_hostname}\n".cyan
|
258
285
|
output "SSH connection: ssh ec2-user@#{ec2_ip_address(asg_stack_name)} -i ~/.ssh/ecs-cluster-qa.pem".cyan
|
259
286
|
output "Deploy effettuato, everything is awesome!\n".green
|
260
287
|
end
|
261
288
|
|
289
|
+
def get_route53_hostname(stack_name)
|
290
|
+
case
|
291
|
+
when stack_name.include?('web')
|
292
|
+
host = "www.#{@dns_record_identifier}.qa.colaster.com"
|
293
|
+
when stack_name.include?('urania')
|
294
|
+
host = "urania.#{@dns_record_identifier}.qa.colaster.com"
|
295
|
+
when stack_name.include?('backoffice')
|
296
|
+
host = "backoffice.#{@dns_record_identifier}.qa.colaster.com"
|
297
|
+
end
|
298
|
+
host
|
299
|
+
end
|
300
|
+
|
262
301
|
def ec2_ip_address(asg_stack_name)
|
263
302
|
resp = @cf.describe_stack_resource({
|
264
303
|
stack_name: asg_stack_name,
|
@@ -273,7 +312,7 @@ class Release
|
|
273
312
|
resp.reservations[0].instances[0].private_ip_address
|
274
313
|
end
|
275
314
|
|
276
|
-
def
|
315
|
+
def get_elb_host(stack_name)
|
277
316
|
case
|
278
317
|
when stack_name.include?('web')
|
279
318
|
logical_resource_id = 'EcsElasticLoadBalancerPublic'
|
@@ -368,9 +407,8 @@ class Release
|
|
368
407
|
end
|
369
408
|
end
|
370
409
|
|
371
|
-
stack_name_web = "ecs-task-web-qa
|
372
|
-
|
373
|
-
web_qa_host = get_elb_url(stack_name_web)
|
410
|
+
stack_name_web = "ecs-task-web-qa-notneeded"
|
411
|
+
web_qa_host = get_route53_hostname(stack_name_web)
|
374
412
|
|
375
413
|
[
|
376
414
|
"docker-compose build workers",
|
@@ -412,10 +450,14 @@ class Release
|
|
412
450
|
end
|
413
451
|
end
|
414
452
|
|
453
|
+
stack_name_backoffice = "ecs-task-backoffice-qa-notneeded"
|
454
|
+
backoffice_qa_host = get_route53_hostname(stack_name_backoffice)
|
455
|
+
|
415
456
|
base_cmd = 'docker run -v $PWD:/code -w /code --link redis:redis prima_'
|
416
457
|
[
|
417
458
|
"docker-compose build web php",
|
418
459
|
"docker run -d --name redis redis:2.8",
|
460
|
+
"#{base_cmd}web 'bash' '-c' 'sed -i \"s/replaceme.qa.staging.colaster.com/#{backoffice_qa_host}/g\" app/config/config_qa.yml'",
|
419
461
|
"cd ../../ && docker run -e GIT_DIR=$PWD -v $PWD:/usr/app/src -w /usr/app/src/projects/prima blinkmobile/bower install --allow-root",
|
420
462
|
"#{base_cmd}web composer install -n",
|
421
463
|
"#{base_cmd}web npm install",
|
@@ -438,6 +480,7 @@ class Release
|
|
438
480
|
color = 'green'
|
439
481
|
end
|
440
482
|
output res.send color
|
483
|
+
exec_step "docker kill redis && docker rm redis" if color == 'red'
|
441
484
|
stop_if (color == 'red'), "Errore durante la build dell'artifact".red
|
442
485
|
end
|
443
486
|
|
@@ -516,10 +559,23 @@ class Release
|
|
516
559
|
create_stack(stack_name, stack_body, parameters, tags)
|
517
560
|
end
|
518
561
|
|
519
|
-
def import_dbs
|
562
|
+
def import_dbs(ip_address)
|
520
563
|
resp = @ecs.run_task({
|
521
564
|
cluster: @qa_cluster,
|
522
565
|
task_definition: @import_db_task,
|
566
|
+
overrides: {
|
567
|
+
container_overrides: [
|
568
|
+
{
|
569
|
+
name: 'dbrestore',
|
570
|
+
environment: [
|
571
|
+
{
|
572
|
+
name: 'Ec2IpAddress',
|
573
|
+
value: ip_address,
|
574
|
+
}
|
575
|
+
]
|
576
|
+
}
|
577
|
+
]
|
578
|
+
},
|
523
579
|
count: 1
|
524
580
|
})
|
525
581
|
output "Attendo che i DB vengano importati...\n".yellow
|