puppet 0.13.6 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puppet might be problematic. Click here for more details.

Files changed (149) hide show
  1. data/CHANGELOG +57 -0
  2. data/Rakefile +38 -410
  3. data/bin/puppet +14 -12
  4. data/bin/puppetca +1 -3
  5. data/bin/puppetd +25 -7
  6. data/bin/puppetdoc +161 -104
  7. data/bin/puppetmasterd +4 -4
  8. data/conf/epm.list +8 -0
  9. data/conf/redhat/client.init +6 -1
  10. data/conf/redhat/no-chuser-0.15.1.patch +38 -0
  11. data/conf/redhat/puppet.spec +20 -5
  12. data/conf/redhat/puppetd.conf +1 -1
  13. data/conf/redhat/puppetmasterd.conf +1 -1
  14. data/conf/redhat/server.init +2 -4
  15. data/examples/code/snippets/{casestatement → casestatement.pp} +12 -1
  16. data/examples/code/snippets/selectorvalues.pp +15 -0
  17. data/examples/code/snippets/singleselector.pp +22 -0
  18. data/examples/code/snippets/tag.pp +9 -0
  19. data/ext/module_puppet +1 -1
  20. data/install.rb +303 -303
  21. data/lib/puppet.rb +7 -9
  22. data/lib/puppet/client.rb +18 -5
  23. data/lib/puppet/client/dipper.rb +12 -10
  24. data/lib/puppet/client/master.rb +113 -41
  25. data/lib/puppet/client/pelement.rb +20 -0
  26. data/lib/puppet/config.rb +113 -6
  27. data/lib/puppet/element.rb +1 -3
  28. data/lib/puppet/event.rb +12 -23
  29. data/lib/puppet/filetype.rb +93 -5
  30. data/lib/puppet/inifile.rb +201 -0
  31. data/lib/puppet/log.rb +18 -6
  32. data/lib/puppet/parameter.rb +80 -29
  33. data/lib/puppet/parser/ast.rb +6 -4
  34. data/lib/puppet/parser/ast/caseopt.rb +13 -4
  35. data/lib/puppet/parser/ast/casestatement.rb +2 -2
  36. data/lib/puppet/parser/ast/component.rb +4 -14
  37. data/lib/puppet/parser/ast/hostclass.rb +1 -1
  38. data/lib/puppet/parser/ast/leaf.rb +12 -0
  39. data/lib/puppet/parser/ast/node.rb +4 -4
  40. data/lib/puppet/parser/ast/objectdef.rb +5 -51
  41. data/lib/puppet/parser/ast/selector.rb +2 -0
  42. data/lib/puppet/parser/ast/tag.rb +26 -0
  43. data/lib/puppet/parser/interpreter.rb +89 -74
  44. data/lib/puppet/parser/lexer.rb +4 -3
  45. data/lib/puppet/parser/parser.rb +440 -378
  46. data/lib/puppet/parser/scope.rb +844 -887
  47. data/lib/puppet/server.rb +12 -1
  48. data/lib/puppet/server/authconfig.rb +166 -0
  49. data/lib/puppet/server/authstore.rb +8 -6
  50. data/lib/puppet/server/ca.rb +23 -26
  51. data/lib/puppet/server/filebucket.rb +24 -23
  52. data/lib/puppet/server/fileserver.rb +116 -47
  53. data/lib/puppet/server/master.rb +58 -19
  54. data/lib/puppet/server/pelement.rb +176 -0
  55. data/lib/puppet/server/rights.rb +78 -0
  56. data/lib/puppet/server/servlet.rb +19 -6
  57. data/lib/puppet/sslcertificates.rb +4 -2
  58. data/lib/puppet/sslcertificates/ca.rb +66 -34
  59. data/lib/puppet/storage.rb +20 -26
  60. data/lib/puppet/transaction.rb +49 -92
  61. data/lib/puppet/type.rb +142 -35
  62. data/lib/puppet/type/cron.rb +29 -14
  63. data/lib/puppet/type/exec.rb +92 -35
  64. data/lib/puppet/type/group.rb +29 -11
  65. data/lib/puppet/type/nameservice.rb +50 -1
  66. data/lib/puppet/type/nameservice/netinfo.rb +68 -1
  67. data/lib/puppet/type/nameservice/objectadd.rb +1 -0
  68. data/lib/puppet/type/package.rb +150 -109
  69. data/lib/puppet/type/package/apple.rb +27 -0
  70. data/lib/puppet/type/package/apt.rb +1 -0
  71. data/lib/puppet/type/package/darwinport.rb +97 -0
  72. data/lib/puppet/type/package/dpkg.rb +10 -2
  73. data/lib/puppet/type/package/freebsd.rb +19 -0
  74. data/lib/puppet/type/package/{bsd.rb → openbsd.rb} +36 -7
  75. data/lib/puppet/type/package/ports.rb +98 -0
  76. data/lib/puppet/type/package/rpm.rb +43 -7
  77. data/lib/puppet/type/package/sun.rb +53 -36
  78. data/lib/puppet/type/package/yum.rb +5 -16
  79. data/lib/puppet/type/parsedtype.rb +41 -29
  80. data/lib/puppet/type/parsedtype/host.rb +13 -5
  81. data/lib/puppet/type/parsedtype/mount.rb +250 -0
  82. data/lib/puppet/type/parsedtype/port.rb +8 -6
  83. data/lib/puppet/type/pfile.rb +284 -30
  84. data/lib/puppet/type/pfile/checksum.rb +96 -68
  85. data/lib/puppet/type/pfile/content.rb +16 -13
  86. data/lib/puppet/type/pfile/ensure.rb +64 -126
  87. data/lib/puppet/type/pfile/group.rb +12 -5
  88. data/lib/puppet/type/pfile/mode.rb +16 -4
  89. data/lib/puppet/type/pfile/source.rb +47 -73
  90. data/lib/puppet/type/pfile/target.rb +81 -0
  91. data/lib/puppet/type/pfile/uid.rb +10 -3
  92. data/lib/puppet/type/pfilebucket.rb +12 -3
  93. data/lib/puppet/type/schedule.rb +5 -1
  94. data/lib/puppet/type/service.rb +138 -66
  95. data/lib/puppet/type/service/debian.rb +9 -3
  96. data/lib/puppet/type/service/init.rb +51 -56
  97. data/lib/puppet/type/service/smf.rb +16 -6
  98. data/lib/puppet/type/state.rb +71 -32
  99. data/lib/puppet/type/symlink.rb +12 -7
  100. data/lib/puppet/type/tidy.rb +5 -1
  101. data/lib/puppet/type/user.rb +116 -20
  102. data/lib/puppet/type/yumrepo.rb +314 -0
  103. data/lib/puppet/util.rb +84 -14
  104. data/test/client/client.rb +41 -18
  105. data/test/client/master.rb +50 -4
  106. data/test/executables/puppetbin.rb +31 -4
  107. data/test/executables/puppetca.rb +18 -2
  108. data/test/language/ast.rb +201 -31
  109. data/test/language/interpreter.rb +8 -2
  110. data/test/{parser → language}/lexer.rb +1 -1
  111. data/test/language/node.rb +84 -0
  112. data/test/{parser → language}/parser.rb +1 -1
  113. data/test/language/scope.rb +101 -2
  114. data/test/language/snippets.rb +23 -2
  115. data/test/other/config.rb +99 -1
  116. data/test/other/filetype.rb +95 -0
  117. data/test/other/inifile.rb +114 -0
  118. data/test/other/log.rb +3 -2
  119. data/test/other/transactions.rb +55 -10
  120. data/test/puppet/utiltest.rb +25 -1
  121. data/test/puppettest.rb +140 -46
  122. data/test/server/authconfig.rb +56 -0
  123. data/test/server/bucket.rb +32 -18
  124. data/test/server/fileserver.rb +75 -30
  125. data/test/server/master.rb +27 -4
  126. data/test/server/pelement.rb +298 -0
  127. data/test/server/rights.rb +41 -0
  128. data/test/server/server.rb +2 -2
  129. data/test/tagging/tagging.rb +100 -1
  130. data/test/types/basic.rb +3 -3
  131. data/test/types/cron.rb +24 -1
  132. data/test/types/exec.rb +99 -1
  133. data/test/types/file.rb +298 -2
  134. data/test/types/filebucket.rb +4 -15
  135. data/test/types/filesources.rb +43 -14
  136. data/test/types/group.rb +1 -13
  137. data/test/types/mount.rb +277 -0
  138. data/test/types/package.rb +164 -33
  139. data/test/types/parameter.rb +107 -0
  140. data/test/types/port.rb +2 -1
  141. data/test/types/service.rb +37 -2
  142. data/test/types/state.rb +92 -0
  143. data/test/types/symlink.rb +30 -2
  144. data/test/types/tidy.rb +2 -14
  145. data/test/types/type.rb +35 -1
  146. data/test/types/user.rb +110 -1
  147. data/test/types/yumrepo.rb +95 -0
  148. metadata +316 -290
  149. data/test/types/filetype.rb +0 -160
