serverspec 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/serverspec/backend/exec.rb +0 -1
- data/lib/serverspec/commands/base.rb +4 -0
- data/lib/serverspec/commands/debian.rb +7 -1
- data/lib/serverspec/commands/linux.rb +4 -0
- data/lib/serverspec/helper/type.rb +1 -1
- data/lib/serverspec/type/base.rb +3 -1
- data/lib/serverspec/type/kernel_module.rb +9 -0
- data/lib/serverspec/version.rb +1 -1
- data/spec/debian/commands_spec.rb +4 -2
- data/spec/debian/kernel_module_spec.rb +7 -0
- data/spec/gentoo/commands_spec.rb +2 -0
- data/spec/gentoo/kernel_module_spec.rb +7 -0
- data/spec/redhat/commands_spec.rb +2 -0
- data/spec/redhat/kernel_module_spec.rb +7 -0
- data/spec/support/shared_commands_examples.rb +5 -0
- data/spec/support/shared_kernel_module_examples.rb +11 -0
- metadata +10 -1
@@ -2,13 +2,19 @@ module Serverspec
|
|
2
2
|
module Commands
|
3
3
|
class Debian < Linux
|
4
4
|
def check_enabled service
|
5
|
-
|
5
|
+
# Until everything uses Upstart, this needs an OR.
|
6
|
+
"ls /etc/rc3.d/ | grep -- #{escape(service)} || grep 'start on' /etc/init/#{escape(service)}.conf"
|
6
7
|
end
|
7
8
|
|
8
9
|
def check_installed package
|
9
10
|
escaped_package = escape(package)
|
10
11
|
"dpkg -s #{escaped_package} && ! dpkg -s #{escaped_package} | grep -E '^Status: .+ not-installed$'"
|
11
12
|
end
|
13
|
+
|
14
|
+
def check_running service
|
15
|
+
# This is compatible with Debian >Jaunty and Ubuntu derivatives
|
16
|
+
"service #{escape(service)} status | grep 'running'"
|
17
|
+
end
|
12
18
|
end
|
13
19
|
end
|
14
20
|
end
|
@@ -3,7 +3,7 @@ module Serverspec
|
|
3
3
|
module Type
|
4
4
|
types = %w(
|
5
5
|
base service package port file cron command linux_kernel_parameter iptables host
|
6
|
-
routing_table default_gateway selinux user group zfs ipnat ipfilter
|
6
|
+
routing_table default_gateway selinux user group zfs ipnat ipfilter kernel_module
|
7
7
|
)
|
8
8
|
|
9
9
|
types.each {|type| require "serverspec/type/#{type}" }
|
data/lib/serverspec/type/base.rb
CHANGED
data/lib/serverspec/version.rb
CHANGED
@@ -52,11 +52,13 @@ describe 'Serverspec commands of Debian family' do
|
|
52
52
|
it_behaves_like 'support command get_mode'
|
53
53
|
|
54
54
|
it_behaves_like 'support command check_access_by_user'
|
55
|
+
|
56
|
+
it_behaves_like 'support command check_kernel_module_loaded', 'lp'
|
55
57
|
end
|
56
58
|
|
57
59
|
describe 'check_enabled' do
|
58
60
|
subject { commands.check_enabled('httpd') }
|
59
|
-
it { should eq
|
61
|
+
it { should eq "ls /etc/rc3.d/ | grep -- httpd || grep 'start on' /etc/init/httpd.conf" }
|
60
62
|
end
|
61
63
|
|
62
64
|
describe 'check_installed' do
|
@@ -66,5 +68,5 @@ end
|
|
66
68
|
|
67
69
|
describe 'check_running' do
|
68
70
|
subject { commands.check_running('httpd') }
|
69
|
-
it { should eq
|
71
|
+
it { should eq "service httpd status | grep 'running'" }
|
70
72
|
end
|
@@ -52,6 +52,8 @@ describe 'Serverspec commands of Gentoo family' do
|
|
52
52
|
it_behaves_like 'support command get_mode'
|
53
53
|
|
54
54
|
it_behaves_like 'support command check_access_by_user'
|
55
|
+
|
56
|
+
it_behaves_like 'support command check_kernel_module_loaded', 'lp'
|
55
57
|
end
|
56
58
|
|
57
59
|
describe 'check_enabled' do
|
@@ -250,3 +250,8 @@ shared_examples_for 'support command check_access_by_user' do
|
|
250
250
|
it { should eq 'su -s sh -c "test -x /tmp/somethingx" dummyuser3' }
|
251
251
|
end
|
252
252
|
end
|
253
|
+
|
254
|
+
shared_examples_for 'support command check_kernel_module_loaded' do |name|
|
255
|
+
subject { commands.check_kernel_module_loaded(name) }
|
256
|
+
it { should eq "lsmod | grep ^#{name}" }
|
257
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
shared_examples_for 'support kernel_module be_loaded matcher' do |name|
|
2
|
+
describe 'be_loaded' do
|
3
|
+
describe kernel_module(name) do
|
4
|
+
it { should be_loaded }
|
5
|
+
end
|
6
|
+
|
7
|
+
describe kernel_module('invalid-module') do
|
8
|
+
it { should_not be_loaded }
|
9
|
+
end
|
10
|
+
end
|
11
|
+
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.6.
|
4
|
+
version: 0.6.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -196,6 +196,7 @@ files:
|
|
196
196
|
- lib/serverspec/type/ipfilter.rb
|
197
197
|
- lib/serverspec/type/ipnat.rb
|
198
198
|
- lib/serverspec/type/iptables.rb
|
199
|
+
- lib/serverspec/type/kernel_module.rb
|
199
200
|
- lib/serverspec/type/linux_kernel_parameter.rb
|
200
201
|
- lib/serverspec/type/package.rb
|
201
202
|
- lib/serverspec/type/port.rb
|
@@ -228,6 +229,7 @@ files:
|
|
228
229
|
- spec/debian/group_spec.rb
|
229
230
|
- spec/debian/host_spec.rb
|
230
231
|
- spec/debian/iptables_spec.rb
|
232
|
+
- spec/debian/kernel_module_spec.rb
|
231
233
|
- spec/debian/linux_kernel_parameter_spec.rb
|
232
234
|
- spec/debian/package_spec.rb
|
233
235
|
- spec/debian/port_spec.rb
|
@@ -243,6 +245,7 @@ files:
|
|
243
245
|
- spec/gentoo/group_spec.rb
|
244
246
|
- spec/gentoo/host_spec.rb
|
245
247
|
- spec/gentoo/iptables_spec.rb
|
248
|
+
- spec/gentoo/kernel_module_spec.rb
|
246
249
|
- spec/gentoo/linux_kernel_parameter_spec.rb
|
247
250
|
- spec/gentoo/package_spec.rb
|
248
251
|
- spec/gentoo/port_spec.rb
|
@@ -258,6 +261,7 @@ files:
|
|
258
261
|
- spec/redhat/group_spec.rb
|
259
262
|
- spec/redhat/host_spec.rb
|
260
263
|
- spec/redhat/iptables_spec.rb
|
264
|
+
- spec/redhat/kernel_module_spec.rb
|
261
265
|
- spec/redhat/linux_kernel_parameter_spec.rb
|
262
266
|
- spec/redhat/package_spec.rb
|
263
267
|
- spec/redhat/port_spec.rb
|
@@ -290,6 +294,7 @@ files:
|
|
290
294
|
- spec/support/shared_group_examples.rb
|
291
295
|
- spec/support/shared_host_examples.rb
|
292
296
|
- spec/support/shared_iptables_examples.rb
|
297
|
+
- spec/support/shared_kernel_module_examples.rb
|
293
298
|
- spec/support/shared_linux_kernel_parameter_examples.rb
|
294
299
|
- spec/support/shared_package_examples.rb
|
295
300
|
- spec/support/shared_port_examples.rb
|
@@ -345,6 +350,7 @@ test_files:
|
|
345
350
|
- spec/debian/group_spec.rb
|
346
351
|
- spec/debian/host_spec.rb
|
347
352
|
- spec/debian/iptables_spec.rb
|
353
|
+
- spec/debian/kernel_module_spec.rb
|
348
354
|
- spec/debian/linux_kernel_parameter_spec.rb
|
349
355
|
- spec/debian/package_spec.rb
|
350
356
|
- spec/debian/port_spec.rb
|
@@ -360,6 +366,7 @@ test_files:
|
|
360
366
|
- spec/gentoo/group_spec.rb
|
361
367
|
- spec/gentoo/host_spec.rb
|
362
368
|
- spec/gentoo/iptables_spec.rb
|
369
|
+
- spec/gentoo/kernel_module_spec.rb
|
363
370
|
- spec/gentoo/linux_kernel_parameter_spec.rb
|
364
371
|
- spec/gentoo/package_spec.rb
|
365
372
|
- spec/gentoo/port_spec.rb
|
@@ -375,6 +382,7 @@ test_files:
|
|
375
382
|
- spec/redhat/group_spec.rb
|
376
383
|
- spec/redhat/host_spec.rb
|
377
384
|
- spec/redhat/iptables_spec.rb
|
385
|
+
- spec/redhat/kernel_module_spec.rb
|
378
386
|
- spec/redhat/linux_kernel_parameter_spec.rb
|
379
387
|
- spec/redhat/package_spec.rb
|
380
388
|
- spec/redhat/port_spec.rb
|
@@ -407,6 +415,7 @@ test_files:
|
|
407
415
|
- spec/support/shared_group_examples.rb
|
408
416
|
- spec/support/shared_host_examples.rb
|
409
417
|
- spec/support/shared_iptables_examples.rb
|
418
|
+
- spec/support/shared_kernel_module_examples.rb
|
410
419
|
- spec/support/shared_linux_kernel_parameter_examples.rb
|
411
420
|
- spec/support/shared_package_examples.rb
|
412
421
|
- spec/support/shared_port_examples.rb
|