serverspec 2.0.0.beta6 → 2.0.0.beta7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/serverspec/helper.rb +0 -2
- data/lib/serverspec/setup.rb +28 -29
- data/lib/serverspec/type/file.rb +11 -0
- data/lib/serverspec/version.rb +1 -1
- data/serverspec.gemspec +1 -1
- metadata +4 -5
- data/lib/serverspec/helper/os.rb +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 86276d22b163697d65c60b346e9b6e6b0ff9e5cb
|
4
|
+
data.tar.gz: 58808a070ee544fe9a86a7a3f50c52a35149ebcc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf3996aefa9f11b279130f27ea47b27673d47e0ae25d9929b9e3103294c59c645a91911d1e3e099250db39925c39402109cb39ca5fb9593a623acd97e556a8a1
|
7
|
+
data.tar.gz: 1f91b85d4ea7f6bc52d54afbc13244b689bb97ac93d7ada9544b980181b64bacb0cabfa2879e8773c0f2b1cd216dffbd5cbc8ad89b8c972c7ceae40363697f67
|
data/lib/serverspec/helper.rb
CHANGED
data/lib/serverspec/setup.rb
CHANGED
@@ -103,13 +103,18 @@ describe package('apache2'), :if => os[:family] == 'Ubuntu' do
|
|
103
103
|
end
|
104
104
|
|
105
105
|
describe service('httpd'), :if => os[:family] == 'RedHat' do
|
106
|
-
it { should be_enabled
|
107
|
-
it { should be_running
|
106
|
+
it { should be_enabled }
|
107
|
+
it { should be_running }
|
108
108
|
end
|
109
109
|
|
110
110
|
describe service('apache2'), :if => os[:family] == 'Ubuntu' do
|
111
|
-
it { should be_enabled
|
112
|
-
it { should be_running
|
111
|
+
it { should be_enabled }
|
112
|
+
it { should be_running }
|
113
|
+
end
|
114
|
+
|
115
|
+
describe service('org.apache.httpd'), :if => os[:family] == 'Darwin' do
|
116
|
+
it { should be_enabled }
|
117
|
+
it { should be_running }
|
113
118
|
end
|
114
119
|
|
115
120
|
describe port(80) do
|
@@ -117,16 +122,16 @@ describe port(80) do
|
|
117
122
|
end
|
118
123
|
EOF
|
119
124
|
|
120
|
-
if File.exists? "spec/#{@hostname}/
|
121
|
-
old_content = File.read("spec/#{@hostname}/
|
125
|
+
if File.exists? "spec/#{@hostname}/sample_spec.rb"
|
126
|
+
old_content = File.read("spec/#{@hostname}/sample_spec.rb")
|
122
127
|
if old_content != content
|
123
|
-
$stderr.puts "!! spec/#{@hostname}/
|
128
|
+
$stderr.puts "!! spec/#{@hostname}/sample_spec.rb already exists and differs from template"
|
124
129
|
end
|
125
130
|
else
|
126
|
-
File.open("spec/#{@hostname}/
|
131
|
+
File.open("spec/#{@hostname}/sample_spec.rb", 'w') do |f|
|
127
132
|
f.puts content
|
128
133
|
end
|
129
|
-
puts " + spec/#{@hostname}/
|
134
|
+
puts " + spec/#{@hostname}/sample_spec.rb"
|
130
135
|
end
|
131
136
|
end
|
132
137
|
|
@@ -233,11 +238,14 @@ end
|
|
233
238
|
end
|
234
239
|
|
235
240
|
def self.spec_helper_template
|
236
|
-
template = <<-EOF
|
241
|
+
template = <<-'EOF'
|
237
242
|
require 'serverspec'
|
238
243
|
<% if @backend_type == 'Ssh' -%>
|
239
244
|
require 'net/ssh'
|
240
245
|
<% end -%>
|
246
|
+
<%- if @vagrant -%>
|
247
|
+
require 'tempfile'
|
248
|
+
<% end -%>
|
241
249
|
<% if @backend_type == 'WinRM' -%>
|
242
250
|
require 'winrm'
|
243
251
|
<% end -%>
|
@@ -262,31 +270,22 @@ else
|
|
262
270
|
end
|
263
271
|
|
264
272
|
<%- if @backend_type == 'Ssh' -%>
|
265
|
-
host
|
266
|
-
options = Net::SSH::Config.for(host)
|
273
|
+
host = ENV['TARGET_HOST']
|
267
274
|
|
268
275
|
<%- if @vagrant -%>
|
269
|
-
`vagrant up
|
270
|
-
|
271
|
-
config =
|
272
|
-
|
273
|
-
config.each_line do |line|
|
274
|
-
if match = /HostName (.*)/.match(line)
|
275
|
-
host = match[1]
|
276
|
-
elsif match = /User (.*)/.match(line)
|
277
|
-
options[:user] = match[1]
|
278
|
-
elsif match = /IdentityFile (.*)/.match(line)
|
279
|
-
options[:keys] = [match[1].gsub(/\"/,'')]
|
280
|
-
elsif match = /Port (.*)/.match(line)
|
281
|
-
options[:port] = match[1]
|
282
|
-
end
|
283
|
-
end
|
284
|
-
end
|
276
|
+
`vagrant up #{host}`
|
277
|
+
|
278
|
+
config = Tempfile.new('', Dir.tmpdir)
|
279
|
+
`vagrant ssh-config #{host} > #{config.path}`
|
285
280
|
|
281
|
+
options = Net::SSH::Config.for(host, [config.path])
|
282
|
+
<%- else -%>
|
283
|
+
options = Net::SSH::Config.for(host)
|
286
284
|
<%- end -%>
|
285
|
+
|
287
286
|
options[:user] ||= Etc.getlogin
|
288
287
|
|
289
|
-
set :host, host
|
288
|
+
set :host, options[:host_name] || host
|
290
289
|
set :ssh_options, options
|
291
290
|
<%- end -%>
|
292
291
|
<%- end -%>
|
data/lib/serverspec/type/file.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'date'
|
2
|
+
|
1
3
|
module Serverspec
|
2
4
|
module Type
|
3
5
|
class File < Base
|
@@ -93,6 +95,15 @@ module Serverspec
|
|
93
95
|
def version?(version)
|
94
96
|
@runner.check_file_version(@name, version)
|
95
97
|
end
|
98
|
+
|
99
|
+
def mtime
|
100
|
+
d = backend.get_file_mtime(@name).stdout.strip
|
101
|
+
DateTime.strptime(d, '%s').new_offset(DateTime.now.offset)
|
102
|
+
end
|
103
|
+
|
104
|
+
def size
|
105
|
+
backend.get_file_size(@name).stdout.strip.to_i
|
106
|
+
end
|
96
107
|
end
|
97
108
|
end
|
98
109
|
end
|
data/lib/serverspec/version.rb
CHANGED
data/serverspec.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_runtime_dependency "rspec", "~> 3.0.0"
|
22
22
|
spec.add_runtime_dependency "rspec-its"
|
23
|
-
spec.add_runtime_dependency "specinfra", "~> 2.0.0.
|
23
|
+
spec.add_runtime_dependency "specinfra", "~> 2.0.0.beta6"
|
24
24
|
spec.add_development_dependency "bundler", "~> 1.3"
|
25
25
|
spec.add_development_dependency "rake", "~> 10.1.1"
|
26
26
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: serverspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.
|
4
|
+
version: 2.0.0.beta7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gosuke Miyashita
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 2.0.0.
|
47
|
+
version: 2.0.0.beta6
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 2.0.0.
|
54
|
+
version: 2.0.0.beta6
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -101,7 +101,6 @@ files:
|
|
101
101
|
- lib/serverspec.rb
|
102
102
|
- lib/serverspec/commands/base.rb
|
103
103
|
- lib/serverspec/helper.rb
|
104
|
-
- lib/serverspec/helper/os.rb
|
105
104
|
- lib/serverspec/helper/properties.rb
|
106
105
|
- lib/serverspec/helper/type.rb
|
107
106
|
- lib/serverspec/matchers.rb
|
data/lib/serverspec/helper/os.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
module Serverspec
|
2
|
-
module Helper
|
3
|
-
[
|
4
|
-
'DetectOS',
|
5
|
-
'AIX',
|
6
|
-
'Arch',
|
7
|
-
'Darwin',
|
8
|
-
'Debian',
|
9
|
-
'Fedora',
|
10
|
-
'FreeBSD',
|
11
|
-
'FreeBSD10',
|
12
|
-
'Gentoo',
|
13
|
-
'Plamo',
|
14
|
-
'RedHat',
|
15
|
-
'RedHat7',
|
16
|
-
'SmartOS',
|
17
|
-
'Solaris',
|
18
|
-
'Solaris10',
|
19
|
-
'Solaris11',
|
20
|
-
'Windows',
|
21
|
-
].each do |os|
|
22
|
-
eval <<-EOF
|
23
|
-
module #{os}
|
24
|
-
include self.class.const_get('Specinfra').const_get('Helper').const_get('#{os}')
|
25
|
-
end
|
26
|
-
EOF
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|