puppet 0.9.2 → 0.13.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.
- data/CHANGELOG +58 -0
- data/README +21 -18
- data/Rakefile +176 -36
- data/bin/puppet +34 -48
- data/bin/puppetca +41 -28
- data/bin/puppetd +87 -65
- data/bin/puppetdoc +99 -23
- data/bin/puppetmasterd +72 -91
- data/conf/redhat/client.init +80 -0
- data/conf/redhat/client.sysconfig +11 -0
- data/conf/redhat/fileserver.conf +12 -0
- data/conf/redhat/puppet.spec +130 -0
- data/conf/redhat/server.init +89 -0
- data/conf/redhat/server.sysconfig +9 -0
- data/examples/code/allatonce +2 -2
- data/examples/code/assignments +1 -1
- data/examples/code/classing +2 -2
- data/examples/code/components +2 -2
- data/examples/code/file.bl +5 -5
- data/examples/code/filedefaults +2 -2
- data/examples/code/fileparsing +1 -1
- data/examples/code/filerecursion +1 -1
- data/examples/code/functions +1 -1
- data/examples/code/groups +1 -1
- data/examples/code/importing +1 -1
- data/examples/code/nodes +1 -1
- data/examples/code/one +1 -1
- data/examples/code/relationships +2 -2
- data/examples/code/simpletests +5 -5
- data/examples/code/snippets/argumentdefaults +2 -2
- data/examples/code/snippets/casestatement +16 -8
- data/examples/code/snippets/classheirarchy.pp +4 -4
- data/examples/code/snippets/classincludes.pp +4 -4
- data/examples/code/snippets/classpathtest +2 -2
- data/examples/code/snippets/componentmetaparams.pp +11 -0
- data/examples/code/snippets/dirchmod +5 -5
- data/examples/code/snippets/emptyclass.pp +9 -0
- data/examples/code/snippets/failmissingexecpath.pp +1 -1
- data/examples/code/snippets/falsevalues.pp +1 -1
- data/examples/code/snippets/filecreate +5 -5
- data/examples/code/snippets/implicititeration +5 -5
- data/examples/code/snippets/multipleinstances +4 -4
- data/examples/code/snippets/namevartest +3 -3
- data/examples/code/snippets/scopetest +1 -1
- data/examples/code/snippets/selectorvalues.pp +3 -3
- data/examples/code/snippets/simpledefaults +2 -2
- data/examples/code/snippets/simpleselector +5 -5
- data/examples/code/snippets/singleary.pp +19 -0
- data/examples/root/etc/init.d/sleeper +3 -2
- data/ext/emacs/puppet-mode-init.el +6 -0
- data/ext/emacs/puppet-mode.el +189 -0
- data/ext/ldap/puppet.schema +17 -0
- data/ext/{module:puppet → module_puppet} +30 -31
- data/ext/vim/filetype.vim +9 -0
- data/ext/vim/puppet.vim +87 -0
- data/install.rb +63 -30
- data/lib/puppet.rb +216 -122
- data/lib/puppet/client.rb +51 -416
- data/lib/puppet/client/ca.rb +17 -0
- data/lib/puppet/client/dipper.rb +78 -0
- data/lib/puppet/client/file.rb +20 -0
- data/lib/puppet/client/log.rb +17 -0
- data/lib/puppet/client/master.rb +246 -0
- data/lib/puppet/client/proxy.rb +27 -0
- data/lib/puppet/client/status.rb +7 -0
- data/lib/puppet/config.rb +563 -13
- data/lib/puppet/daemon.rb +50 -22
- data/lib/puppet/element.rb +4 -4
- data/lib/puppet/event-loop.rb +1 -0
- data/lib/puppet/event-loop/better-definers.rb +367 -0
- data/lib/puppet/event-loop/event-loop.rb +355 -0
- data/lib/puppet/event-loop/signal-system.rb +220 -0
- data/lib/puppet/event.rb +9 -11
- data/lib/puppet/filetype.rb +195 -0
- data/lib/puppet/log.rb +35 -12
- data/lib/puppet/metric.rb +2 -2
- data/lib/puppet/networkclient.rb +145 -0
- data/lib/puppet/parameter.rb +335 -0
- data/lib/puppet/parser/ast.rb +42 -1453
- data/lib/puppet/parser/ast/astarray.rb +88 -0
- data/lib/puppet/parser/ast/branch.rb +47 -0
- data/lib/puppet/parser/ast/caseopt.rb +66 -0
- data/lib/puppet/parser/ast/casestatement.rb +78 -0
- data/lib/puppet/parser/ast/classdef.rb +78 -0
- data/lib/puppet/parser/ast/compdef.rb +111 -0
- data/lib/puppet/parser/ast/component.rb +105 -0
- data/lib/puppet/parser/ast/hostclass.rb +82 -0
- data/lib/puppet/parser/ast/leaf.rb +86 -0
- data/lib/puppet/parser/ast/node.rb +103 -0
- data/lib/puppet/parser/ast/nodedef.rb +68 -0
- data/lib/puppet/parser/ast/objectdef.rb +336 -0
- data/lib/puppet/parser/ast/objectparam.rb +30 -0
- data/lib/puppet/parser/ast/objectref.rb +76 -0
- data/lib/puppet/parser/ast/selector.rb +60 -0
- data/lib/puppet/parser/ast/typedefaults.rb +45 -0
- data/lib/puppet/parser/ast/vardef.rb +44 -0
- data/lib/puppet/parser/interpreter.rb +31 -14
- data/lib/puppet/parser/lexer.rb +2 -4
- data/lib/puppet/parser/parser.rb +332 -242
- data/lib/puppet/parser/scope.rb +55 -38
- data/lib/puppet/server.rb +43 -44
- data/lib/puppet/server/authstore.rb +3 -6
- data/lib/puppet/server/ca.rb +5 -2
- data/lib/puppet/server/filebucket.rb +2 -4
- data/lib/puppet/server/fileserver.rb +28 -12
- data/lib/puppet/server/logger.rb +15 -4
- data/lib/puppet/server/master.rb +62 -7
- data/lib/puppet/sslcertificates.rb +41 -607
- data/lib/puppet/sslcertificates/ca.rb +291 -0
- data/lib/puppet/sslcertificates/certificate.rb +283 -0
- data/lib/puppet/statechange.rb +6 -1
- data/lib/puppet/storage.rb +67 -56
- data/lib/puppet/transaction.rb +25 -9
- data/lib/puppet/transportable.rb +102 -22
- data/lib/puppet/type.rb +1096 -315
- data/lib/puppet/type/component.rb +30 -21
- data/lib/puppet/type/cron.rb +409 -448
- data/lib/puppet/type/exec.rb +234 -174
- data/lib/puppet/type/group.rb +65 -82
- data/lib/puppet/type/nameservice.rb +247 -3
- data/lib/puppet/type/nameservice/netinfo.rb +29 -40
- data/lib/puppet/type/nameservice/objectadd.rb +52 -66
- data/lib/puppet/type/nameservice/posix.rb +6 -194
- data/lib/puppet/type/package.rb +447 -295
- data/lib/puppet/type/package/apt.rb +51 -50
- data/lib/puppet/type/package/bsd.rb +82 -0
- data/lib/puppet/type/package/dpkg.rb +85 -88
- data/lib/puppet/type/package/rpm.rb +67 -63
- data/lib/puppet/type/package/sun.rb +119 -98
- data/lib/puppet/type/package/yum.rb +41 -37
- data/lib/puppet/type/parsedtype.rb +295 -0
- data/lib/puppet/type/parsedtype/host.rb +143 -0
- data/lib/puppet/type/parsedtype/port.rb +232 -0
- data/lib/puppet/type/parsedtype/sshkey.rb +129 -0
- data/lib/puppet/type/pfile.rb +484 -460
- data/lib/puppet/type/pfile/checksum.rb +237 -181
- data/lib/puppet/type/pfile/content.rb +67 -0
- data/lib/puppet/type/pfile/ensure.rb +212 -0
- data/lib/puppet/type/pfile/group.rb +106 -105
- data/lib/puppet/type/pfile/mode.rb +98 -101
- data/lib/puppet/type/pfile/source.rb +228 -209
- data/lib/puppet/type/pfile/type.rb +18 -21
- data/lib/puppet/type/pfile/uid.rb +127 -130
- data/lib/puppet/type/pfilebucket.rb +68 -63
- data/lib/puppet/type/schedule.rb +341 -0
- data/lib/puppet/type/service.rb +351 -255
- data/lib/puppet/type/service/base.rb +9 -14
- data/lib/puppet/type/service/debian.rb +32 -38
- data/lib/puppet/type/service/init.rb +130 -130
- data/lib/puppet/type/service/smf.rb +48 -20
- data/lib/puppet/type/state.rb +229 -16
- data/lib/puppet/type/symlink.rb +51 -63
- data/lib/puppet/type/tidy.rb +105 -102
- data/lib/puppet/type/user.rb +118 -180
- data/lib/puppet/util.rb +100 -6
- data/test/certmgr/certmgr.rb +0 -1
- data/test/client/client.rb +4 -4
- data/test/executables/puppetbin.rb +7 -14
- data/test/executables/puppetca.rb +18 -24
- data/test/executables/puppetd.rb +7 -16
- data/test/executables/puppetmasterd.rb +7 -9
- data/test/executables/puppetmodule.rb +11 -16
- data/test/language/ast.rb +11 -7
- data/test/language/interpreter.rb +1 -1
- data/test/language/scope.rb +2 -0
- data/test/language/snippets.rb +30 -5
- data/test/language/transportable.rb +77 -0
- data/test/other/config.rb +316 -0
- data/test/other/events.rb +22 -21
- data/test/other/log.rb +14 -14
- data/test/other/metrics.rb +4 -8
- data/test/other/overrides.rb +5 -5
- data/test/other/relationships.rb +4 -2
- data/test/other/storage.rb +64 -3
- data/test/other/transactions.rb +20 -20
- data/test/parser/parser.rb +7 -4
- data/test/puppet/conffiles.rb +12 -12
- data/test/puppet/defaults.rb +13 -11
- data/test/puppet/utiltest.rb +14 -11
- data/test/puppettest.rb +156 -48
- data/test/server/bucket.rb +2 -2
- data/test/server/fileserver.rb +6 -6
- data/test/server/logger.rb +19 -11
- data/test/server/master.rb +33 -4
- data/test/server/server.rb +2 -7
- data/test/types/basic.rb +5 -7
- data/test/types/component.rb +22 -18
- data/test/types/cron.rb +111 -44
- data/test/types/exec.rb +116 -59
- data/test/types/file.rb +262 -137
- data/test/types/filebucket.rb +13 -15
- data/test/types/fileignoresource.rb +12 -16
- data/test/types/filesources.rb +73 -48
- data/test/types/filetype.rb +13 -15
- data/test/types/group.rb +15 -13
- data/test/types/host.rb +146 -0
- data/test/types/package.rb +74 -63
- data/test/types/port.rb +139 -0
- data/test/types/query.rb +8 -8
- data/test/types/schedule.rb +335 -0
- data/test/types/service.rb +137 -21
- data/test/types/sshkey.rb +140 -0
- data/test/types/symlink.rb +3 -5
- data/test/types/tidy.rb +5 -14
- data/test/types/type.rb +67 -11
- data/test/types/user.rb +25 -23
- metadata +186 -122
- data/lib/puppet/type/pfile/create.rb +0 -108
- data/lib/puppet/type/pprocess.rb +0 -97
- data/lib/puppet/type/typegen.rb +0 -149
- data/lib/puppet/type/typegen/filerecord.rb +0 -243
- data/lib/puppet/type/typegen/filetype.rb +0 -316
- data/test/other/state.rb +0 -106
@@ -1,316 +0,0 @@
|
|
1
|
-
#!/usr/local/bin/ruby -w
|
2
|
-
|
3
|
-
# $Id: filetype.rb 576 2005-08-23 16:09:14Z luke $
|
4
|
-
|
5
|
-
# parse and write configuration files using objects with minimal parsing abilities
|
6
|
-
|
7
|
-
require 'puppet/type'
|
8
|
-
require 'puppet/type/typegen'
|
9
|
-
|
10
|
-
class Puppet::Type::FileType < Puppet::Type::TypeGenerator
|
11
|
-
attr_accessor :childtype
|
12
|
-
|
13
|
-
@parameters = [:name, :linesplit, :escapednewlines]
|
14
|
-
#@abstract = true
|
15
|
-
@metaclass = true
|
16
|
-
|
17
|
-
@namevar = :name
|
18
|
-
@name = :filetype
|
19
|
-
|
20
|
-
@modsystem = true
|
21
|
-
|
22
|
-
#---------------------------------------------------------------
|
23
|
-
def FileType.newtype(hash)
|
24
|
-
unless hash.include?(:linesplit)
|
25
|
-
hash[:linesplit] = "\n"
|
26
|
-
end
|
27
|
-
|
28
|
-
# i don't think there's any reason to 'super' this
|
29
|
-
#klass = Puppet::Type::TypeGenerator.newtype(hash)
|
30
|
-
klass = super(hash)
|
31
|
-
|
32
|
-
klass.escapednewlines = true
|
33
|
-
klass.namevar = :name
|
34
|
-
klass.parameters = [:name, :path, :complete]
|
35
|
-
|
36
|
-
#klass.childtype = Puppet::Type::FileRecord.newtype(
|
37
|
-
# :name => hash[:name] + "_record",
|
38
|
-
# :splitchar => hash[:recordsplit],
|
39
|
-
# :fields => hash[:fields],
|
40
|
-
# :namevar => hash[:namevar]
|
41
|
-
#)
|
42
|
-
#klass.addrecord(
|
43
|
-
# :name => hash[:name] + "_record",
|
44
|
-
# :splitchar => hash[:recordsplit],
|
45
|
-
# :fields => hash[:fields],
|
46
|
-
# :namevar => hash[:namevar]
|
47
|
-
#)
|
48
|
-
|
49
|
-
return klass
|
50
|
-
end
|
51
|
-
#---------------------------------------------------------------
|
52
|
-
|
53
|
-
#---------------------------------------------------------------
|
54
|
-
# currently not used
|
55
|
-
def FileType.addrecord(hash)
|
56
|
-
unless defined? @records
|
57
|
-
@records = {}
|
58
|
-
end
|
59
|
-
hash[:filetype] = self
|
60
|
-
|
61
|
-
# default to the naming field being the first field provided
|
62
|
-
unless hash.include?(:namevar)
|
63
|
-
hash[:namevar] = hash[:fields][0]
|
64
|
-
end
|
65
|
-
|
66
|
-
recordtype = Puppet::Type::FileRecord.newtype(hash)
|
67
|
-
@records[recordtype.name] = recordtype
|
68
|
-
end
|
69
|
-
#---------------------------------------------------------------
|
70
|
-
|
71
|
-
#---------------------------------------------------------------
|
72
|
-
def FileType.records
|
73
|
-
return @records
|
74
|
-
end
|
75
|
-
#---------------------------------------------------------------
|
76
|
-
|
77
|
-
#---------------------------------------------------------------
|
78
|
-
def FileType.escapednewlines=(value)
|
79
|
-
@escnlines = value
|
80
|
-
end
|
81
|
-
#---------------------------------------------------------------
|
82
|
-
|
83
|
-
#---------------------------------------------------------------
|
84
|
-
def FileType.escapednewlines
|
85
|
-
if ! defined? @escnlines or @escnlines.nil?
|
86
|
-
return false
|
87
|
-
else
|
88
|
-
return @escnlines
|
89
|
-
end
|
90
|
-
end
|
91
|
-
#---------------------------------------------------------------
|
92
|
-
|
93
|
-
#---------------------------------------------------------------
|
94
|
-
def FileType.childtype
|
95
|
-
unless defined? @childtype
|
96
|
-
@childtype = nil
|
97
|
-
end
|
98
|
-
return @childtype
|
99
|
-
end
|
100
|
-
#---------------------------------------------------------------
|
101
|
-
|
102
|
-
#---------------------------------------------------------------
|
103
|
-
def FileType.childtype=(childtype)
|
104
|
-
@childtype = childtype
|
105
|
-
end
|
106
|
-
#---------------------------------------------------------------
|
107
|
-
|
108
|
-
#---------------------------------------------------------------
|
109
|
-
def FileType.regex
|
110
|
-
return @regex
|
111
|
-
end
|
112
|
-
#---------------------------------------------------------------
|
113
|
-
|
114
|
-
#---------------------------------------------------------------
|
115
|
-
def FileType.linesplit=(linesplit)
|
116
|
-
@regex = %r{#{linesplit}}
|
117
|
-
@linesplit = linesplit
|
118
|
-
end
|
119
|
-
#---------------------------------------------------------------
|
120
|
-
|
121
|
-
#---------------------------------------------------------------
|
122
|
-
def FileType.linesplit
|
123
|
-
return @linesplit
|
124
|
-
end
|
125
|
-
#---------------------------------------------------------------
|
126
|
-
|
127
|
-
#---------------------------------------------------------------
|
128
|
-
#def [](name)
|
129
|
-
# return @childhash[name]
|
130
|
-
#end
|
131
|
-
#---------------------------------------------------------------
|
132
|
-
|
133
|
-
#---------------------------------------------------------------
|
134
|
-
#def []=(name,value)
|
135
|
-
#end
|
136
|
-
#---------------------------------------------------------------
|
137
|
-
|
138
|
-
#---------------------------------------------------------------
|
139
|
-
# we don't really have a 'less-than/greater-than' sense here
|
140
|
-
# so i'm sticking with 'equals' until those make sense
|
141
|
-
def ==(other)
|
142
|
-
unless self.children.length == other.children.length
|
143
|
-
debug("file has %s records instead of %s" %
|
144
|
-
[self.children.length, other.children.length])
|
145
|
-
return self.children.length == other.children.length
|
146
|
-
end
|
147
|
-
equal = true
|
148
|
-
self.zip(other.children) { |schild,ochild|
|
149
|
-
unless schild == ochild
|
150
|
-
debug("%s has changed in %s" %
|
151
|
-
[schild.name,self.name])
|
152
|
-
equal = false
|
153
|
-
break
|
154
|
-
end
|
155
|
-
}
|
156
|
-
|
157
|
-
return equal
|
158
|
-
end
|
159
|
-
#---------------------------------------------------------------
|
160
|
-
|
161
|
-
#---------------------------------------------------------------
|
162
|
-
# create a new record with a block
|
163
|
-
def add(type,&block)
|
164
|
-
obj = self.class.records[type].new(self,&block)
|
165
|
-
debug("adding %s" % obj.name)
|
166
|
-
@childary.push(obj)
|
167
|
-
@childhash[obj.name] = obj
|
168
|
-
|
169
|
-
return obj
|
170
|
-
end
|
171
|
-
#---------------------------------------------------------------
|
172
|
-
|
173
|
-
#---------------------------------------------------------------
|
174
|
-
def children
|
175
|
-
return @childary
|
176
|
-
end
|
177
|
-
#---------------------------------------------------------------
|
178
|
-
|
179
|
-
#---------------------------------------------------------------
|
180
|
-
# remove a record
|
181
|
-
def delete(name)
|
182
|
-
if @childhash.has_key?(name)
|
183
|
-
child = @childhash[name]
|
184
|
-
|
185
|
-
@childhash.delete(child)
|
186
|
-
@childary.delete(child)
|
187
|
-
else
|
188
|
-
raise "No such entry %s" % name
|
189
|
-
end
|
190
|
-
end
|
191
|
-
#---------------------------------------------------------------
|
192
|
-
|
193
|
-
#---------------------------------------------------------------
|
194
|
-
def each
|
195
|
-
@childary.each { |child|
|
196
|
-
yield child
|
197
|
-
}
|
198
|
-
end
|
199
|
-
#---------------------------------------------------------------
|
200
|
-
|
201
|
-
#---------------------------------------------------------------
|
202
|
-
# create a new file
|
203
|
-
def initialize(hash)
|
204
|
-
# if we are the FileType object itself, we create a new type
|
205
|
-
# otherwise, we create an instance of an existing type
|
206
|
-
# yes, this should be more straightforward
|
207
|
-
if self.class == Puppet::Type::FileType
|
208
|
-
self.class.newtype(hash)
|
209
|
-
return
|
210
|
-
end
|
211
|
-
debug "Creating new '%s' file with path '%s' and name '%s'" %
|
212
|
-
[self.class.name,hash["path"],hash[:name]]
|
213
|
-
debug hash.inspect
|
214
|
-
@file = hash["path"]
|
215
|
-
|
216
|
-
@childary = []
|
217
|
-
@childhash = {}
|
218
|
-
super
|
219
|
-
end
|
220
|
-
#---------------------------------------------------------------
|
221
|
-
|
222
|
-
#---------------------------------------------------------------
|
223
|
-
# this is where we're pretty different from other objects
|
224
|
-
# we can choose to either reparse the existing file and compare
|
225
|
-
# the objects, or we can write our file out and do an
|
226
|
-
# text comparison
|
227
|
-
def insync?
|
228
|
-
tmp = self.class.new(@file)
|
229
|
-
tmp.retrieve
|
230
|
-
|
231
|
-
return self == tmp
|
232
|
-
end
|
233
|
-
#---------------------------------------------------------------
|
234
|
-
|
235
|
-
#---------------------------------------------------------------
|
236
|
-
#def name
|
237
|
-
# return @file
|
238
|
-
#end
|
239
|
-
#---------------------------------------------------------------
|
240
|
-
|
241
|
-
#---------------------------------------------------------------
|
242
|
-
# read the whole file in and turn it into each of the appropriate
|
243
|
-
# objects
|
244
|
-
def retrieve
|
245
|
-
str = ""
|
246
|
-
::File.open(@file) { |fname|
|
247
|
-
fname.each { |line|
|
248
|
-
str += line
|
249
|
-
}
|
250
|
-
}
|
251
|
-
|
252
|
-
if self.class.escapednewlines
|
253
|
-
endreg = %r{\\\n\s*}
|
254
|
-
str.gsub!(endreg,'')
|
255
|
-
end
|
256
|
-
@childary = str.split(self.class.regex).collect { |line|
|
257
|
-
childobj = nil
|
258
|
-
self.class.records.each { |name,recordtype|
|
259
|
-
if childobj = recordtype.match(self,line)
|
260
|
-
break
|
261
|
-
end
|
262
|
-
}
|
263
|
-
if childobj.nil?
|
264
|
-
warning("%s: could not match %s" % [self.name,line])
|
265
|
-
#warning("could not match %s" % line)
|
266
|
-
next
|
267
|
-
end
|
268
|
-
|
269
|
-
begin
|
270
|
-
debug("got child: %s(%s)" % [childobj.class,childobj.to_s])
|
271
|
-
rescue NoMethodError
|
272
|
-
warning "Failed: %s" % childobj
|
273
|
-
end
|
274
|
-
childobj
|
275
|
-
}.reject { |child|
|
276
|
-
child.nil?
|
277
|
-
}
|
278
|
-
|
279
|
-
@childary.each { |child|
|
280
|
-
begin
|
281
|
-
@childhash[child.name] = child
|
282
|
-
rescue NoMethodError => detail
|
283
|
-
p child
|
284
|
-
p child.class
|
285
|
-
puts detail
|
286
|
-
exit
|
287
|
-
end
|
288
|
-
}
|
289
|
-
end
|
290
|
-
#---------------------------------------------------------------
|
291
|
-
|
292
|
-
#---------------------------------------------------------------
|
293
|
-
def sync
|
294
|
-
#unless self.insync?
|
295
|
-
self.write
|
296
|
-
#end
|
297
|
-
end
|
298
|
-
#---------------------------------------------------------------
|
299
|
-
|
300
|
-
#---------------------------------------------------------------
|
301
|
-
def to_s
|
302
|
-
return @childary.collect { |child|
|
303
|
-
child.to_s
|
304
|
-
}.join(self.class.linesplit) + self.class.linesplit
|
305
|
-
end
|
306
|
-
#---------------------------------------------------------------
|
307
|
-
|
308
|
-
#---------------------------------------------------------------
|
309
|
-
def write
|
310
|
-
::File.open(@file, "w") { |file|
|
311
|
-
file.write(self.to_s)
|
312
|
-
}
|
313
|
-
end
|
314
|
-
#---------------------------------------------------------------
|
315
|
-
end
|
316
|
-
#---------------------------------------------------------------
|
data/test/other/state.rb
DELETED
@@ -1,106 +0,0 @@
|
|
1
|
-
if __FILE__ == $0
|
2
|
-
$:.unshift '..'
|
3
|
-
$:.unshift '../../lib'
|
4
|
-
$puppetbase = "../../../../language/trunk"
|
5
|
-
end
|
6
|
-
|
7
|
-
require 'puppet'
|
8
|
-
require 'puppettest'
|
9
|
-
require 'puppet/storage'
|
10
|
-
require 'test/unit'
|
11
|
-
|
12
|
-
# $Id: state.rb 724 2005-10-22 22:27:20Z luke $
|
13
|
-
|
14
|
-
class StorageTestingClass
|
15
|
-
end
|
16
|
-
|
17
|
-
class TestStorage < Test::Unit::TestCase
|
18
|
-
include TestPuppet
|
19
|
-
def disabled_setup
|
20
|
-
Puppet[:loglevel] = :debug if __FILE__ == $0
|
21
|
-
Puppet[:checksumfile] = "/var/tmp/puppetteststate"
|
22
|
-
|
23
|
-
@oldconf = Puppet[:puppetconf]
|
24
|
-
Puppet[:puppetconf] = "/tmp/storagetesting"
|
25
|
-
@oldvar = Puppet[:puppetvar]
|
26
|
-
Puppet[:puppetvar] = "/tmp/storagetesting"
|
27
|
-
|
28
|
-
@@tmpfiles << "/tmp/storagetesting"
|
29
|
-
end
|
30
|
-
|
31
|
-
def teardown
|
32
|
-
#system("rm -f %s" % Puppet[:checksumfile])
|
33
|
-
Puppet::Storage.clear
|
34
|
-
|
35
|
-
#Puppet[:puppetconf] = @oldconf
|
36
|
-
#Puppet[:puppetvar] = @oldvar
|
37
|
-
super
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_simple
|
41
|
-
state = nil
|
42
|
-
assert_nothing_raised {
|
43
|
-
Puppet::Storage.load
|
44
|
-
}
|
45
|
-
assert_nothing_raised {
|
46
|
-
state = Puppet::Storage.state(Puppet::Type)
|
47
|
-
}
|
48
|
-
assert(state)
|
49
|
-
state["/etc/passwd"] = ["md5","9ebebe0c02445c40b9dc6871b64ee416"]
|
50
|
-
assert_nothing_raised {
|
51
|
-
Puppet::Storage.store
|
52
|
-
}
|
53
|
-
|
54
|
-
# clear the memory, so we're sure we're hitting the state file
|
55
|
-
assert_nothing_raised {
|
56
|
-
Puppet::Storage.clear
|
57
|
-
Puppet::Storage.init
|
58
|
-
}
|
59
|
-
assert_nothing_raised {
|
60
|
-
Puppet::Storage.load
|
61
|
-
}
|
62
|
-
assert_equal(
|
63
|
-
["md5","9ebebe0c02445c40b9dc6871b64ee416"],
|
64
|
-
Puppet::Storage.state(Puppet::Type)["/etc/passwd"]
|
65
|
-
)
|
66
|
-
end
|
67
|
-
|
68
|
-
def test_instance
|
69
|
-
file = nil
|
70
|
-
state = nil
|
71
|
-
assert_nothing_raised {
|
72
|
-
file = Puppet::Type::PFile.create(
|
73
|
-
:path => "/etc/passwd"
|
74
|
-
)
|
75
|
-
}
|
76
|
-
assert_nothing_raised {
|
77
|
-
Puppet::Storage.load
|
78
|
-
}
|
79
|
-
assert_nothing_raised {
|
80
|
-
state = Puppet::Storage.state(file)
|
81
|
-
}
|
82
|
-
assert(state)
|
83
|
-
end
|
84
|
-
|
85
|
-
def test_update
|
86
|
-
state = Puppet::Storage.state(StorageTestingClass)
|
87
|
-
state["testing"] = "yayness"
|
88
|
-
Puppet::Storage.store
|
89
|
-
assert(FileTest.exists?(Puppet[:checksumfile]))
|
90
|
-
end
|
91
|
-
|
92
|
-
def test_hashstorage
|
93
|
-
state = Puppet::Storage.state(StorageTestingClass)
|
94
|
-
hash = {
|
95
|
-
:yay => "boo",
|
96
|
-
:rah => "foo"
|
97
|
-
}
|
98
|
-
state["testing"] = hash
|
99
|
-
Puppet::Storage.store
|
100
|
-
Puppet::Storage.clear
|
101
|
-
Puppet::Storage.init
|
102
|
-
Puppet::Storage.load
|
103
|
-
state = Puppet::Storage.state(StorageTestingClass)
|
104
|
-
assert_equal(hash, state["testing"])
|
105
|
-
end
|
106
|
-
end
|