rutty 1.0.1 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. data/README.md +1 -0
  2. data/VERSION +1 -1
  3. data/bin/rutty +38 -9
  4. data/rutty.gemspec +1 -1
  5. metadata +3 -3
data/README.md CHANGED
@@ -28,6 +28,7 @@ TODO
28
28
  * Implement delete_node command
29
29
  * Make better printouts
30
30
  * Documentation
31
+ * Tests
31
32
 
32
33
  Copyright
33
34
  ---------
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.1
1
+ 1.1.2
data/bin/rutty CHANGED
@@ -4,7 +4,7 @@
4
4
  CONF_DIR = File.join(ENV['HOME'], '.rutty')
5
5
  GENERAL_CONF = File.join(CONF_DIR, 'defaults.yaml')
6
6
  NODES_CONF = File.join(CONF_DIR, 'nodes.yaml')
7
-
7
+
8
8
  # Gems
9
9
  require 'rubygems'
10
10
  require 'bundler/setup'
@@ -65,10 +65,21 @@ def options_for_node node
65
65
  hash
66
66
  end
67
67
 
68
+ def get_version
69
+ Gem.path.each do |path|
70
+ file = Dir.glob(File.join(path, 'gems', 'rutty-*', 'VERSION')).sort
71
+ next if file.empty?
72
+
73
+ return File.open(file.pop, 'r').read.chomp
74
+ end
75
+
76
+ return false
77
+ end
78
+
68
79
  # Commander config
69
80
  program :name, 'rutty'
70
81
  program :description, 'A DSH implementation in Ruby'
71
- program :version, '1.0.0'
82
+ program :version, get_version
72
83
  program :help_formatter, Commander::HelpFormatter::TerminalCompact
73
84
 
74
85
  default_command :dsh
@@ -180,10 +191,11 @@ command :dsh do |c|
180
191
 
181
192
  c.option('--tags TAG1[,TAG2,...]', Array, 'Comma-separated list of tags to run the command on')
182
193
  c.option('-a', 'Run the command on ALL nodes')
194
+ c.option('-d', '--debug', 'Enable debug output')
183
195
 
184
196
  c.when_called do |args, options|
185
197
  # TODO: Clean this up, it's pretty hard to read and follow
186
-
198
+
187
199
  check_installed!
188
200
  raise "Must supply a command to run. See `rutty help dsh' for usage" if args.empty?
189
201
  raise "One of -a or --tags must be passed" if options.a.nil? and options.tags.nil?
@@ -237,9 +249,18 @@ command :dsh do |c|
237
249
  nodes.each do |node|
238
250
  params = options_for_node(node)
239
251
  @returns[node[:host]] = { :out => '' }
240
- connections << Net::SSH.start(params[:host], params[:user], :port => params[:port], :paranoid => false,
241
- :user_known_hosts_file => '/dev/null', :keys => [params[:keypath]], :logger => Logger.new($stderr),
242
- :verbose => Logger::FATAL)
252
+ begin
253
+ connections << Net::SSH.start(params[:host], params[:user], :port => params[:port], :paranoid => false,
254
+ :user_known_hosts_file => '/dev/null', :keys => [params[:keypath]],
255
+ :logger => Logger.new(options.debug.nil? ? $stderr : $stdout),
256
+ :verbose => (options.debug.nil? ? Logger::FATAL : Logger::DEBUG))
257
+ rescue Errno::ECONNREFUSED
258
+ $stderr.puts "ERROR: Connection refused on #{node[:host]}"
259
+ @returns.delete node[:host]
260
+ rescue SocketError
261
+ $stderr.puts "ERROR: nodename nor servname provided, or not known for #{node[:host]}"
262
+ @returns.delete node[:host]
263
+ end
243
264
  end
244
265
 
245
266
  connections.each { |ssh| exec_command.call(ssh) }
@@ -263,6 +284,7 @@ command :scp do |c|
263
284
 
264
285
  c.option('--tags TAG1[,TAG2,...]', Array, 'Comma-separated list of tags to run the command on')
265
286
  c.option('-a', 'Run the command on ALL nodes')
287
+ c.option('-d', '--debug', 'Enable debug output')
266
288
 
267
289
  c.when_called do |args, options|
268
290
  check_installed!
@@ -284,9 +306,16 @@ command :scp do |c|
284
306
 
285
307
  nodes.each do |node|
286
308
  params = options_for_node(node)
287
- connections << Net::SSH.start(params[:host], params[:user], :port => params[:port], :paranoid => false,
288
- :user_known_hosts_file => '/dev/null', :keys => [params[:keypath]], :logger => Logger.new($stderr),
289
- :verbose => Logger::FATAL)
309
+ begin
310
+ connections << Net::SSH.start(params[:host], params[:user], :port => params[:port], :paranoid => false,
311
+ :user_known_hosts_file => '/dev/null', :keys => [params[:keypath]],
312
+ :logger => Logger.new(options.debug.nil? ? $stderr : $stdout),
313
+ :verbose => (options.debug.nil? ? Logger::FATAL : Logger::DEBUG))
314
+ rescue Errno::ECONNREFUSED
315
+ $stderr.puts "ERROR: Connection refused on #{node[:host]}"
316
+ rescue SocketError
317
+ $stderr.puts "ERROR: nodename nor servname provided, or not known for #{node[:host]}"
318
+ end
290
319
  end
291
320
 
292
321
  connections.each { |ssh| ssh.scp.upload! local_path, remote_path }
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rutty}
8
- s.version = "1.0.1"
8
+ s.version = "1.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Josh Lindsey"]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rutty
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
- - 0
9
8
  - 1
10
- version: 1.0.1
9
+ - 2
10
+ version: 1.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Josh Lindsey