rspec-system-puppet 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,7 +5,7 @@ module RSpecSystemPuppet::Helpers
5
5
  include RSpecSystem::Log
6
6
 
7
7
  # Basic helper to install puppet
8
- def system_puppet_install(options = {})
8
+ def puppet_install(options = {})
9
9
  # Grab facts from node
10
10
  facts = system_node.facts
11
11
 
@@ -19,7 +19,16 @@ module RSpecSystemPuppet::Helpers
19
19
  # Grab PL repository and install PL copy of puppet
20
20
  log.info "Starting installation of puppet from PL repos"
21
21
  if facts['osfamily'] == 'RedHat'
22
- system_run('rpm -ivh http://yum.puppetlabs.com/el/5/products/i386/puppetlabs-release-5-6.noarch.rpm')
22
+ if facts['operatingsystem'] == 'Fedora'
23
+ # Fedora testing is probably the best for now
24
+ system_run('sed -i "0,/RE/s/enabled=0/enabled=1/" /etc/yum.repos.d/fedora-updates-testing.repo')
25
+ else
26
+ if facts['operatingsystemrelease'] =~ /^6\./
27
+ system_run('rpm -ivh http://yum.puppetlabs.com/el/6/products/x86_64/puppetlabs-release-6-6.noarch.rpm')
28
+ else
29
+ system_run('rpm -ivh http://yum.puppetlabs.com/el/5/products/x86_64/puppetlabs-release-5-6.noarch.rpm')
30
+ end
31
+ end
23
32
  system_run('yum install -y puppet')
24
33
  elsif facts['osfamily'] == 'Debian'
25
34
  system_run("wget http://apt.puppetlabs.com/puppetlabs-release-#{facts['lsbdistcodename']}.deb")
@@ -34,7 +43,7 @@ module RSpecSystemPuppet::Helpers
34
43
  end
35
44
 
36
45
  # Helper to copy a module onto a node from source
37
- def system_puppet_module_from_path(options)
46
+ def puppet_module_install(options)
38
47
  # Defaults etc.
39
48
  options = {
40
49
  :node => rspec_system_node_set.default_node,
@@ -51,4 +60,30 @@ module RSpecSystemPuppet::Helpers
51
60
  log.info("Now transferring module onto node")
52
61
  system_rcp(:sp => source, :d => node, :dp => File.join(module_path, module_name))
53
62
  end
63
+
64
+ # Runs puppet resource commands
65
+ def puppet_resource(opts)
66
+ if opts.is_a?(String)
67
+ opts = {:resource => opts}
68
+ end
69
+
70
+ # Defaults
71
+ opts = {
72
+ :node => rspec_system_node_set.default_node
73
+ }.merge(opts)
74
+
75
+ resource = opts[:resource]
76
+ node = opts[:node]
77
+
78
+ raise 'Must provide resource' unless resource
79
+
80
+ log.info("Now running puppet resource")
81
+ result = system_run(:n => node, :c => "puppet resource #{resource}")
82
+
83
+ if block_given?
84
+ yield(result)
85
+ else
86
+ result
87
+ end
88
+ end
54
89
  end
@@ -2,7 +2,7 @@
2
2
  Gem::Specification.new do |s|
3
3
  # Metadata
4
4
  s.name = "rspec-system-puppet"
5
- s.version = "0.2.0"
5
+ s.version = "0.3.0"
6
6
  s.authors = ["Ken Barber"]
7
7
  s.email = ["ken@bob.sh"]
8
8
  s.homepage = "https://github.com/kbarber/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", '~> 0.2.0'
19
+ s.add_runtime_dependency "rspec-system", '~> 0.3.0'
20
20
  end
@@ -1,7 +1,14 @@
1
1
  require 'spec_helper_system'
2
2
 
3
3
  describe "basic tests:" do
4
- it "check system_puppet_install works" do
5
- system_puppet_install()
4
+ it "check puppet_install works" do
5
+ puppet_install()
6
+ end
7
+
8
+ it 'check puppet_resource returns an exit code of 0' do
9
+ puppet_resource('user') do |r|
10
+ r[:exit_code].should == 0
11
+ r[:stderr].should == ''
12
+ end
6
13
  end
7
14
  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: 23
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 2
8
+ - 3
9
9
  - 0
10
- version: 0.2.0
10
+ version: 0.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ken Barber
@@ -25,12 +25,12 @@ dependencies:
25
25
  requirements:
26
26
  - - ~>
27
27
  - !ruby/object:Gem::Version
28
- hash: 23
28
+ hash: 19
29
29
  segments:
30
30
  - 0
31
- - 2
31
+ - 3
32
32
  - 0
33
- version: 0.2.0
33
+ version: 0.3.0
34
34
  type: :runtime
35
35
  version_requirements: *id001
36
36
  description: