rspec-system-puppet 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -42,6 +42,63 @@ module RSpecSystemPuppet::Helpers
42
42
  # Prep modules dir
43
43
  log.info("Preparing modules dir")
44
44
  system_run('mkdir -p /etc/puppet/modules')
45
+
46
+ pp = <<-EOS
47
+ host { 'puppet':
48
+ ip => '127.0.0.1',
49
+ }
50
+ EOS
51
+ puppet_apply(pp)
52
+ end
53
+
54
+ # Basic helper to install a puppet master
55
+ #
56
+ # @param opts [Hash] a hash of opts
57
+ def puppet_master_install
58
+ # Defaults etc.
59
+ opts = {
60
+ :node => rspec_system_node_set.default_node,
61
+ }
62
+
63
+ node = opts[:node]
64
+
65
+ # Grab facts from node
66
+ facts = system_node(:node => node).facts
67
+
68
+ if facts['osfamily'] == 'RedHat'
69
+ system_run(:n => node, :c => 'yum install -y puppet-server')
70
+ if facts['operatingsystemrelease'] =~ /^5\./
71
+ system_run(:n => node, :c => '/etc/init.d/puppetmaster start')
72
+ else
73
+ system_run(:n => node, :c => 'service puppetmaster start')
74
+ end
75
+ elsif facts['osfamily'] == 'Debian'
76
+ system_run(:n => node, :c => 'apt-get install -y puppetmaster')
77
+ system_run(:n => node, :c => 'service puppetmaster start')
78
+ end
79
+ end
80
+
81
+ # Run puppet agent
82
+ #
83
+ # @param opts [Hash] a hash of opts
84
+ # @return [Hash] a hash of results
85
+ # @yield [result] yields result when called as a block
86
+ # @yieldparam result [Hash] a hash containing :exit_code, :stdout and :stderr
87
+ def puppet_agent
88
+ # Defaults etc.
89
+ opts = {
90
+ :node => rspec_system_node_set.default_node,
91
+ }
92
+
93
+ node = opts[:node]
94
+
95
+ result = system_run(:n => node, :c => 'puppet agent -t --detailed-exitcodes')
96
+
97
+ if block_given?
98
+ yield(result)
99
+ else
100
+ result
101
+ end
45
102
  end
46
103
 
47
104
  # Helper to copy a module onto a node from source
@@ -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.3.1"
5
+ s.version = "0.3.2"
6
6
  s.authors = ["Ken Barber"]
7
7
  s.email = ["ken@bob.sh"]
8
8
  s.homepage = "https://github.com/kbarber/rspec-system-puppet"
@@ -5,6 +5,15 @@ describe "basic tests:" do
5
5
  puppet_install()
6
6
  end
7
7
 
8
+ it 'check master install works' do
9
+ puppet_master_install()
10
+
11
+ puppet_agent do |r|
12
+ r[:stderr].should == ''
13
+ r[:exit_code].should == 0
14
+ end
15
+ end
16
+
8
17
  it 'facter domain should return something valid' do
9
18
  system_run("facter domain") do |r|
10
19
  r[:stdout].should =~ /[a-z]+/
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: 17
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 1
10
- version: 0.3.1
9
+ - 2
10
+ version: 0.3.2
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-13 00:00:00 Z
18
+ date: 2013-04-15 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rspec-system