@@ -0,0 +1,314 @@
1
+ # Description of yum repositories
2
+
3
+ require 'puppet/statechange'
4
+ require 'puppet/inifile'
5
+ require 'puppet/type/parsedtype'
6
+
7
+ module Puppet
8
+
9
+ # A state for one entry in a .ini-style file
10
+ class IniState < Puppet::State
11
+
12
+ def insync?
13
+ # A should state of :absent is the same as nil
14
+ if is.nil? && (should.nil? || should == :absent)
15
+ return true
16
+ end
17
+ return super
18
+ end
19
+
20
+ def sync
21
+ if insync?
22
+ result = nil
23
+ else
24
+ result = set
25
+ parent.section[inikey] = should
26
+ end
27
+ return result
28
+ end
29
+
30
+ def retrieve
31
+ @is = parent.section[inikey]
32
+ end
33
+
34
+ def inikey
35
+ name.to_s
36
+ end
37
+
38
+ # Set the key associated with this state to KEY, instead
39
+ # of using the state's NAME
40
+ def self.inikey(key)
41
+ # Override the inikey instance method
42
+ # Is there a way to do this without resorting to strings ?
43
+ # Using a block fails because the block can't access
44
+ # the variable 'key' in the outer scope
45
+ self.class_eval("def inikey ; \"#{key.to_s}\" ; end")
46
+ end
47
+
48
+ end
49
+
50
+ # Doc string for states that can be made 'absent'
51
+ ABSENT_DOC="Set this to 'absent' to remove it from the file completely"
52
+
53
+ newtype(:yumrepo) do
54
+ @doc = "The client-side description of a yum repository. Repository
55
+ configurations are found by parsing /etc/yum.conf and
56
+ the files indicated by reposdir in that file (see yum.conf(5)
57
+ for details)
58
+
59
+ Most parameters are identical to the ones documented
60
+ in yum.conf(5)
61
+
62
+ Continuation lines that yum supports for example for the
63
+ baseurl are not supported. No attempt is made to access
64
+ files included with the **include** directive"
65
+
66
+ class << self
67
+ attr_accessor :filetype
68
+ # The writer is only used for testing, there should be no need
69
+ # to change yumconf in any other context
70
+ attr_accessor :yumconf
71
+ end
72
+
73
+ self.filetype = Puppet::FileType.filetype(:flat)
74
+
75
+ @inifile = nil
76
+
77
+ @yumconf = "/etc/yum.conf"
78
+
79
+ # Where to put files for brand new sections
80
+ @defaultrepodir = nil
81
+
82
+ # Return the Puppet::IniConfig::File for the whole yum config
83
+ def self.inifile
84
+ if @inifile.nil?
85
+ @inifile = read()
86
+ main = @inifile['main']
87
+ if main.nil?
88
+ raise Puppet::Error, "File #{yumconf} does not contain a main section"
89
+ end
90
+ reposdir = main['reposdir']
91
+ reposdir ||= "/etc/yum.repos.d, /etc/yum/repos.d"
92
+ reposdir.gsub!(/[\n,]/, " ")
93
+ reposdir.split.each do |dir|
94
+ Dir::glob("#{dir}/*.repo").each do |file|
95
+ if File.file?(file)
96
+ @inifile.read(file)
97
+ end
98
+ end
99
+ end
100
+ reposdir.split.each do |dir|
101
+ if File::directory?(dir) && File::writable?(dir)
102
+ @defaultrepodir = dir
103
+ break
104
+ end
105
+ end
106
+ end
107
+ return @inifile
108
+ end
109
+
110
+ # Parse the yum config files. Only exposed for the tests
111
+ # Non-test code should use self.inifile to get at the
112
+ # underlying file
113
+ def self.read
114
+ result = Puppet::IniConfig::File.new()
115
+ result.read(yumconf)
116
+ main = result['main']
117
+ if main.nil?
118
+ raise Puppet::Error, "File #{yumconf} does not contain a main section"
119
+ end
120
+ reposdir = main['reposdir']
121
+ reposdir ||= "/etc/yum.repos.d, /etc/yum/repos.d"
122
+ reposdir.gsub!(/[\n,]/, " ")
123
+ reposdir.split.each do |dir|
124
+ Dir::glob("#{dir}/*.repo").each do |file|
125
+ if File.file?(file)
126
+ result.read(file)
127
+ end
128
+ end
129
+ end
130
+ if @defaultrepodir.nil?
131
+ reposdir.split.each do |dir|
132
+ if File::directory?(dir) && File::writable?(dir)
133
+ @defaultrepodir = dir
134
+ break
135
+ end
136
+ end
137
+ end
138
+ return result
139
+ end
140
+
141
+ # Return the Puppet::IniConfig::Section with name NAME
142
+ # from the yum config
143
+ def self.section(name)
144
+ result = inifile[name]
145
+ if result.nil?
146
+ # Brand new section
147
+ path = yumconf
148
+ unless @defaultrepodir.nil?
149
+ path = File::join(@defaultrepodir, "#{name}.repo")
150
+ end
151
+ Puppet::info "create new repo #{name} in file #{path}"
152
+ result = inifile.add_section(name, path)
153
+ end
154
+ return result
155
+ end
156
+
157
+ # Store all modifications back to disk
158
+ def self.store
159
+ inifile.store
160
+ end
161
+
162
+ def self.clear
163
+ @inifile = nil
164
+ @yumconf = "/etc/yum.conf"
165
+ @defaultrepodir = nil
166
+ end
167
+
168
+ # Return the Puppet::IniConfig::Section for this yumrepo element
169
+ def section
170
+ self.class.section(self[:name])
171
+ end
172
+
173
+ def evaluate
174
+ changes = super
175
+ # FIXME: Dirty, dirty hack
176
+ # We amend the go method of the last change to trigger
177
+ # writing the whole file
178
+ # A cleaner solution would be to either use the composite
179
+ # pattern and encapsulate all changes into a change that does
180
+ # not depend on a state and triggers storing, or insert another
181
+ # change at the end of changes to trigger storing Both
182
+ # solutions require that the StateChange interface be
183
+ # abstracted so that it can work with a change that is not
184
+ # directly backed by a State
185
+ unless changes.empty?
186
+ class << changes[-1]
187
+ def go
188
+ result = super
189
+ self.state.parent.store
190
+ return result
191
+ end
192
+ end
193
+ end
194
+ return changes
195
+ end
196
+
197
+ # Store modifications to this yumrepo element back to disk
198
+ def store
199
+ self.class.store
200
+ end
201
+
202
+ newparam(:name) do
203
+ desc "The name of the repository."
204
+ isnamevar
205
+ end
206
+
207
+ newstate(:descr, Puppet::IniState) do
208
+ desc "A human readable description of the repository.
209
+ #{ABSENT_DOC}"
210
+ newvalue(:absent) { self.should = :absent }
211
+ newvalue(/.*/) { }
212
+ inikey "name"
213
+ end
214
+
215
+ newstate(:mirrorlist, Puppet::IniState) do
216
+ desc "The URL that holds the list of mirrors for this repository.
217
+ #{ABSENT_DOC}"
218
+ newvalue(:absent) { self.should = :absent }
219
+ # Should really check that it's a valid URL
220
+ newvalue(/.*/) { }
221
+ end
222
+
223
+ newstate(:baseurl, Puppet::IniState) do
224
+ desc "The URL for this repository.\n#{ABSENT_DOC}"
225
+ newvalue(:absent) { self.should = :absent }
226
+ # Should really check that it's a valid URL
227
+ newvalue(/.*/) { }
228
+ end
229
+
230
+ newstate(:enabled, Puppet::IniState) do
231
+ desc "Whether this repository is enabled or disabled. Possible
232
+ values are '0', and '1'.\n#{ABSENT_DOC}"
233
+ newvalue(:absent) { self.should = :absent }
234
+ newvalue(%r{(0|1)}) { }
235
+ end
236
+
237
+ newstate(:gpgcheck, Puppet::IniState) do
238
+ desc "Whether to check the GPG signature on packages installed
239
+ from this repository. Possible values are '0', and '1'.
240
+ \n#{ABSENT_DOC}"
241
+ newvalue(:absent) { self.should = :absent }
242
+ newvalue(%r{(0|1)}) { }
243
+ end
244
+
245
+ newstate(:gpgkey, Puppet::IniState) do
246
+ desc "The URL for the GPG key with which packages from this
247
+ repository are signed.\n#{ABSENT_DOC}"
248
+ newvalue(:absent) { self.should = :absent }
249
+ # Should really check that it's a valid URL
250
+ newvalue(/.*/) { }
251
+ end
252
+
253
+ newstate(:include, Puppet::IniState) do
254
+ desc "A URL from which to include the config.\n#{ABSENT_DOC}"
255
+ newvalue(:absent) { self.should = :absent }
256
+ # Should really check that it's a valid URL
257
+ newvalue(/.*/) { }
258
+ end
259
+
260
+ newstate(:exclude, Puppet::IniState) do
261
+ desc "List of shell globs. Matching packages will never be
262
+ considered in updates or installs for this repo.
263
+ #{ABSENT_DOC}"
264
+ newvalue(:absent) { self.should = :absent }
265
+ newvalue(/.*/) { }
266
+ end
267
+
268
+ newstate(:includepkgs, Puppet::IniState) do
269
+ desc "List of shell globs. If this is set, only packages
270
+ matching one of the globs will be considered for
271
+ update or install.\n#{ABSENT_DOC}"
272
+ newvalue(:absent) { self.should = :absent }
273
+ newvalue(/.*/) { }
274
+ end
275
+
276
+ newstate(:enablegroups, Puppet::IniState) do
277
+ desc "Determines whether yum will allow the use of
278
+ package groups for this repository. Possible
279
+ values are '0', and '1'.\n#{ABSENT_DOC}"
280
+ newvalue(:absent) { self.should = :absent }
281
+ newvalue(%r{(0|1)}) { }
282
+ end
283
+
284
+ newstate(:failovermethod, Puppet::IniState) do
285
+ desc "Either 'roundrobin' or 'priority'.\n#{ABSENT_DOC}"
286
+ newvalue(:absent) { self.should = :absent }
287
+ newvalue(%r(roundrobin|priority)) { }
288
+ end
289
+
290
+ newstate(:keepalive, Puppet::IniState) do
291
+ desc "Either '1' or '0'. This tells yum whether or not HTTP/1.1
292
+ keepalive should be used with this repository.\n#{ABSENT_DOC}"
293
+ newvalue(:absent) { self.should = :absent }
294
+ newvalue(%r{(0|1)}) { }
295
+ end
296
+
297
+ newstate(:timeout, Puppet::IniState) do
298
+ desc "Number of seconds to wait for a connection before timing
299
+ out.\n#{ABSENT_DOC}"
300
+ newvalue(:absent) { self.should = :absent }
301
+ newvalue(%r{[0-9]+}) { }
302
+ end
303
+
304
+ newstate(:metadata_expire, Puppet::IniState) do
305
+ desc "Number of seconds after which the metadata will expire.
306
+ #{ABSENT_DOC}"
307
+ newvalue(:absent) { self.should = :absent }
308
+ newvalue(%r{[0-9]+}) { }
309
+ end
310
+
311
+
312
+
313
+ end
314
+ end
@@ -5,6 +5,8 @@ require 'puppet/lock'
5
5
 
