koma 0.8.0 → 0.9.0

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: 3ae88014a1a220b9d13805154813b8974523c8b4
4
- data.tar.gz: 74fd9919c86669ca86eb4b03265f60506d2e0a9b
3
+ metadata.gz: 33a965754d80b189a101cea02a9e879803b774ab
4
+ data.tar.gz: 1808ccb3e7afa6090c289d35735c245b2040a391
5
5
  SHA512:
6
- metadata.gz: aac147c41110d1676a13ec5529ad5ffb43c11bdc5011fd4ba487a95abd09f33bbb8bdccd6959098a262f17ff4f9f43328a76be1ae13de4f19054df5196de1edd
7
- data.tar.gz: 7034dba38a96abe98cc9487b48c38ee1ed7585b5de9d5232aa98ec3f927b423bfe73c3cec30cb190e5df5f700c784653c6046acc0085b182f66947f6645ca40b
6
+ metadata.gz: 6281c8a5b558259025f43ca058ca32fa7a473cc6c32498871da4ffea6ac9dcd2b36cd95cb0cfeca2be0bcaba174dbf575895ac4844550be14bed361e0e4a9eaf
7
+ data.tar.gz: d4bc1790b1ba8c7ea700053299e1650f6bc35373d5ce89cf1c0973f913d1a093dd5e131765c34426323e8eb0ef762b68bbd86d75c43adb3bbd6ccd7ea46e6a98
data/README.md CHANGED
@@ -46,10 +46,32 @@ $ koma ssh example.com,example.jp
46
46
  }
47
47
  ```
48
48
 
49
- ### Pro Tip: Gather multiple hosts with ~/.ssh/config
49
+ ### Pro Tip: Gather multiple hosts with ssh_config
50
50
 
51
51
  ```sh
52
- $ cat ~/.ssh/config | koma ssh --key platform,platform_version
52
+ $ cat <<EOF > ssh_config_tmp
53
+ Host example_com
54
+ User k1low
55
+ Hostname example.com
56
+ PreferredAuthentications publickey
57
+ IdentityFile /path/to/example_rsa
58
+
59
+ Host example_jp
60
+ User someone
61
+ Hostname example.jp
62
+ PreferredAuthentications publickey
63
+ IdentityFile /path/to/more/example_jp_rsa
64
+ EOF
65
+
66
+ $ cat ssh_config_tmp | koma ssh
67
+ ```
68
+
69
+ ```sh
70
+ $ vagrant ssh-config | koma ssh --key cpu,kernel
71
+ ```
72
+
73
+ ```sh
74
+ $ sconb dump example.com | sconb restore | koma ssh --key platform,platform_version
53
75
  ```
54
76
 
55
77
  ## Host inventory keys
data/koma.gemspec CHANGED
@@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.add_runtime_dependency 'highline'
24
24
  spec.add_runtime_dependency 'specinfra', '~> 2.48'
25
25
  spec.add_runtime_dependency 'parallel'
26
+ spec.add_runtime_dependency 'sconb', '~> 1.2'
26
27
  spec.add_development_dependency 'bundler', '~> 1.9'
27
28
  spec.add_development_dependency 'rake', '~> 10.0'
28
29
  spec.add_development_dependency 'rspec'
@@ -1,8 +1,11 @@
1
1
  require 'parallel'
2
+ require 'sconb'
2
3
 
3
4
  module Koma
4
5
  module Backend
5
6
  class Ssh < Base
7
+ attr_accessor :stdin
8
+
6
9
  def gather
7
10
  if host.include?(',')
8
11
  list = host.split(',').uniq
@@ -22,10 +25,16 @@ module Koma
22
25
  set :backend, :ssh
23
26
  set :host, host
24
27
  set :request_pty, true
25
- ssh_options = Net::SSH::Config.for(host)
26
- ssh_options[:user] = user if user
27
- ssh_options[:keys] = [options[:identity_file]] if options[:identity_file]
28
- ssh_options[:port] = options[:port] if options[:port]
28
+ if stdin
29
+ parsed = Sconb::SSHConfig.parse(stdin, host, {})
30
+ ssh_options = Net::SSH::Config.translate(Hash[parsed[host].map { |k, v| [k.downcase, v] }])
31
+ else
32
+ ssh_options = Net::SSH::Config.for(host)
33
+ ssh_options[:user] = user if user
34
+ ssh_options[:keys] = [options[:identity_file]] if options[:identity_file]
35
+ ssh_options[:port] = options[:port] if options[:port]
36
+ end
37
+
29
38
  set :ssh_options, ssh_options
30
39
  out(options[:key])
31
40
  end
data/lib/koma/cli.rb CHANGED
@@ -35,6 +35,7 @@ module Koma
35
35
  stdin = timeout(5) do
36
36
  $stdin.read
37
37
  end
38
+
38
39
  rescue Timeout::Error
39
40
  STDERR.puts 'ERROR: "koma ssh" was called with no arguments'
40
41
  STDERR.puts 'Usage: "koma ssh <host1,host2,..>"'
@@ -47,6 +48,7 @@ module Koma
47
48
  host = ret.join(',')
48
49
  end
49
50
  backend = Koma::Backend::Ssh.new(host, options)
51
+ backend.stdin = stdin if stdin
50
52
  if options[:yaml]
51
53
  puts YAML.dump(backend.gather)
52
54
  else
data/lib/koma/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Koma
2
- VERSION = '0.8.0'
2
+ VERSION = '0.9.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: koma
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - k1LoW
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-04-25 00:00:00.000000000 Z
11
+ date: 2016-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: sconb
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.2'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.2'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: bundler
71
85
  requirement: !ruby/object:Gem::Requirement