train 0.21.1 → 0.22.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -2
- data/Gemfile +1 -0
- data/README.md +7 -0
- data/lib/train/extras/os_common.rb +8 -2
- data/lib/train/extras/os_detect_openvms.rb +29 -0
- data/lib/train/transports/ssh.rb +22 -6
- data/lib/train/transports/ssh_connection.rb +1 -1
- data/lib/train/version.rb +1 -1
- data/test/unit/transports/ssh_test.rb +23 -3
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc2d4b48426cfdbf820116b76d6b1d0d4d5336b0
|
4
|
+
data.tar.gz: 509cdb12eac96f85cfdc04daf255bd59e1e2dbbd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46724f6d5f90556e90854488b0eb28736a93f6daacf86389ee2cb45f120c9699c983428d317831ee61cb1e829ec8b49d75883562e0e65548883cee33eec8cc8e
|
7
|
+
data.tar.gz: 7097d55714e3c2e36d1bec6bf169a72a8d84c2a138bfc5012d914059d2487499a1f086f8e4c1f4d2ccc5165b4d83847ca8010459a5fa45ba056dbcc2616d9c69
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,18 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
-
## [0.
|
4
|
-
[Full Changelog](https://github.com/chef/train/compare/v0.21.
|
3
|
+
## [0.22.0](https://github.com/chef/train/tree/0.22.0) (2016-11-29)
|
4
|
+
[Full Changelog](https://github.com/chef/train/compare/v0.21.1...0.22.0)
|
5
|
+
|
6
|
+
**Implemented enhancements:**
|
7
|
+
|
8
|
+
- Try to use ssh agent if no password or key files have been specified [\#165](https://github.com/chef/train/pull/165) ([alexpop](https://github.com/alexpop))
|
9
|
+
|
10
|
+
**Merged pull requests:**
|
11
|
+
|
12
|
+
- Add openvms detection [\#159](https://github.com/chef/train/pull/159) ([briandoodyie](https://github.com/briandoodyie))
|
13
|
+
|
14
|
+
## [v0.21.1](https://github.com/chef/train/tree/v0.21.1) (2016-11-04)
|
15
|
+
[Full Changelog](https://github.com/chef/train/compare/v0.21.0...v0.21.1)
|
5
16
|
|
6
17
|
**Closed issues:**
|
7
18
|
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -39,6 +39,13 @@ train = Train.create('ssh',
|
|
39
39
|
host: '1.2.3.4', port: 22, user: 'root', key_files: '/vagrant')
|
40
40
|
```
|
41
41
|
|
42
|
+
If you don't specify the `key_files` and `password` options, SSH agent authentication will be attempted. For example:
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
require 'train'
|
46
|
+
train = Train.create('ssh', host: '1.2.3.4', port: 22, user: 'root')
|
47
|
+
```
|
48
|
+
|
42
49
|
**WinRM**
|
43
50
|
|
44
51
|
```ruby
|
@@ -14,6 +14,7 @@ require 'train/extras/os_detect_unix'
|
|
14
14
|
require 'train/extras/os_detect_windows'
|
15
15
|
require 'train/extras/os_detect_esx'
|
16
16
|
require 'train/extras/os_detect_arista_eos'
|
17
|
+
require 'train/extras/os_detect_openvms'
|
17
18
|
|
18
19
|
module Train::Extras
|
19
20
|
class OSCommon
|
@@ -23,6 +24,7 @@ module Train::Extras
|
|
23
24
|
include Train::Extras::DetectWindows
|
24
25
|
include Train::Extras::DetectEsx
|
25
26
|
include Train::Extras::DetectAristaEos
|
27
|
+
include Train::Extras::DetectOpenVMS
|
26
28
|
|
27
29
|
attr_accessor :backend
|
28
30
|
def initialize(backend, platform = nil)
|
@@ -96,6 +98,8 @@ module Train::Extras
|
|
96
98
|
# TODO: extend base implementation for detecting the family type
|
97
99
|
# to Windows and others
|
98
100
|
case uname_s
|
101
|
+
when /unrecognized command verb/
|
102
|
+
@platform[:family] = 'openvms'
|
99
103
|
when /linux/i
|
100
104
|
@platform[:family] = 'linux'
|
101
105
|
when /./
|
@@ -105,8 +109,8 @@ module Train::Extras
|
|
105
109
|
@platform[:family] = nil
|
106
110
|
end
|
107
111
|
|
108
|
-
# try to detect the platform
|
109
|
-
return nil
|
112
|
+
# try to detect the platform if the platform is set to nil, otherwise this code will never work
|
113
|
+
return nil if @platform[:family].nil?
|
110
114
|
detect_family_type
|
111
115
|
end
|
112
116
|
|
@@ -116,6 +120,7 @@ module Train::Extras
|
|
116
120
|
return detect_windows if pf == 'windows'
|
117
121
|
return detect_darwin if pf == 'darwin'
|
118
122
|
return detect_esx if pf == 'esx'
|
123
|
+
return detect_openvms if pf =='openvms'
|
119
124
|
|
120
125
|
if %w{freebsd netbsd openbsd aix solaris2 hpux}.include?(pf)
|
121
126
|
return detect_via_uname
|
@@ -124,6 +129,7 @@ module Train::Extras
|
|
124
129
|
# unix based systems combine the above
|
125
130
|
return true if pf == 'unix' and detect_darwin
|
126
131
|
return true if pf == 'unix' and detect_esx
|
132
|
+
# This is assuming that pf is set to unix, this should be if pf == 'linux'
|
127
133
|
return true if pf == 'unix' and detect_arista_eos
|
128
134
|
return true if pf == 'unix' and detect_via_uname
|
129
135
|
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# author: Brian Doody (HPE)
|
3
|
+
# This is heavily based on:
|
4
|
+
#
|
5
|
+
# OHAI https://github.com/chef/ohai
|
6
|
+
# by Adam Jacob, Chef Software Inc
|
7
|
+
#
|
8
|
+
require 'train/extras/uname'
|
9
|
+
|
10
|
+
module Train::Extras
|
11
|
+
module DetectOpenVMS
|
12
|
+
include Train::Extras::Uname
|
13
|
+
|
14
|
+
def detect_openvms
|
15
|
+
cmd = @backend.run_command('show system/noprocess')
|
16
|
+
|
17
|
+
return false if cmd.exit_status != 0
|
18
|
+
return false if cmd.stdout.empty?
|
19
|
+
|
20
|
+
@platform[:name] = cmd.stdout.downcase.split(' ')[0]
|
21
|
+
cmd = @backend.run_command('write sys$output f$getsyi("VERSION")')
|
22
|
+
@platform[:release] = cmd.stdout.downcase.split("\n")[1][1..-1]
|
23
|
+
cmd = @backend.run_command('write sys$output f$getsyi("ARCH_NAME")')
|
24
|
+
@platform[:arch] = cmd.stdout.downcase.split("\n")[1]
|
25
|
+
|
26
|
+
true
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/train/transports/ssh.rb
CHANGED
@@ -82,12 +82,6 @@ module Train::Transports
|
|
82
82
|
super(options)
|
83
83
|
|
84
84
|
key_files = Array(options[:key_files])
|
85
|
-
if key_files.empty? and options[:password].nil?
|
86
|
-
fail Train::ClientError,
|
87
|
-
'You must configure at least one authentication method for SSH:'\
|
88
|
-
' Password or key.'
|
89
|
-
end
|
90
|
-
|
91
85
|
options[:auth_methods] ||= ['none']
|
92
86
|
|
93
87
|
unless key_files.empty?
|
@@ -100,6 +94,17 @@ module Train::Transports
|
|
100
94
|
options[:auth_methods].push('password', 'keyboard-interactive')
|
101
95
|
end
|
102
96
|
|
97
|
+
if options[:auth_methods] == ['none']
|
98
|
+
if ssh_known_identities.empty?
|
99
|
+
fail Train::ClientError,
|
100
|
+
'You must configure at least one authentication method for SSH:'\
|
101
|
+
' Agent, Key or Password.'
|
102
|
+
else
|
103
|
+
logger.debug('[SSH] Using Agent keys as no password or key file have been specified')
|
104
|
+
options[:auth_methods].push('publickey')
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
103
108
|
if options[:pty]
|
104
109
|
logger.warn('[SSH] PTY requested: stderr will be merged into stdout')
|
105
110
|
end
|
@@ -108,6 +113,17 @@ module Train::Transports
|
|
108
113
|
self
|
109
114
|
end
|
110
115
|
|
116
|
+
# Creates an SSH Authentication KeyManager instance and saves it for
|
117
|
+
# potential future reuse.
|
118
|
+
#
|
119
|
+
# @return [Hash] hash of SSH Known Identities
|
120
|
+
# @api private
|
121
|
+
def ssh_known_identities
|
122
|
+
# Force KeyManager to load the key(s)
|
123
|
+
@manager ||= Net::SSH::Authentication::KeyManager.new(nil).each_identity {}
|
124
|
+
@manager.known_identities
|
125
|
+
end
|
126
|
+
|
111
127
|
# Builds the hash of options needed by the Connection object on
|
112
128
|
# construction.
|
113
129
|
#
|
data/lib/train/version.rb
CHANGED
@@ -23,6 +23,7 @@ describe 'ssh transport' do
|
|
23
23
|
password: rand.to_s,
|
24
24
|
key_files: rand.to_s,
|
25
25
|
}}
|
26
|
+
let(:cls_agent) { cls.new({ host: rand.to_s }) }
|
26
27
|
|
27
28
|
describe 'default options' do
|
28
29
|
let(:ssh) { cls.new({ host: 'dummy' }) }
|
@@ -84,6 +85,26 @@ describe 'ssh transport' do
|
|
84
85
|
"root@#{conf[:host]}",
|
85
86
|
])
|
86
87
|
end
|
88
|
+
|
89
|
+
it 'sets the right auth_methods when password is specified' do
|
90
|
+
conf[:key_files] = nil
|
91
|
+
cls.new(conf).connection.method(:options).call[:auth_methods].must_equal ["none", "password", "keyboard-interactive"]
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'sets the right auth_methods when keys are specified' do
|
95
|
+
conf[:password] = nil
|
96
|
+
cls.new(conf).connection.method(:options).call[:auth_methods].must_equal ["none", "publickey"]
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'sets the right auth_methods for agent auth' do
|
100
|
+
cls_agent.stubs(:ssh_known_identities).returns({:some => 'rsa_key'})
|
101
|
+
cls_agent.connection.method(:options).call[:auth_methods].must_equal ['none', 'publickey']
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'works with ssh agent auth' do
|
105
|
+
cls_agent.stubs(:ssh_known_identities).returns({:some => 'rsa_key'})
|
106
|
+
cls_agent.connection
|
107
|
+
end
|
87
108
|
end
|
88
109
|
|
89
110
|
describe 'converting connection to string for logging' do
|
@@ -111,9 +132,8 @@ describe 'ssh transport' do
|
|
111
132
|
end
|
112
133
|
|
113
134
|
it 'does not like key and password == nil' do
|
114
|
-
|
115
|
-
|
116
|
-
proc { cls.new(conf).connection }.must_raise Train::ClientError
|
135
|
+
cls_agent.stubs(:ssh_known_identities).returns({})
|
136
|
+
proc { cls_agent.connection }.must_raise Train::ClientError
|
117
137
|
end
|
118
138
|
|
119
139
|
it 'wont connect if it is not possible' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: train
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.22.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dominik Richter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -162,6 +162,7 @@ files:
|
|
162
162
|
- lib/train/extras/os_detect_darwin.rb
|
163
163
|
- lib/train/extras/os_detect_esx.rb
|
164
164
|
- lib/train/extras/os_detect_linux.rb
|
165
|
+
- lib/train/extras/os_detect_openvms.rb
|
165
166
|
- lib/train/extras/os_detect_unix.rb
|
166
167
|
- lib/train/extras/os_detect_windows.rb
|
167
168
|
- lib/train/extras/stat.rb
|