foreplay 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/foreplay/deploy.rb +17 -21
- data/lib/foreplay/version.rb +1 -1
- 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: 2c6f5e8bfcabd20afbaf44cabda6241b916603ce
|
4
|
+
data.tar.gz: 8a6de18e1a54e47caa12d1025cd9719f1cd928ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89befabb8377516f2b655941ebd32efa5a9c2044ebd56c70a5047eb9bc37bbec0b53227afaded76b2b9a4ce0073cd29491b26b6c5443130f2833c3a06a9fa38e
|
7
|
+
data.tar.gz: fd4f72a2f5e5a1b209531a42e127dbaf2ee8515dc21145a81ca93641a45f3b12f53128ab0afb9eba87cecba5c7b6a0407bf57fe2d1aac8aef6a50d777d588e12
|
data/lib/foreplay/deploy.rb
CHANGED
@@ -96,7 +96,8 @@ module Foreplay
|
|
96
96
|
threads.each { |thread| thread.join }
|
97
97
|
end
|
98
98
|
|
99
|
-
def deploy_to_server(
|
99
|
+
def deploy_to_server(server_port, instructions)
|
100
|
+
server, _ = server_port.split(':') # Parse server + port
|
100
101
|
name = instructions[:name]
|
101
102
|
role = instructions[:role]
|
102
103
|
path = instructions[:path]
|
@@ -106,8 +107,6 @@ module Foreplay
|
|
106
107
|
port = instructions[:port]
|
107
108
|
preposition = mode == :deploy ? 'to' : 'for'
|
108
109
|
|
109
|
-
instructions[:server] = server
|
110
|
-
|
111
110
|
message = "#{mode.capitalize}ing #{name.yellow} #{preposition} #{server.yellow} "
|
112
111
|
message += "for the #{role.dup.yellow} role in the #{environment.dup.yellow} environment"
|
113
112
|
puts message
|
@@ -120,12 +119,12 @@ module Foreplay
|
|
120
119
|
current_port_file = ".foreplay/#{name}/current_port"
|
121
120
|
steps = [{ command: "mkdir -p .foreplay/#{name} && touch #{current_port_file} && cat #{current_port_file}", silent: true }]
|
122
121
|
|
123
|
-
current_port_string = execute_on_server(steps, instructions).strip!
|
122
|
+
current_port_string = execute_on_server(server_port, steps, instructions).strip!
|
124
123
|
|
125
124
|
if current_port_string.blank?
|
126
|
-
puts "#{
|
125
|
+
puts "#{server}#{INDENT}No instance is currently deployed"
|
127
126
|
else
|
128
|
-
"#{
|
127
|
+
"#{server}#{INDENT}Current instance is using port #{current_port_string}"
|
129
128
|
end
|
130
129
|
|
131
130
|
current_port = current_port_string.to_i
|
@@ -228,12 +227,10 @@ module Foreplay
|
|
228
227
|
ignore_error: true }
|
229
228
|
]
|
230
229
|
|
231
|
-
execute_on_server steps, instructions
|
230
|
+
execute_on_server server_port, steps, instructions
|
232
231
|
end
|
233
232
|
|
234
|
-
def execute_on_server(steps, instructions)
|
235
|
-
name = instructions[:name]
|
236
|
-
server_port = instructions[:server]
|
233
|
+
def execute_on_server(server_port, steps, instructions)
|
237
234
|
user = instructions[:user]
|
238
235
|
password = instructions[:password]
|
239
236
|
keyfile = instructions[:keyfile]
|
@@ -241,8 +238,7 @@ module Foreplay
|
|
241
238
|
|
242
239
|
keyfile.sub! '~', ENV['HOME'] || '/' unless keyfile.blank? # Remote shell won't expand this for us
|
243
240
|
|
244
|
-
# Parse server + port
|
245
|
-
server, port = server_port.split(':')
|
241
|
+
server, port = server_port.split(':') # Parse server + port
|
246
242
|
port ||= 22
|
247
243
|
|
248
244
|
# SSH authentication methods
|
@@ -270,19 +266,19 @@ module Foreplay
|
|
270
266
|
output = ''
|
271
267
|
|
272
268
|
if mode == :deploy
|
273
|
-
puts "#{
|
269
|
+
puts "#{server}#{INDENT}Connecting to #{server} on port #{port}"
|
274
270
|
|
275
271
|
# SSH connection
|
276
272
|
begin
|
277
273
|
Net::SSH.start(server, user, options) do |session|
|
278
|
-
puts "#{
|
274
|
+
puts "#{server}#{INDENT}Successfully connected to #{server} on port #{port}"
|
279
275
|
|
280
276
|
session.shell do |sh|
|
281
277
|
steps.each do |step|
|
282
278
|
# Output from this step
|
283
279
|
output = ''
|
284
280
|
previous = '' # We don't need or want the final CRLF
|
285
|
-
commands = build_step step, instructions
|
281
|
+
commands = build_step server, step, instructions
|
286
282
|
|
287
283
|
commands.each do |command|
|
288
284
|
process = sh.execute command
|
@@ -295,7 +291,7 @@ module Foreplay
|
|
295
291
|
sh.wait!
|
296
292
|
|
297
293
|
if step[:ignore_error] == true || process.exit_status == 0
|
298
|
-
print output.gsub!(/^/, "#{
|
294
|
+
print output.gsub!(/^/, "#{server}#{INDENT * 2}") unless step[:silent] == true || output.blank?
|
299
295
|
else
|
300
296
|
terminate(output)
|
301
297
|
end
|
@@ -304,22 +300,22 @@ module Foreplay
|
|
304
300
|
end
|
305
301
|
end
|
306
302
|
rescue SocketError => e
|
307
|
-
terminate "#{
|
303
|
+
terminate "#{server}#{INDENT}There was a problem starting an ssh session on #{server_port}:\n#{e.message}"
|
308
304
|
end
|
309
305
|
else
|
310
306
|
# Deployment check: just say what we would have done
|
311
307
|
steps.each do |step|
|
312
|
-
commands = build_step step, instructions
|
308
|
+
commands = build_step server, step, instructions
|
313
309
|
|
314
|
-
commands.each { |command| puts "#{
|
310
|
+
commands.each { |command| puts "#{server}#{INDENT * 2}#{command}" unless step[:silent] }
|
315
311
|
end
|
316
312
|
end
|
317
313
|
|
318
314
|
output
|
319
315
|
end
|
320
316
|
|
321
|
-
def build_step(step, instructions)
|
322
|
-
puts "#{
|
317
|
+
def build_step(server, step, instructions)
|
318
|
+
puts "#{server}#{INDENT}#{(step[:commentary] || step[:command]).yellow}" unless step[:silent] == true
|
323
319
|
|
324
320
|
# Each step can be (1) a command or (2) a series of values to add to a file
|
325
321
|
if step.key?(:key)
|
data/lib/foreplay/version.rb
CHANGED