prima-twig 0.2.18 → 0.2.19
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 +53 -29
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f76d6be32c5245924b220372482cf52dd85b613
|
4
|
+
data.tar.gz: b79aa0cd8fc006dbeb4d1d515bbf4b44c699510e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5b6085fd381a06173796a10e47238c5afec6d43d6af6f48ed62cc53ce84096b1cd60c931333ddc84cf1b2c405ca9c1c5d199a053dc180bf42fea1b9db7aceed
|
7
|
+
data.tar.gz: 8725627465a374d55c400edfaa60a453acca8357c184bda4ad35303a024788c205c2e76d3780663756b61f7523d01c2b22b8b9c073ea0c89735888ced83d81fa
|
data/bin/twig-feature
CHANGED
@@ -20,12 +20,15 @@ class Release
|
|
20
20
|
@version_label = @environment_name + '-' + @git_rev[0,5]
|
21
21
|
@user = `git config user.name`.downcase
|
22
22
|
@user = @user[0,1] + @user.split(' ').last
|
23
|
+
@artifact_path = '/tmp/prima-artifact.zip'
|
24
|
+
@ec2_key_name = "eb_#{@user}"
|
25
|
+
@ssh_key_path = "#{ENV['HOME']}/.ssh/eb_#{@user}"
|
23
26
|
end
|
24
27
|
|
25
28
|
def execute! args
|
26
29
|
possible_args = ["start", "finish", "deploy"]
|
27
30
|
stop_if args.empty?, [:wrong_args, possible_args]
|
28
|
-
stop_if args.length >
|
31
|
+
stop_if args.length > 3, [:wrong_args, possible_args]
|
29
32
|
|
30
33
|
stop_if @prima.head_detached?, :detached_head
|
31
34
|
|
@@ -38,7 +41,8 @@ class Release
|
|
38
41
|
if ['terminate', 'stop', 'shutdown', 'halt', 'destroy'].include? args[1]
|
39
42
|
deploy_shutdown!
|
40
43
|
else
|
41
|
-
|
44
|
+
ignoranza = args[1] == 'ignorante' ? true : false
|
45
|
+
deploy_feature! ignoranza
|
42
46
|
end
|
43
47
|
else
|
44
48
|
stop_if true, [:wrong_args, possible_args]
|
@@ -51,26 +55,42 @@ class Release
|
|
51
55
|
def finish_feature!
|
52
56
|
end
|
53
57
|
|
54
|
-
def deploy_feature!
|
55
|
-
app_name = 'prima-qa'
|
58
|
+
def deploy_feature!(ignoranza=false)
|
56
59
|
|
57
|
-
|
58
|
-
ec2_key_name = "eb_#{@user}"
|
59
|
-
artifact_path = '/tmp/prima-artifact.zip'
|
60
|
+
stop_if application_version_exists?(@application_name, @version_label), "La versione #{@version_label} esiste gia', ti sei ricordato di committare?".red unless ignoranza
|
60
61
|
|
61
|
-
|
62
|
-
|
63
|
-
manage_ec2_keypair(ec2_key_name, ssh_key_path)
|
62
|
+
manage_ec2_keypair(@ec2_key_name, @ssh_key_path)
|
64
63
|
|
65
64
|
build_release!
|
66
65
|
|
67
66
|
exec_step 'rsync -avd --exclude-from app/deploy/aws_docker/qa/.rsync-exclude-qa . /tmp/prima'
|
68
67
|
exec_step 'cd /tmp/prima && cp app/deploy/aws_docker/qa/Dockerrun.aws.json .'
|
69
|
-
|
70
|
-
|
68
|
+
|
69
|
+
if ignoranza
|
70
|
+
deploy_ignorante
|
71
|
+
else
|
72
|
+
deploy_serio
|
73
|
+
end
|
74
|
+
|
75
|
+
endpoint_url = get_eb_endpoint_url(@application_name, @environment_name)
|
76
|
+
output "Endpoint url: #{endpoint_url}\n".cyan
|
77
|
+
Launchy.open(endpoint_url) if @prima.yesno 'Vuoi aprirlo nel browser?'.blue
|
78
|
+
output "Deploy effettuato, everything is awesome!\n".green
|
79
|
+
end
|
80
|
+
|
81
|
+
def deploy_shutdown!
|
82
|
+
stop_unless environment_exists?(@application_name, @environment_name), "L'environment #{@environment_name} non esiste!"
|
83
|
+
shutdown_environment(@environment_name) if @prima.yesno("Sei sicuro di voler spegnere l'env?".blue)
|
84
|
+
output "L'environment #{@environment_name} e' stato disrutto con successo!\n".green
|
85
|
+
output "Potrebbe comunque passare qualche minuto prima che l'operazione finisca\n".yellow
|
86
|
+
end
|
87
|
+
|
88
|
+
def deploy_serio
|
89
|
+
exec_step "rm -f #{@artifact_path}; cd /tmp/prima && zip -ryq #{@artifact_path} ."
|
90
|
+
output "Upload dell'artifact in corso (#{(File.size(@artifact_path).to_f / 2**20).round(2)} MiB)\n".yellow
|
71
91
|
s3 = Aws::S3::Resource.new
|
72
92
|
obj = s3.bucket(@s3_bucket).object(@s3_key)
|
73
|
-
obj.upload_file(artifact_path)
|
93
|
+
obj.upload_file(@artifact_path)
|
74
94
|
|
75
95
|
output "#{@s3_bucket}/#{@s3_key} uploadato con successo!\n".green
|
76
96
|
|
@@ -105,27 +125,27 @@ class Release
|
|
105
125
|
sleep 1
|
106
126
|
seconds_elapsed += 1
|
107
127
|
end
|
108
|
-
run_commands(@environment_name, ssh_key_path)
|
128
|
+
run_commands(@environment_name, @ssh_key_path)
|
109
129
|
else
|
110
130
|
output "Environment #{@environment_name} non presente, inizio la creazione...\n".yellow
|
111
|
-
create_eb_environment(@application_name, @environment_name, @version_label, @git_rev, ec2_key_name)
|
131
|
+
create_eb_environment(@application_name, @environment_name, @version_label, @git_rev, @ec2_key_name)
|
112
132
|
output "Environment #{@environment_name} creato!\n".green
|
113
133
|
is_eb_ready = is_eb_ready?(@application_name, @environment_name)
|
114
134
|
wait_for_eb_ready(@application_name, @environment_name) unless is_eb_ready
|
115
|
-
run_commands(@environment_name, ssh_key_path)
|
135
|
+
run_commands(@environment_name, @ssh_key_path)
|
116
136
|
end
|
117
|
-
|
118
|
-
endpoint_url = get_eb_endpoint_url(@application_name, @environment_name)
|
119
|
-
output "Endpoint url: #{endpoint_url}\n".cyan
|
120
|
-
Launchy.open(endpoint_url) if @prima.yesno 'Vuoi aprirlo nel browser?'.blue
|
121
|
-
output "Deploy effettuato, everything is awesome!\n".green
|
122
137
|
end
|
123
138
|
|
124
|
-
def
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
139
|
+
def deploy_ignorante
|
140
|
+
if environment_exists?(@application_name, @environment_name)
|
141
|
+
public_ip_address = get_ec2_public_ip_address @environment_name
|
142
|
+
is_eb_ready = is_eb_ready?(@application_name, @environment_name)
|
143
|
+
wait_for_eb_ready(@application_name, @environment_name) unless is_eb_ready
|
144
|
+
exec_step "cd /tmp/prima && rsync -azd -e 'ssh -o StrictHostKeyChecking=no -i #{@ssh_key_path}' --rsync-path='sudo rsync' --exclude-from app/deploy/aws_docker/qa/.rsync-exclude-qa . ec2-user@#{public_ip_address}:/var/app/current/"
|
145
|
+
output "Deploy ignorante effettuato!".green
|
146
|
+
else
|
147
|
+
output "Non puoi fare il deploy ignorante se l'environment non esiste".red
|
148
|
+
end
|
129
149
|
end
|
130
150
|
|
131
151
|
def build_release!
|
@@ -340,18 +360,22 @@ class Release
|
|
340
360
|
output "Environment inizializzato!\n".green
|
341
361
|
end
|
342
362
|
|
343
|
-
def
|
363
|
+
def get_ec2_public_ip_address(environment_name)
|
344
364
|
instance_id = @eb.describe_environment_resources({
|
345
365
|
environment_name: environment_name,
|
346
366
|
}).environment_resources.instances[0].id
|
347
367
|
|
348
368
|
resp = @ec2.describe_instances({instance_ids: [instance_id]})
|
349
369
|
|
350
|
-
|
370
|
+
resp.reservations[0].instances[0].public_ip_address
|
371
|
+
end
|
372
|
+
|
373
|
+
def run_commands(environment_name, ssh_key_path)
|
374
|
+
public_ip_address = get_ec2_public_ip_address environment_name
|
351
375
|
|
352
376
|
output "L'IP pubblico della macchina e': #{public_ip_address}\n".cyan
|
353
377
|
|
354
|
-
base_cmd = "ssh -
|
378
|
+
base_cmd = "ssh -tt -o StrictHostKeyChecking=no -i #{ssh_key_path} ec2-user@#{public_ip_address}"
|
355
379
|
cmd = "#{base_cmd} sudo -i docker ps --filter='name=-php-' | awk '{print $1 }' | grep -v CONTAINER"
|
356
380
|
container_id = %x[ #{cmd} | grep -v 'Warning:' ].strip
|
357
381
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prima-twig
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matteo Giachino
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2015-12-
|
14
|
+
date: 2015-12-22 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: twig
|