serverspec 0.2.7 → 0.2.8

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -17,3 +17,4 @@ test/tmp
17
17
  test/version_tmp
18
18
  tmp
19
19
  Vagrantfile
20
+ vendor/
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Serverspec [![BuildStatus](https://secure.travis-ci.org/mizzy/serverspec.png)](http://travis-ci.org/mizzy/serverspec) [![Coverage Status](https://coveralls.io/repos/mizzy/serverspec/badge.png?branch=master)](https://coveralls.io/r/mizzy/serverspec)
1
+ # Serverspec [![BuildStatus](https://secure.travis-ci.org/mizzy/serverspec.png)](http://travis-ci.org/mizzy/serverspec)
2
2
 
3
3
  RSpec tests for your servers provisioned by Puppet, Chef or anything else
4
4
 
@@ -37,11 +37,11 @@ Input target host name: www.example.jp
37
37
 
38
38
  Select OS type of target host:
39
39
 
40
- 1) Red Hat
41
- 2) Debian
42
- 3) Gentoo
43
- 4) Solaris
44
- 5) None
40
+ 1) Auto Detect
41
+ 2) Red Hat
42
+ 3) Debian
43
+ 4) Gentoo
44
+ 5) Solaris
45
45
 
46
46
  Select number: 1
47
47
 
@@ -99,9 +99,12 @@ Finished in 0.99715 seconds
99
99
  ----
100
100
  ## Multi OS support
101
101
 
102
- Serverspec is supporting Red Hat based OS, Debian based OS, Gentoo and Solaris now.
102
+ Serverspec is supporting Red Hat based OS, Debian based OS, Gentoo and Solaris.
103
+
104
+ Serverspec can detect target host's OS automatically.
105
+
106
+ If you'd like to set target host's OS explicitly, you should include `Serverspec::Helper::OSName` like this.
103
107
 
104
- If your target host's OS is Debian, you should include `Serverspec::Helper::Debian` like this.
105
108
 
106
109
  ```ruby
107
110
  require 'serverspec'
@@ -128,49 +131,6 @@ RSpec.configure do |c|
128
131
  end
129
132
  ```
130
133
 
131
- And you can omit OS type from spec like this.
132
-
133
- ```ruby
134
- require 'spec_helper'
135
-
136
- describe 'httpd' do
137
- it { should be_installed }
138
- it { should be_enabled }
139
- it { should be_running }
140
- end
141
-
142
- describe 'port 80' do
143
- it { should be_listening }
144
- end
145
-
146
- describe '/etc/httpd/conf/httpd.conf' do
147
- it { should be_file }
148
- it { should contain "ServerName www.example.jp" }
149
- end
150
- ```
151
-
152
- You can change the target host's OS per spec like this.
153
-
154
-
155
- ```ruby
156
- require 'spec_helper'
157
-
158
- describe 'httpd', :os => :debian do
159
- it { should be_installed }
160
- it { should be_enabled }
161
- it { should be_running }
162
- end
163
-
164
- describe 'port 80', :os => :debian do
165
- it { should be_listening }
166
- end
167
-
168
- describe '/etc/httpd/conf/httpd.conf', :os => :debian do
169
- it { should be_file }
170
- it { should contain "ServerName www.example.jp" }
171
- end
172
- ```
173
-
174
134
  See details on [serverspec.org](http://serverspec.org)
175
135
 
176
136
  ----
data/lib/serverspec.rb CHANGED
@@ -17,6 +17,7 @@ RSpec.configure do |c|
17
17
  c.include(Serverspec::Helper::Debian, :os => :debian)
18
18
  c.include(Serverspec::Helper::Gentoo, :os => :gentoo)
19
19
  c.include(Serverspec::Helper::Solaris, :os => :solaris)
20
+ c.add_setting :os, :default => nil
20
21
  c.add_setting :host, :default => nil
21
22
  c.add_setting :ssh, :default => nil
22
23
  c.add_setting :sudo_password, :default => nil
@@ -93,6 +93,18 @@ module Serverspec
93
93
  end
94
94
  end
95
95
 
96
+ def check_os
97
+ if do_check('ls /etc/redhat-release')[:exit_code] == 0
98
+ 'RedHat'
99
+ elsif do_check('ls /etc/debian_version')[:exit_code] == 0
100
+ 'Debian'
101
+ elsif do_check('ls /etc/gentoo-release')[:exit_code] == 0
102
+ 'Gentoo'
103
+ elsif do_check('uname -s')[:stdout] =~ /SunOS/i
104
+ 'Solaris'
105
+ end
106
+ end
107
+
96
108
  end
97
109
  end
98
110
  end
@@ -10,6 +10,7 @@ require 'serverspec/helper/redhat'
10
10
  require 'serverspec/helper/debian'
11
11
  require 'serverspec/helper/gentoo'
12
12
  require 'serverspec/helper/solaris'
13
+ require 'serverspec/helper/detect_os'
13
14
 
14
15
  # Obsoleted helpers
15
16
  require 'serverspec/helper/obsoleted'
@@ -0,0 +1,9 @@
1
+ module Serverspec
2
+ module Helper
3
+ module DetectOS
4
+ def commands
5
+ self.class.const_get('Serverspec').const_get('Commands').const_get(RSpec.configuration.os).new
6
+ end
7
+ end
8
+ end
9
+ end
@@ -1,8 +1,8 @@
1
1
  module Serverspec
2
2
  module Helper
3
3
  module Exec
4
- def backend
5
- Serverspec::Backend::Exec.new(commands)
4
+ def backend(commmands_object=nil)
5
+ Serverspec::Backend::Exec.new(commands_object || commands)
6
6
  end
7
7
  end
8
8
  end
@@ -1,8 +1,8 @@
1
1
  module Serverspec
2
2
  module Helper
3
3
  module Ssh
4
- def backend
5
- Serverspec::Backend::Ssh.new(commands)
4
+ def backend(commands_object=nil)
5
+ Serverspec::Backend::Ssh.new(commands_object || commands)
6
6
  end
7
7
  end
8
8
  end
@@ -28,11 +28,11 @@ EOF
28
28
 
29
29
  Select OS type of target host:
30
30
 
31
- 1) Red Hat
32
- 2) Debian
33
- 3) Gentoo
34
- 4) Solaris
35
- 5) None
31
+ 1) Auto Detect
32
+ 2) Red Hat
33
+ 3) Debian
34
+ 4) Gentoo
35
+ 5) Solaris
36
36
 