6
6
  module Puppet
7
7
  module Util
8
+ require 'benchmark'
9
+
8
10
  # Create a sync point for any threads
9
11
  @@sync = Sync.new
10
12
  # Execute a block as a given user or group
@@ -16,6 +18,13 @@ module Util
16
18
  olduid = nil
17
19
  oldgid = nil
18
20
 
21
+ # If they're running as a normal user, then just execute as that same
22
+ # user.
23
+ unless Process.uid == 0
24
+ yield
25
+ return
26
+ end
27
+
19
28
  begin
20
29
  # the groupid, if we got passed a group
21
30
  # The gid has to be changed first, because, well, otherwise we won't
@@ -27,13 +36,17 @@ module Util
27
36
  gid = self.gid(group)
28
37
  end
29
38
 
30
- if Process.gid != gid
31
- oldgid = Process.gid
32
- begin
33
- Process.egid = gid
34
- rescue => detail
35
- raise Puppet::Error, "Could not change GID: %s" % detail
39
+ if gid
40
+ if Process.gid != gid
41
+ oldgid = Process.gid
42
+ begin
43
+ Process.egid = gid
44
+ rescue => detail
45
+ raise Puppet::Error, "Could not change GID: %s" % detail
46
+ end
36
47
  end
48
+ else
49
+ Puppet.warning "Could not retrieve GID for %s" % group
37
50
  end
