blower 4.4 → 4.5

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: 3c6367491fa2a0b915044247edee33154deb5868
4
- data.tar.gz: dd912a9d63a01284959b004aa9b3939a4c33a604
3
+ metadata.gz: 72aaddf083b8cb10bb0b1b564a0f76af7c44d711
4
+ data.tar.gz: '013882caa7d9b709f5c1d3097d6aa5eb7192d700'
5
5
  SHA512:
6
- metadata.gz: 91a4979929ad2f8e36b6ee0a1c0ff92bbc7b75abbd8033d07fa2e9aeb5d6068aae4ab02360c33116d330dde7e20e087e34885582b4b753edb5b315e110538b69
7
- data.tar.gz: 8324bbf1b404b50d6a922e5c60d75fbf63d2b49ab4dd517ffdeabaa5c9a60cb6d750692fbe2dcdb067e1fabb1ecd1938343c9dae30b88343151cc9f9e395b01e
6
+ metadata.gz: d703c6084adc479cd8658b46b195cf55bfb68a61d9ca39659981bb6324242b13c09598955ec2492fac0fd9a985b012fee665f0368de45a8c39026ff198e0113a
7
+ data.tar.gz: 59d9093e0d975bc95d469fb78be17d233fef8c3c6f376ae628ed56b7555b43fba8a65201ee033d85062a8793d834fb00f06f7eaf1064be942125b7232930fcef
@@ -273,9 +273,16 @@ module Blower
273
273
  end.join("\n")
274
274
  end
275
275
 
276
+ def values_map!
277
+ each do |host, data|
278
+ self[host] = yield(host, data)
279
+ end
280
+ self
281
+ end
282
+
276
283
  def stash (key)
277
284
  each do |host, data|
278
- host[key] = data.strip
285
+ host[key] = data.strip if data
279
286
  end
280
287
  end
281
288
 
@@ -289,19 +296,33 @@ module Blower
289
296
  end
290
297
  end
291
298
 
292
- def each (hosts = self.hosts)
299
+ def on_each (hosts = self.hosts, serial: true)
300
+ each(hosts, serial: serial) do |host|
301
+ on host do
302
+ yield host
303
+ end
304
+ end
305
+ end
306
+
307
+ def each (hosts = self.hosts, serial: false)
293
308
  fail "No hosts" if hosts.empty?
294
- threads = [hosts].flatten.map do |host|
295
- Thread.new do
296
- begin
297
- yield host
298
- rescue => e
299
- host.log.error e.message
300
- hosts.delete host
309
+ if serial
310
+ [hosts].flatten.each do |host|
311
+ yield host
312
+ end
313
+ else
314
+ threads = [hosts].flatten.map do |host|
315
+ Thread.new do
316
+ begin
317
+ yield host
318
+ rescue => e
319
+ host.log.error e.message
320
+ hosts.delete host
321
+ end
301
322
  end
302
323
  end
324
+ threads.each(&:join)
303
325
  end
304
- threads.each(&:join)
305
326
  fail "No hosts remaining" if hosts.empty?
306
327
  end
307
328
 
data/lib/blower/host.rb CHANGED
@@ -3,6 +3,7 @@ require 'net/ssh/gateway'
3
3
  require 'net/scp'
4
4
  require 'monitor'
5
5
  require 'colorize'
6
+ require 'base64'
6
7
  require 'timeout'
7
8
 
8
9
  module Blower
@@ -81,7 +82,7 @@ module Blower
81
82
  end
82
83
  end
83
84
  elsif from.respond_to?(:read)
84
- cmd = "echo #{from.read.shellescape} > #{to.shellescape}"
85
+ cmd = "echo #{Base64.strict_encode64(from.read).shellescape} | base64 -d > #{to.shellescape}"
85
86
  sh cmd, quiet: quiet
86
87
  else
87
88
  fail "Don't know how to copy a #{from.class}: #{from}"
@@ -100,7 +101,7 @@ module Blower
100
101
  # Read a host file.
101
102
  # @api private
102
103
  def read (filename, as: nil, quiet: false)
103
- sh "cat #{filename.shellescape}", as: as, quiet: quiet
104
+ Base64.decode64 sh("cat #{filename.shellescape} | base64", as: as, quiet: quiet)
104
105
  end
105
106
 
106
107
  # Execute a command on the host and return its output.
@@ -113,7 +114,7 @@ module Blower
113
114
  result = nil
114
115
  ch = ssh(as).open_channel do |ch|
115
116
  ch.request_pty do |ch, success|
116
- "failed to acquire pty" unless success unless success
117
+ "failed to acquire pty" unless success
117
118
  ch.exec(command) do |_, success|
118
119
  fail "failed to execute command" unless success
119
120
  ch.on_data do |_, data|
@@ -1,3 +1,3 @@
1
1
  module Blower
2
- VERSION = "4.4"
2
+ VERSION = "4.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blower
3
3
  version: !ruby/object:Gem::Version
4
- version: '4.4'
4
+ version: '4.5'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Baum
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-28 00:00:00.000000000 Z
11
+ date: 2016-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-ssh
@@ -116,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
116
  version: '0'
117
117
  requirements: []
118
118
  rubyforge_project:
119
- rubygems_version: 2.5.1
119
+ rubygems_version: 2.5.2
120
120
  signing_key:
121
121
  specification_version: 4
122
122
  summary: Really simple server orchestration