rspec-system-puppet 0.3.2 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +1 -1
- data/lib/rspec-system-puppet/helpers.rb +29 -8
- data/rspec-system-puppet.gemspec +1 -1
- data/spec/system/basic_spec.rb +25 -0
- metadata +4 -4
data/README.md
CHANGED
@@ -81,18 +81,34 @@ host { 'puppet':
|
|
81
81
|
# Run puppet agent
|
82
82
|
#
|
83
83
|
# @param opts [Hash] a hash of opts
|
84
|
+
# @option opts [RSpecSystem::Node] :node node to execute DSL on
|
85
|
+
# @option opts [Boolean] :debug true if debugging required
|
86
|
+
# @option opts [Boolean] :trace true if trace required
|
84
87
|
# @return [Hash] a hash of results
|
85
88
|
# @yield [result] yields result when called as a block
|
86
89
|
# @yieldparam result [Hash] a hash containing :exit_code, :stdout and :stderr
|
87
|
-
|
90
|
+
# @example
|
91
|
+
# puppet_agent.do |r|
|
92
|
+
# r[:exit_code].should == 0
|
93
|
+
# end
|
94
|
+
# @example with debugging enabled
|
95
|
+
# puppet_agent(:debug => true).do |r|
|
96
|
+
# r[:exit_code].should == 0
|
97
|
+
# end
|
98
|
+
def puppet_agent(opts = {})
|
88
99
|
# Defaults etc.
|
89
100
|
opts = {
|
90
101
|
:node => rspec_system_node_set.default_node,
|
91
|
-
|
102
|
+
:debug => false,
|
103
|
+
:trace => true,
|
104
|
+
}.merge(opts)
|
92
105
|
|
93
106
|
node = opts[:node]
|
94
107
|
|
95
|
-
|
108
|
+
cmd = "puppet agent -t --detailed-exitcodes"
|
109
|
+
cmd += " --debug" if opts[:debug]
|
110
|
+
cmd += " --trace" if opts[:trace]
|
111
|
+
result = system_run(:n => node, :c => cmd)
|
96
112
|
|
97
113
|
if block_given?
|
98
114
|
yield(result)
|
@@ -159,6 +175,8 @@ host { 'puppet':
|
|
159
175
|
# code to execute with option defaults
|
160
176
|
# @option opts [String] :code the Puppet DSL code to execute
|
161
177
|
# @option opts [RSpecSystem::Node] :node node to execute DSL on
|
178
|
+
# @option opts [Boolean] :debug true if debugging required
|
179
|
+
# @option opts [Boolean] :trace true if trace required
|
162
180
|
# @return [Hash] a hash of results
|
163
181
|
# @yield [result] yields result when called as a block
|
164
182
|
# @yieldparam result [Hash] a hash containing :exit_code, :stdout and :stderr
|
@@ -168,9 +186,6 @@ host { 'puppet':
|
|
168
186
|
# r[:stdout].should =~ /foo/
|
169
187
|
# end
|
170
188
|
# end
|
171
|
-
# @todo Support for custom switches perhaps?
|
172
|
-
# @todo The destination path is static, need a good remote random path
|
173
|
-
# generator
|
174
189
|
def puppet_apply(opts)
|
175
190
|
if opts.is_a?(String)
|
176
191
|
opts = {:code => opts}
|
@@ -178,7 +193,9 @@ host { 'puppet':
|
|
178
193
|
|
179
194
|
# Defaults
|
180
195
|
opts = {
|
181
|
-
:node => rspec_system_node_set.default_node
|
196
|
+
:node => rspec_system_node_set.default_node,
|
197
|
+
:debug => false,
|
198
|
+
:trace => true,
|
182
199
|
}.merge(opts)
|
183
200
|
|
184
201
|
code = opts[:code]
|
@@ -199,7 +216,11 @@ host { 'puppet':
|
|
199
216
|
system_run(:n => node, :c => "cat #{remote_path}")
|
200
217
|
|
201
218
|
log.info("Now running puppet apply")
|
202
|
-
|
219
|
+
cmd = "puppet apply --detailed-exitcodes"
|
220
|
+
cmd += " --debug" if opts[:debug]
|
221
|
+
cmd += " --trace" if opts[:trace]
|
222
|
+
cmd += " #{remote_path}"
|
223
|
+
result = system_run(:n => node, :c => cmd)
|
203
224
|
|
204
225
|
if block_given?
|
205
226
|
yield(result)
|
data/rspec-system-puppet.gemspec
CHANGED
data/spec/system/basic_spec.rb
CHANGED
@@ -14,6 +14,14 @@ describe "basic tests:" do
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
+
it 'try puppet agent with debug enabled' do
|
18
|
+
puppet_agent(:debug => true) do |r|
|
19
|
+
r[:stderr].should == ''
|
20
|
+
r[:stdout].should =~ /Debug:/
|
21
|
+
r[:exit_code].should == 0
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
17
25
|
it 'facter domain should return something valid' do
|
18
26
|
system_run("facter domain") do |r|
|
19
27
|
r[:stdout].should =~ /[a-z]+/
|
@@ -44,4 +52,21 @@ describe "basic tests:" do
|
|
44
52
|
r[:exit_code].should == 0
|
45
53
|
end
|
46
54
|
end
|
55
|
+
|
56
|
+
it 'try puppet apply with debug mode' do
|
57
|
+
puppet_apply(:code => 'notice("foo")', :debug => true) do |r|
|
58
|
+
r[:stdout].should =~ /foo/
|
59
|
+
r[:stdout].should =~ /Debug:/
|
60
|
+
r[:stderr].should == ''
|
61
|
+
r[:exit_code].should == 0
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'try puppet apply with trace off' do
|
66
|
+
puppet_apply(:code => 'notice("foo")', :trace => false) do |r|
|
67
|
+
r[:stdout].should =~ /foo/
|
68
|
+
r[:stderr].should == ''
|
69
|
+
r[:exit_code].should == 0
|
70
|
+
end
|
71
|
+
end
|
47
72
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-system-puppet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 3
|
10
|
+
version: 0.3.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ken Barber
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2013-04-
|
18
|
+
date: 2013-04-19 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rspec-system
|