rspec-system-puppet 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +5 -12
- data/lib/rspec-system-puppet/helpers.rb +26 -26
- data/rspec-system-puppet.gemspec +2 -2
- metadata +10 -10
data/README.md
CHANGED
@@ -96,10 +96,7 @@ You will need a spec helper for your tests to `require`. So create the file `spe
|
|
96
96
|
c.tty = true
|
97
97
|
|
98
98
|
# This is where we 'setup' the nodes before running our tests
|
99
|
-
c.
|
100
|
-
# TODO: find a better way of importing this into this namespace
|
101
|
-
include RSpecSystemPuppet::Helpers
|
102
|
-
|
99
|
+
c.before :suite do
|
103
100
|
# Install puppet
|
104
101
|
puppet_install
|
105
102
|
puppet_master_install
|
@@ -118,24 +115,19 @@ And create your first system tests in say `spec/system/basic_spec.rb` (make sure
|
|
118
115
|
|
119
116
|
require 'spec_helper_system'
|
120
117
|
describe 'basic tests:' do
|
121
|
-
|
122
|
-
let(pp) do
|
118
|
+
it 'my class should work with no errors' do
|
123
119
|
pp = <<-EOS
|
124
120
|
class { 'mymodule': }
|
125
121
|
EOS
|
126
|
-
|
127
|
-
|
128
|
-
it 'my class should work with no errors' do
|
122
|
+
|
129
123
|
# Run it once and make sure it doesn't bail with errors
|
130
124
|
puppet_apply(pp) do |r|
|
131
125
|
r.exit_code.should_not eq(1)
|
132
126
|
end
|
133
|
-
end
|
134
127
|
|
135
|
-
it 'my class should be idempotent' do
|
136
128
|
# Run it again and make sure no changes occurred this time, proving idempotency
|
137
129
|
puppet_apply(pp) do |r|
|
138
|
-
r.exit_code.should
|
130
|
+
r.exit_code.should be_zero
|
139
131
|
end
|
140
132
|
end
|
141
133
|
end
|
@@ -163,6 +155,7 @@ Consult the .nodeset.yml file for the list of sets.
|
|
163
155
|
* [API Documentation](http://rubydoc.info/gems/rspec-system-puppet/) - this provides the Ruby API docs for the Puppet Helpers. In particular look at the [Helpers](http://rubydoc.info/gems/rspec-system-puppet/RSpecSystemPuppet/Helpers) sub-class.
|
164
156
|
* [rspec-system docs](http://rubydoc.info/gems/rspec-system) - This is the main library rspec-system-puppet utilises, and should provide more in-depth instructions on doing more complex stuff than what this gem alone provides.
|
165
157
|
* [puppetlabs-firewall](http://github.com/puppetlabs/puppetlabs-firewall) - If you want to see the library in action this module is the primary guinea pig for rspec-system-puppet and should give you some ideas on writing tests of your own. Look under `spec/system` for the tests.
|
158
|
+
* [puppetlabs-puppetdb](http://github.com/puppetlabs/puppetlabs-puppetdb) - Another example of the module in action.
|
166
159
|
|
167
160
|
## CI Integration
|
168
161
|
|
@@ -9,13 +9,13 @@ module RSpecSystemPuppet::Helpers
|
|
9
9
|
# @param opts [Hash] a hash of opts
|
10
10
|
def puppet_install(opts = {})
|
11
11
|
# Grab facts from node
|
12
|
-
facts =
|
12
|
+
facts = node.facts
|
13
13
|
|
14
14
|
# Remove annoying mesg n from profile, otherwise on Debian we get:
|
15
15
|
# stdin: is not a tty which messes with our tests later on.
|
16
16
|
if facts['osfamily'] == 'Debian'
|
17
17
|
log.info("Remove 'mesg n' from profile to stop noise")
|
18
|
-
|
18
|
+
shell "sed -i 's/^mesg n/# mesg n/' /root/.profile"
|
19
19
|
end
|
20
20
|
|
21
21
|
# Grab PL repository and install PL copy of puppet
|
@@ -23,25 +23,25 @@ module RSpecSystemPuppet::Helpers
|
|
23
23
|
if facts['osfamily'] == 'RedHat'
|
24
24
|
if facts['operatingsystem'] == 'Fedora'
|
25
25
|
# Fedora testing is probably the best for now
|
26
|
-
|
26
|
+
shell 'sed -i "0,/RE/s/enabled=0/enabled=1/" /etc/yum.repos.d/fedora-updates-testing.repo'
|
27
27
|
else
|
28
28
|
if facts['operatingsystemrelease'] =~ /^6\./
|
29
|
-
|
29
|
+
shell 'rpm -ivh http://yum.puppetlabs.com/el/6/products/x86_64/puppetlabs-release-6-6.noarch.rpm'
|
30
30
|
else
|
31
|
-
|
31
|
+
shell 'rpm -ivh http://yum.puppetlabs.com/el/5/products/x86_64/puppetlabs-release-5-6.noarch.rpm'
|
32
32
|
end
|
33
33
|
end
|
34
|
-
|
34
|
+
shell 'yum install -y puppet'
|
35
35
|
elsif facts['osfamily'] == 'Debian'
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
36
|
+
shell "wget http://apt.puppetlabs.com/puppetlabs-release-#{facts['lsbdistcodename']}.deb"
|
37
|
+
shell "dpkg -i puppetlabs-release-#{facts['lsbdistcodename']}.deb"
|
38
|
+
shell 'apt-get update'
|
39
|
+
shell 'apt-get install -y puppet'
|
40
40
|
end
|
41
41
|
|
42
42
|
# Prep modules dir
|
43
43
|
log.info("Preparing modules dir")
|
44
|
-
|
44
|
+
shell 'mkdir -p /etc/puppet/modules'
|
45
45
|
|
46
46
|
# Create alias for puppet
|
47
47
|
pp = <<-EOS
|
@@ -59,7 +59,7 @@ host { 'puppet':
|
|
59
59
|
:logger: noop
|
60
60
|
EOS
|
61
61
|
file.close
|
62
|
-
|
62
|
+
rcp(:sp => file.path, :dp => '/etc/puppet/hiera.yaml')
|
63
63
|
ensure
|
64
64
|
file.unlink
|
65
65
|
end
|
@@ -77,18 +77,18 @@ host { 'puppet':
|
|
77
77
|
node = opts[:node]
|
78
78
|
|
79
79
|
# Grab facts from node
|
80
|
-
facts =
|
80
|
+
facts = node(:node => node).facts
|
81
81
|
|
82
82
|
if facts['osfamily'] == 'RedHat'
|
83
|
-
|
83
|
+
shell(:n => node, :c => 'yum install -y puppet-server')
|
84
84
|
if facts['operatingsystemrelease'] =~ /^5\./
|
85
|
-
|
85
|
+
shell(:n => node, :c => '/etc/init.d/puppetmaster start')
|
86
86
|
else
|
87
|
-
|
87
|
+
shell(:n => node, :c => 'service puppetmaster start')
|
88
88
|
end
|
89
89
|
elsif facts['osfamily'] == 'Debian'
|
90
|
-
|
91
|
-
|
90
|
+
shell(:n => node, :c => 'apt-get install -y puppetmaster')
|
91
|
+
shell(:n => node, :c => 'service puppetmaster start')
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
@@ -122,7 +122,7 @@ host { 'puppet':
|
|
122
122
|
cmd = "puppet agent -t --detailed-exitcodes"
|
123
123
|
cmd += " --debug" if opts[:debug]
|
124
124
|
cmd += " --trace" if opts[:trace]
|
125
|
-
result =
|
125
|
+
result = shell(:n => node, :c => cmd)
|
126
126
|
|
127
127
|
if block_given?
|
128
128
|
yield(result)
|
@@ -149,7 +149,7 @@ host { 'puppet':
|
|
149
149
|
raise "Must provide :source and :module_name parameters" unless source && module_name
|
150
150
|
|
151
151
|
log.info("Now transferring module onto node")
|
152
|
-
|
152
|
+
rcp(:sp => source, :d => node, :dp => File.join(module_path, module_name))
|
153
153
|
end
|
154
154
|
|
155
155
|
# Runs puppet resource commands
|
@@ -174,7 +174,7 @@ host { 'puppet':
|
|
174
174
|
raise 'Must provide resource' unless resource
|
175
175
|
|
176
176
|
log.info("Now running puppet resource")
|
177
|
-
result =
|
177
|
+
result = shell(:n => node, :c => "puppet resource #{resource}")
|
178
178
|
|
179
179
|
if block_given?
|
180
180
|
yield(result)
|
@@ -226,18 +226,18 @@ host { 'puppet':
|
|
226
226
|
file.close
|
227
227
|
|
228
228
|
remote_path = '/tmp/puppetapply.' + rand(1000000000).to_s
|
229
|
-
r =
|
229
|
+
r = rcp(:sp => file.path, :dp => remote_path, :d => node)
|
230
230
|
file.unlink
|
231
231
|
|
232
232
|
log.info("Cat file to see contents")
|
233
|
-
|
233
|
+
shell(:n => node, :c => "cat #{remote_path}")
|
234
234
|
|
235
235
|
log.info("Now running puppet apply")
|
236
236
|
cmd = "puppet apply --detailed-exitcodes"
|
237
237
|
cmd += " --debug" if opts[:debug]
|
238
238
|
cmd += " --trace" if opts[:trace]
|
239
239
|
cmd += " #{remote_path}"
|
240
|
-
result =
|
240
|
+
result = shell(:n => node, :c => cmd)
|
241
241
|
|
242
242
|
if block_given?
|
243
243
|
yield(result)
|
@@ -265,10 +265,10 @@ host { 'puppet':
|
|
265
265
|
raise "Must specify a node" unless node
|
266
266
|
|
267
267
|
cmd = "facter -y"
|
268
|
-
result =
|
268
|
+
result = shell(:n => node, :c => cmd)
|
269
269
|
|
270
270
|
begin
|
271
|
-
facts = YAML::load(result
|
271
|
+
facts = YAML::load(result.stdout)
|
272
272
|
result.facts = facts
|
273
273
|
rescue
|
274
274
|
end
|
data/rspec-system-puppet.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
Gem::Specification.new do |s|
|
3
3
|
# Metadata
|
4
4
|
s.name = "rspec-system-puppet"
|
5
|
-
s.version = "1.
|
5
|
+
s.version = "1.2.0"
|
6
6
|
s.authors = ["Ken Barber"]
|
7
7
|
s.email = ["ken@bob.sh"]
|
8
8
|
s.homepage = "https://github.com/puppetlabs/rspec-system-puppet"
|
@@ -16,5 +16,5 @@ Gem::Specification.new do |s|
|
|
16
16
|
|
17
17
|
# Dependencies
|
18
18
|
s.required_ruby_version = '>= 1.8.7'
|
19
|
-
s.add_runtime_dependency "rspec-system", '~> 1.
|
19
|
+
s.add_runtime_dependency "rspec-system", '~> 1.5', '>= 1.5.0'
|
20
20
|
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: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
8
|
+
- 2
|
9
9
|
- 0
|
10
|
-
version: 1.
|
10
|
+
version: 1.2.0
|
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-05-
|
18
|
+
date: 2013-05-30 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rspec-system
|
@@ -25,19 +25,19 @@ dependencies:
|
|
25
25
|
requirements:
|
26
26
|
- - ~>
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
hash:
|
28
|
+
hash: 5
|
29
29
|
segments:
|
30
30
|
- 1
|
31
|
-
-
|
32
|
-
version: "1.
|
31
|
+
- 5
|
32
|
+
version: "1.5"
|
33
33
|
- - ">="
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
hash:
|
35
|
+
hash: 3
|
36
36
|
segments:
|
37
37
|
- 1
|
38
|
-
-
|
38
|
+
- 5
|
39
39
|
- 0
|
40
|
-
version: 1.
|
40
|
+
version: 1.5.0
|
41
41
|
type: :runtime
|
42
42
|
version_requirements: *id001
|
43
43
|
description:
|