serverspec-runner 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/Rakefile +2 -2
- data/lib/serverspec-runner/version.rb +1 -1
- data/lib/serverspec-runner.rb +0 -1
- data/serverspec-runner.gemspec +0 -1
- data/spec/spec_helper.rb +5 -3
- metadata +2 -18
- data/lib/serverspec-runner/detection.rb +0 -45
- data/lib/serverspec-runner/util.rb +0 -48
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8bbdaab098b4ab210d5f3990c4a2fa59b34740da
|
4
|
+
data.tar.gz: 6f9b74bd39f704d32ba75a77245df1e0cd65bd8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 336d14453ead53ea80583ddddb2ff3dfcb2431251c81e2b9bb67bbd5bd464369fee8abb8b28ffffc2fa0a226a0dc18085b1a3bd63abfead11ad9b932557c6b5c
|
7
|
+
data.tar.gz: a44f9de7fb360df996945e68eb20355247610bc72eb7ee438555bd1d8422d78d6e9ea8fa98411eb7b596a0a255be56680f88088a65c3a8bf1a5d9511cd6c5282
|
data/README.md
CHANGED
@@ -50,7 +50,7 @@ or
|
|
50
50
|
|
51
51
|
$ cd /path/to/your_serverspec_root && serverspec-runner
|
52
52
|
|
53
|
-
You can also specify [ssh_options.yml](http://net-ssh.github.io/ssh/
|
53
|
+
You can also specify [ssh_options.yml](http://net-ssh.github.io/net-ssh/classes/Net/SSH.html)(Net::SSH options) file by "-o" option for default ssh options.
|
54
54
|
|
55
55
|
$ serverspec-runner -s /path/to/your_scenario.yml -o /path/to/your_ssh_options.yml
|
56
56
|
|
data/Rakefile
CHANGED
@@ -39,6 +39,8 @@ namespace :spec do
|
|
39
39
|
|
40
40
|
FileUtils.mkdir_p(path)
|
41
41
|
FileUtils.cp("#{File.dirname(__FILE__)}/scenario.yml", ENV['specroot'])
|
42
|
+
FileUtils.cp("#{File.dirname(__FILE__)}/ssh_options_default.yml", ENV['specroot'])
|
43
|
+
FileUtils.cp("#{File.dirname(__FILE__)}/.rspec", ENV['specroot'])
|
42
44
|
FileUtils.cp_r("#{File.dirname(__FILE__)}/spec/.", path)
|
43
45
|
|
44
46
|
puts("Please edit \"#{ENV['specroot']}/scenario.yml\" and change directory to \"#{ENV['specroot']}\" and exec \"serverspec-runner\" command !!")
|
@@ -70,8 +72,6 @@ namespace :spec do
|
|
70
72
|
platform[host_alias.to_sym][:ssh_opts].each { |k, v| ssh_options[k.to_sym] = v } if platform[host_alias.to_sym].include?(:ssh_opts)
|
71
73
|
|
72
74
|
tasks << "#{path}::#{host_alias}"
|
73
|
-
platform[host_alias.to_sym] = ServerspecRunner::Detection.platform(ssh_host, ssh_options, platform[host_alias.to_sym])
|
74
|
-
return ''
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
data/lib/serverspec-runner.rb
CHANGED
data/serverspec-runner.gemspec
CHANGED
@@ -20,7 +20,6 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_runtime_dependency "serverspec"
|
22
22
|
spec.add_runtime_dependency "net-ssh"
|
23
|
-
spec.add_runtime_dependency "net-ssh-shell"
|
24
23
|
spec.add_development_dependency "rake"
|
25
24
|
spec.add_development_dependency "rspec-core"
|
26
25
|
spec.add_development_dependency "bundler", "~> 1.3"
|
data/spec/spec_helper.rb
CHANGED
@@ -5,8 +5,6 @@ require 'yaml'
|
|
5
5
|
require 'csv'
|
6
6
|
require 'serverspec-runner/util/hash'
|
7
7
|
|
8
|
-
set :backend, :exec
|
9
|
-
|
10
8
|
ssh_opts_default = YAML.load_file(ENV['ssh_options'])
|
11
9
|
csv_path = ENV['result_csv']
|
12
10
|
explains = []
|
@@ -43,7 +41,11 @@ RSpec.configure do |c|
|
|
43
41
|
ssh_opts ||= ssh_opts_default
|
44
42
|
property[:ssh_opts].each { |k, v| ssh_opts[k.to_sym] = v } if property[:ssh_opts]
|
45
43
|
user = options[:user] || ssh_opts[:user] || Etc.getlogin
|
46
|
-
|
44
|
+
options.merge!(ssh_opts)
|
45
|
+
set :ssh_options, options
|
46
|
+
set :backend, :ssh
|
47
|
+
else
|
48
|
+
set :backend, :exec
|
47
49
|
end
|
48
50
|
|
49
51
|
c.before(:suite) do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: serverspec-runner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- hiracy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: serverspec
|
@@ -38,20 +38,6 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: net-ssh-shell
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: rake
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -110,8 +96,6 @@ files:
|
|
110
96
|
- Rakefile
|
111
97
|
- bin/serverspec-runner
|
112
98
|
- lib/serverspec-runner.rb
|
113
|
-
- lib/serverspec-runner/detection.rb
|
114
|
-
- lib/serverspec-runner/util.rb
|
115
99
|
- lib/serverspec-runner/util/hash.rb
|
116
100
|
- lib/serverspec-runner/version.rb
|
117
101
|
- scenario.yml
|
@@ -1,45 +0,0 @@
|
|
1
|
-
require 'socket'
|
2
|
-
require 'serverspec-runner/util'
|
3
|
-
|
4
|
-
module ServerspecRunner
|
5
|
-
module Detection
|
6
|
-
|
7
|
-
def self.platform(host, ssh_options={}, properties)
|
8
|
-
|
9
|
-
detected = {}
|
10
|
-
|
11
|
-
sudo = properties[:nosudo] ? '' : 'sudo'
|
12
|
-
properties[:sudo_prefix] = sudo + ' '
|
13
|
-
|
14
|
-
commands = {
|
15
|
-
:detect_platform_redhat => 'cat /etc/redhat-release 2> /dev/null',
|
16
|
-
:detect_platform_debian => 'cat /etc/debian_version 2> /dev/null',
|
17
|
-
:detect_hostname => 'hostname 2> /dev/null',
|
18
|
-
:detect_hostname_short => 'hostname -s 2> /dev/null',
|
19
|
-
}
|
20
|
-
|
21
|
-
executed = ServerspecRunner::Util.alternative_exec!(host, commands, ssh_options)
|
22
|
-
|
23
|
-
# platform
|
24
|
-
if executed[:detect_platform_redhat][:exit_succeeded]
|
25
|
-
detected[:platform_name] = 'centos'
|
26
|
-
|
27
|
-
if executed[:detect_platform_redhat][:stdout] =~ /^(CentOS release )(\d+).(\d+).*$/
|
28
|
-
detected[:platform_detail_name] = "centos#{$2}"
|
29
|
-
end
|
30
|
-
elsif executed[:detect_platform_debian][:exit_succeeded]
|
31
|
-
detected[:platform_name] = 'debian'
|
32
|
-
|
33
|
-
if executed[:detect_platform_debian][:stdout] =~ /^(\d+).(\d+).(\d*)$/
|
34
|
-
detected[:platform_detail_name] = "debian#{$1}"
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
# hostname
|
39
|
-
detected[:hostname] = executed[:detect_hostname][:stdout]
|
40
|
-
detected[:hostname_short] = executed[:detect_hostname_short][:stdout]
|
41
|
-
|
42
|
-
detected.merge(properties)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
require 'net/ssh'
|
2
|
-
require 'net/ssh/shell'
|
3
|
-
|
4
|
-
module ServerspecRunner
|
5
|
-
module Util
|
6
|
-
|
7
|
-
def self.alternative_exec!(host, commands={}, options={})
|
8
|
-
|
9
|
-
result = {}
|
10
|
-
|
11
|
-
if host == 'localhost' || host == '127.0.0.1' || host == nil
|
12
|
-
commands.each do |key,cmd|
|
13
|
-
result[key] = { :stdout => `#{cmd}`.strip, :exit_status => $?, :exit_succeeded => ($? == 0) }
|
14
|
-
end
|
15
|
-
|
16
|
-
return result
|
17
|
-
end
|
18
|
-
|
19
|
-
options = Net::SSH::Config.for(host).merge(options)
|
20
|
-
user = options[:user] || Etc.getlogin
|
21
|
-
|
22
|
-
puts "connecting #{host}..."
|
23
|
-
|
24
|
-
Net::SSH.start(host, user, options) do |ssh|
|
25
|
-
|
26
|
-
ssh.shell do |sh|
|
27
|
-
commands.each do |key,cmd|
|
28
|
-
|
29
|
-
stdout = ''
|
30
|
-
stderr = ''
|
31
|
-
exit_status = nil
|
32
|
-
exit_succeeded = nil
|
33
|
-
|
34
|
-
pr = sh.execute! cmd do |shell_process|
|
35
|
-
shell_process.on_output do |pr, data|
|
36
|
-
stdout = data
|
37
|
-
end
|
38
|
-
end
|
39
|
-
result[key] = { :stdout => stdout.strip, :exit_status => pr.exit_status, :exit_succeeded => (pr.exit_status == 0) }
|
40
|
-
end
|
41
|
-
sh.execute! "exit"
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
result
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|