38
51
  end
39
52
 
@@ -44,14 +57,19 @@ module Util
44
57
  uid = self.uid(user)
45
58
  end
46
59
  uid = self.uid(user)
47
- # Now change the uid
48
- if Process.uid != uid
49
- olduid = Process.uid
50
- begin
51
- Process.euid = uid
52
- rescue => detail
53
- raise Puppet::Error, "Could not change UID: %s" % detail
60
+
61
+ if uid
62
+ # Now change the uid
63
+ if Process.uid != uid
64
+ olduid = Process.uid
65
+ begin
66
+ Process.euid = uid
67
+ rescue => detail
68
+ raise Puppet::Error, "Could not change UID: %s" % detail
69
+ end
54
70
  end
71
+ else
72
+ Puppet.warning "Could not retrieve UID for %s" % user
55
73
  end
56
74
  end
57
75
 
@@ -294,7 +312,59 @@ module Util
294
312
  File.umask(cur)
295
313
  end
296
314
  end
315
+
316
+ def benchmark(*args)
317
+ msg = args.pop
318
+ level = args.pop
319
+ object = nil
320
+
321
+ if args.empty?
322
+ object = Puppet
323
+ else
324
+ object = args.pop
325
+ end
326
+
327
+ unless level
328
+ puts caller.join("\n")
329
+ raise Puppet::DevError, "Failed to provide level"
330
+ end
331
+
332
+ unless object.respond_to? level
333
+ raise Puppet::DevError, "Benchmarked object does not respond to %s" % level
334
+ end
335
+
336
+ # Only benchmark if our log level is high enough
337
+ if Puppet::Log.sendlevel?(level)
338
+ result = nil
339
+ seconds = Benchmark.realtime {
340
+ result = yield
341
+ }
342
+ object.send(level, msg + (" in %0.2f seconds" % seconds))
343
+ result
344
+ else
345
+ yield
346
+ end
347
+ end
348
+
349
+ module_function :benchmark
350
+
351
+ def memory
352
+ unless defined? @pmap
353
+ pmap = %x{which pmap 2>/dev/null}.chomp
354
+ if pmap == ""
355
+ @pmap = nil
356
+ else
357
+ @pmap = pmap
358
+ end
359
+ end
360
+ if @pmap
361
+ return %x{pmap #{Process.pid}| grep total}.chomp.sub(/^\s*total\s+/, '').sub(/K$/, '').to_i
362
+ else
363
+ 0
364
+ end
365
+ end
366
+ module_function :memory
297
367
  end
298
368
  end
299
369
 
300
- # $Id: util.rb 967 2006-03-02 20:28:45Z luke $
370
+ # $Id: util.rb 1113 2006-04-17 16:15:33Z luke $
@@ -10,7 +10,7 @@ require 'puppet/server'
10
10
  require 'test/unit'
11
11
  require 'puppettest.rb'
12
12
 
13
- # $Id: client.rb 967 2006-03-02 20:28:45Z luke $
13
+ # $Id: client.rb 1068 2006-04-04 23:13:55Z luke $
14
14
 
15
15
  class TestClient < Test::Unit::TestCase
16
16
  include ServerTest
@@ -109,24 +109,12 @@ class TestClient < Test::Unit::TestCase
109
109
  )