37
37
  Select number:
38
38
  EOF
@@ -41,7 +41,7 @@ EOF
41
41
  num = gets.to_i - 1
42
42
  puts
43
43
 
44
- @os_type = [ 'RedHat', 'Debian', 'Gentoo', 'Solaris', nil ][num]
44
+ @os_type = [ 'DetectOS', 'RedHat', 'Debian', 'Gentoo', 'Solaris' ][num]
45
45
 
46
46
  [ 'spec', "spec/#{@hostname}" ].each { |dir| safe_mkdir(dir) }
47
47
  safe_create_spec
@@ -121,9 +121,9 @@ EOF
121
121
  options = Net::SSH::Config.for(c.host)
122
122
  user = options[:user] || Etc.getlogin
123
123
  c.ssh = Net::SSH.start(c.host, user, options)
124
+ c.os = backend(Serverspec::Commands::Base).check_os
124
125
  end
125
- end
126
- ")
126
+ end")
127
127
  when 'Puppet'
128
128
  content.gsub!(/### include requirements ###/, "require 'puppet'\nrequire 'serverspec/backend/puppet'
129
129
  ")
@@ -1,3 +1,3 @@
1
1
  module Serverspec
2
- VERSION = "0.2.7"
2
+ VERSION = "0.2.8"
3
3
  end
metadata CHANGED
@@ -1,89 +1,90 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: serverspec
3
- version: !ruby/object:Gem::Version
4
- version: 0.2.7
5
- prerelease:
3
+ version: !ruby/object:Gem::Version
4
+ hash: 7
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 2
9
+ - 8
10
+ version: 0.2.8
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Gosuke Miyashita
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2013-04-12 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2013-04-13 00:00:00 +09:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
15
22
  name: net-ssh
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :runtime
23
23
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
25
  none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: '0'
30
- - !ruby/object:Gem::Dependency
31
- name: rspec
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: '0'
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
38
33
  type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: rspec
39
37
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
38
+ requirement: &id002 !ruby/object:Gem::Requirement
41
39
  none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
46
- - !ruby/object:Gem::Dependency
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 0
46
+ version: "0"
47
+ type: :runtime
48
+ version_requirements: *id002
49
+ - !ruby/object:Gem::Dependency
47
50
  name: bundler
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ~>
52
- - !ruby/object:Gem::Version
53
- version: '1.3'
54
- type: :development
55
51
  prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
52
+ requirement: &id003 !ruby/object:Gem::Requirement
57
53
  none: false
58
- requirements:
54
+ requirements:
59
55
  - - ~>
60
- - !ruby/object:Gem::Version
61
- version: '1.3'
62
- - !ruby/object:Gem::Dependency
63
- name: rake
64
- requirement: !ruby/object:Gem::Requirement
65
- none: false
66
- requirements:
67
- - - ! '>='
68
- - !ruby/object:Gem::Version
69
- version: '0'
56
+ - !ruby/object:Gem::Version
57
+ hash: 9
58
+ segments:
59
+ - 1
60
+ - 3
61
+ version: "1.3"
70
62
  type: :development
63
+ version_requirements: *id003
64
+ - !ruby/object:Gem::Dependency
65
+ name: rake
71
66
  prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
67
+ requirement: &id004 !ruby/object:Gem::Requirement
73
68
  none: false
74
- requirements:
75
- - - ! '>='
76
- - !ruby/object:Gem::Version
77
- version: '0'
78
- description: RSpec tests for your servers provisioned by Puppet, Chef or anything
79
- else
80
- email:
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ hash: 3
73
+ segments:
74
+ - 0
75
+ version: "0"
76
+ type: :development
77
+ version_requirements: *id004
78
+ description: RSpec tests for your servers provisioned by Puppet, Chef or anything else
79
+ email:
81
80
  - gosukenator@gmail.com
82
- executables:
81
+ executables:
83
82
  - serverspec-init
84
83
  extensions: []
84
+
85
85
  extra_rdoc_files: []
86
- files:
86
+
87
+ files:
87
88
  - .gitignore
88
89
  - .travis.yml
89
90
  - Gemfile
@@ -103,6 +104,7 @@ files:
103
104
  - lib/serverspec/commands/solaris.rb
104
105
  - lib/serverspec/helper.rb
105
106
  - lib/serverspec/helper/debian.rb
107
+ - lib/serverspec/helper/detect_os.rb
106
108
  - lib/serverspec/helper/exec.rb
107
109
  - lib/serverspec/helper/gentoo.rb
108
110
  - lib/serverspec/helper/obsoleted.rb
@@ -150,32 +152,41 @@ files:
150
152
  - spec/solaris/matchers_spec.rb
151
153
  - spec/spec_helper.rb
152
154
  - spec/support/shared_matcher_examples.rb
155
+ has_rdoc: true
153
156
  homepage: http://serverspec.org/
154
- licenses:
157
+ licenses:
155
158
  - MIT
156
159
  post_install_message:
157
160
  rdoc_options: []
158
- require_paths:
161
+
162
+ require_paths:
159
163
  - lib
160
- required_ruby_version: !ruby/object:Gem::Requirement
164
+ required_ruby_version: !ruby/object:Gem::Requirement
161
165
  none: false
162
- requirements:
163
- - - ! '>='
164
- - !ruby/object:Gem::Version
165
- version: '0'
166
- required_rubygems_version: !ruby/object:Gem::Requirement
166
+ requirements:
167
+ - - ">="
168
+ - !ruby/object:Gem::Version
169
+ hash: 3
170
+ segments:
171
+ - 0
172
+ version: "0"
173
+ required_rubygems_version: !ruby/object:Gem::Requirement
167
174
  none: false
168
- requirements:
169
- - - ! '>='
170
- - !ruby/object:Gem::Version
171
- version: '0'
175
+ requirements:
176
+ - - ">="
177
+ - !ruby/object:Gem::Version
178
+ hash: 3
179
+ segments:
180
+ - 0
181
+ version: "0"
172
182
  requirements: []
183
+
173
184
  rubyforge_project:
174
- rubygems_version: 1.8.23
185
+ rubygems_version: 1.3.7
175
186
  signing_key:
176
187
  specification_version: 3
177
188
  summary: RSpec tests for your servers provisioned by Puppet, Chef or anything else
178
- test_files:
189
+ test_files:
179
190
  - spec/debian/commands_spec.rb
180
191
  - spec/debian/matchers_spec.rb
181
192
  - spec/gentoo/commands_spec.rb