serverspec 0.4.10 → 0.4.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -17,9 +17,16 @@ EOF
17
17
 
18
18
  @backend_type = [ 'Ssh', 'Exec' ][num]
19
19
  if @backend_type == 'Ssh'
20
- print "Input target host name: "
20
+ print "Vagrant instance y/n: "
21
+ @vagrant = gets.chomp
22
+ if @vagrant =~ (/(true|t|yes|y|1)$/i)
23
+ @vagrant = true
24
+ else
25
+ @vagrant = false
26
+ end
27
+ @vagrant ? print("Input vagrant instance name: ") : print("Input target host name: ")
21
28
  @hostname = gets.chomp
22
- else
29
+ else
23
30
  @hostname = 'localhost'
24
31
  end
25
32
 
@@ -115,10 +122,31 @@ EOF
115
122
  c.host = host
116
123
  options = Net::SSH::Config.for(c.host)
117
124
  user = options[:user] || Etc.getlogin
125
+ ### include vagrant conf ###
118
126
  c.ssh = Net::SSH.start(c.host, user, options)
119
127
  c.os = backend(Serverspec::Commands::Base).check_os
120
128
  end
121
129
  end")
130
+ if @vagrant
131
+ content.gsub!(/### include vagrant conf ###/,"
132
+ config = `vagrant ssh-config --host \#{host}`
133
+ if config != ''
134
+ config.each_line do |line|
135
+ if match = /HostName (.*)/.match(line)
136
+ c.host = match[1]
137
+ elsif match = /User (.*)/.match(line)
138
+ user = match[1]
139
+ elsif match = /IdentityFile (.*)/.match(line)
140
+ options[:keys] = [match[1].gsub(/\"/,'')]
141
+ elsif match = /Port (.*)/.match(line)
142
+ options[:port] = match[1]
143
+ end
144
+ end
145
+ end
146
+ ")
147
+ else
148
+ content.gsub!(/### include vagrant conf ###/,'')
149
+ end
122
150
  when 'Exec'
123
151
  content.gsub!(/### include backend conf ###/, "c.before :all do
124
152
  c.os = backend(Serverspec::Commands::Base).check_os
@@ -1,3 +1,3 @@
1
1
  module Serverspec
2
- VERSION = "0.4.10"
2
+ VERSION = "0.4.11"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: serverspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.10
4
+ version: 0.4.11
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-25 00:00:00.000000000 Z
12
+ date: 2013-05-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: net-ssh
@@ -349,7 +349,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
349
349
  version: '0'
350
350
  requirements: []
351
351
  rubyforge_project:
352
- rubygems_version: 1.8.25
352
+ rubygems_version: 1.8.23
353
353
  signing_key:
354
354
  specification_version: 3
355
355
  summary: RSpec tests for your servers provisioned by Puppet, Chef or anything else