110
110
  }
111
111
 
112
- # clean up the existing certs, so the server creates a new CA
113
- #system("rm -rf %s" % Puppet[:ssldir])
112
+ # Create a new ssl root.
114
113
  confdir = tempfile()
115
- Puppet[:confdir] = confdir
116
-
117
- # Now we need to recreate the directory structure
118
- [:certificates, :ca].each { |section|
119
- Puppet.config.params(section).each { |param|
120
- val = Puppet[param]
121
- if val =~ /^#{File::SEPARATOR}/
122
- if param.to_s =~ /dir/
123
- Puppet::Util.recmkdir(val)
124
- else
125
- Puppet::Util.recmkdir(File.dirname(val))
126
- end
127
- end
128
- }
129
- }
114
+ Puppet[:ssldir] = confdir
115
+ Puppet.config.mkdir(:ssldir)
116
+ Puppet.config.clearused
117
+ Puppet.config.use(:certificates, :ca)
130
118
 
131
119
  mkserver
132
120
 
@@ -150,4 +138,39 @@ class TestClient < Test::Unit::TestCase
150
138
  certbucket.backup("/etc/passwd")
151
139
  }
152
140
  end
141
+
142
+ def test_classfile
143
+ manifest = tempfile()
144
+
145
+ File.open(manifest, "w") do |file|
146
+ file.puts "class yaytest {}\n class bootest {}\n include yaytest, bootest"
147
+ end
148
+
149
+ master = client = nil
150
+ assert_nothing_raised() {
151
+ master = Puppet::Server::Master.new(
152
+ :Manifest => manifest,
153
+ :UseNodes => false,
154
+ :Local => false
155
+ )
156
+ }
157
+ assert_nothing_raised() {
158
+ client = Puppet::Client::MasterClient.new(
159
+ :Master => master
160
+ )
161
+ }
162
+
163
+ # Fake that it's local, so it creates the class file
164
+ client.local = false
165
+
166
+ assert_nothing_raised {
167
+ client.getconfig
168
+ }
169
+
170
+ assert(FileTest.exists?(Puppet[:classfile]), "Class file does not exist")
171
+
172
+ classes = File.read(Puppet[:classfile]).split("\n")
173
+
174
+ assert_equal(%w{bootest yaytest}, classes.sort)
175
+ end
153
176
  end