Class: Serverspec::Backend::Puppet
- Inherits:
-
Exec
- Object
- Exec
- Serverspec::Backend::Puppet
show all
- Defined in:
- lib/serverspec/backend/puppet.rb
Overview
Use Exec methods as fallbacks
Instance Method Summary
collapse
-
#check_directory(example, directory) ⇒ Object
-
#check_enabled(example, service) ⇒ Object
-
#check_file(example, file) ⇒ Object
-
#check_group(example, group) ⇒ Object
-
#check_grouped(example, file, group) ⇒ Object
-
#check_installed(example, package) ⇒ Object
-
#check_installed_by_gem(example, package, version) ⇒ Object
-
#check_link(example, link, target) ⇒ Object
-
#check_mode(example, file, mode) ⇒ Object
check_listening: inherited.
-
#check_owner(example, file, owner) ⇒ Object
-
#check_running(example, process) ⇒ Object
-
#check_user(example, user) ⇒ Object
Methods inherited from Exec
#add_pre_command, #build_command, #check_executable, #check_mounted, #check_os, #check_readable, #check_routing_table, #check_running_under_supervisor, #check_writable, #check_zero, #commands, #method_missing, #run_command, #set_commands, #set_example
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Serverspec::Backend::Exec
Instance Method Details
#check_directory(example, directory) ⇒ Object
12
13
14
15
|
# File 'lib/serverspec/backend/puppet.rb', line 12
def check_directory(example, directory)
d = ::Puppet::Type::File.new(:name => directory, :ensure => 'directory')
d.insync?(d.retrieve)
end
|
#check_enabled(example, service) ⇒ Object
17
18
19
20
|
# File 'lib/serverspec/backend/puppet.rb', line 17
def check_enabled(example, service)
s = ::Puppet::Type::Service.new(:name => service, :enable => 'true')
s.insync?(s.retrieve)
end
|
#check_file(example, file) ⇒ Object
22
23
24
25
|
# File 'lib/serverspec/backend/puppet.rb', line 22
def check_file(example, file)
f = ::Puppet::Type::File.new(:name => file, :ensure => 'file')
f.insync?(f.retrieve)
end
|
#check_group(example, group) ⇒ Object
27
28
29
30
31
32
33
34
35
|
# File 'lib/serverspec/backend/puppet.rb', line 27
def check_group(example, group)
g = ::Puppet::Type::Group.new(:name => group)
g_real = g.retrieve
if g.provider.exists?
g.insync?(g_real)
else
false
end
end
|
#check_grouped(example, file, group) ⇒ Object
37
38
39
40
|
# File 'lib/serverspec/backend/puppet.rb', line 37
def check_grouped(example, file, group)
f = ::Puppet::Type::File.new(:name => file, :group => group)
f.insync?(f.retrieve)
end
|
#check_installed(example, package) ⇒ Object
42
43
44
45
46
47
48
49
50
|
# File 'lib/serverspec/backend/puppet.rb', line 42
def check_installed(example, package)
p = ::Puppet::Type::Package.new(:name => package)
p_real = p.retrieve
if p.exists?
p.insync?(p_real)
else
false
end
end
|
#check_installed_by_gem(example, package, version) ⇒ Object
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/serverspec/backend/puppet.rb', line 52
def check_installed_by_gem(example, package, version)
p = ::Puppet::Type::Package.new(:name => package, :provider => 'gem',
:ensure => version || 'present')
p_real = p.retrieve
if p.exists?
p.insync?(p_real)
else
false
end
end
|
#check_link(example, link, target) ⇒ Object
63
64
65
66
|
# File 'lib/serverspec/backend/puppet.rb', line 63
def check_link(example, link, target)
f = ::Puppet::Type::File.new(:name => link, :ensure => 'link', :target => target)
f.insync?(f.retrieve)
end
|
#check_mode(example, file, mode) ⇒ Object
check_listening: inherited
70
71
72
73
|
# File 'lib/serverspec/backend/puppet.rb', line 70
def check_mode(example, file, mode)
f = ::Puppet::Type::File.new(:name => file, :mode => mode)
f.insync?(f.retrieve)
end
|
#check_owner(example, file, owner) ⇒ Object
75
76
77
78
|
# File 'lib/serverspec/backend/puppet.rb', line 75
def check_owner(example, file, owner)
f = ::Puppet::Type::File.new(:name => file, :owner => owner)
f.insync?(f.retrieve)
end
|
#check_running(example, process) ⇒ Object
80
81
82
83
|
# File 'lib/serverspec/backend/puppet.rb', line 80
def check_running(example, process)
s = ::Puppet::Type::Service.new(:name => process, :ensure => 'running')
s.insync?(s.retrieve)
end
|
#check_user(example, user) ⇒ Object
85
86
87
88
89
90
91
92
93
|
# File 'lib/serverspec/backend/puppet.rb', line 85
def check_user(example, user)
u = ::Puppet::Type::User.new(:name => user)
u_real = u.retrieve
if u.provider.exists?
u.insync?(u_real)
else
false
end
end
|