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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 62fed4f278257118a74f5de5caa3c7dd40e3b387
4
- data.tar.gz: d147a749c74122ae09916f049a5f55a2959546d2
3
+ metadata.gz: 2c6f5e8bfcabd20afbaf44cabda6241b916603ce
4
+ data.tar.gz: 8a6de18e1a54e47caa12d1025cd9719f1cd928ac
5
5
  SHA512:
6
- metadata.gz: 2cdd91eeadc8bef6324281617806068871c3a188b803d7e72f340d6e3a16aefb26c639c5b63e4ae0162183bcb4e2c2547dc0d26626ae6a469a30868bb0459aa0
7
- data.tar.gz: aa4ab625feac4dd5adfaf2d02319f55d2087da680aa63c7641b57c7b1293621e00a74e81603382803b771881cdbdabb088b98590c4e14cf6026663b19e8a5b7e
6
+ metadata.gz: 89befabb8377516f2b655941ebd32efa5a9c2044ebd56c70a5047eb9bc37bbec0b53227afaded76b2b9a4ce0073cd29491b26b6c5443130f2833c3a06a9fa38e
7
+ data.tar.gz: fd4f72a2f5e5a1b209531a42e127dbaf2ee8515dc21145a81ca93641a45f3b12f53128ab0afb9eba87cecba5c7b6a0407bf57fe2d1aac8aef6a50d777d588e12
@@ -96,7 +96,8 @@ module Foreplay
96
96
  threads.each { |thread| thread.join }
97
97
  end
98
98
 
99
- def deploy_to_server(server, instructions)
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 "#{name}#{INDENT}No instance is currently deployed"
125
+ puts "#{server}#{INDENT}No instance is currently deployed"
127
126
  else
128
- "#{name}#{INDENT}Current instance is using port #{current_port_string}"
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 "#{name}#{INDENT}Connecting to #{server} on port #{port}"
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 "#{name}#{INDENT}Successfully connected to #{server} on port #{port}"
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!(/^/, "#{name}#{INDENT * 2}") unless step[:silent] == true || output.blank?
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 "#{name}#{INDENT}There was a problem starting an ssh session on #{server_port}:\n#{e.message}"
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 "#{name}#{INDENT * 2}#{command}" unless step[:silent] }
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 "#{instructions[:name]}#{INDENT}#{(step[:commentary] || step[:command]).yellow}" unless step[:silent] == true
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)
@@ -1,3 +1,3 @@
1
1
  module Foreplay
2
- VERSION = '0.5.0'
2
+ VERSION = '0.5.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreplay
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Xenapto