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.
- data/CHANGELOG +57 -0
- data/Rakefile +38 -410
- data/bin/puppet +14 -12
- data/bin/puppetca +1 -3
- data/bin/puppetd +25 -7
- data/bin/puppetdoc +161 -104
- data/bin/puppetmasterd +4 -4
- data/conf/epm.list +8 -0
- data/conf/redhat/client.init +6 -1
- data/conf/redhat/no-chuser-0.15.1.patch +38 -0
- data/conf/redhat/puppet.spec +20 -5
- data/conf/redhat/puppetd.conf +1 -1
- data/conf/redhat/puppetmasterd.conf +1 -1
- data/conf/redhat/server.init +2 -4
- data/examples/code/snippets/{casestatement → casestatement.pp} +12 -1
- data/examples/code/snippets/selectorvalues.pp +15 -0
- data/examples/code/snippets/singleselector.pp +22 -0
- data/examples/code/snippets/tag.pp +9 -0
- data/ext/module_puppet +1 -1
- data/install.rb +303 -303
- data/lib/puppet.rb +7 -9
- data/lib/puppet/client.rb +18 -5
- data/lib/puppet/client/dipper.rb +12 -10
- data/lib/puppet/client/master.rb +113 -41
- data/lib/puppet/client/pelement.rb +20 -0
- data/lib/puppet/config.rb +113 -6
- data/lib/puppet/element.rb +1 -3
- data/lib/puppet/event.rb +12 -23
- data/lib/puppet/filetype.rb +93 -5
- data/lib/puppet/inifile.rb +201 -0
- data/lib/puppet/log.rb +18 -6
- data/lib/puppet/parameter.rb +80 -29
- data/lib/puppet/parser/ast.rb +6 -4
- data/lib/puppet/parser/ast/caseopt.rb +13 -4
- data/lib/puppet/parser/ast/casestatement.rb +2 -2
- data/lib/puppet/parser/ast/component.rb +4 -14
- data/lib/puppet/parser/ast/hostclass.rb +1 -1
- data/lib/puppet/parser/ast/leaf.rb +12 -0
- data/lib/puppet/parser/ast/node.rb +4 -4
- data/lib/puppet/parser/ast/objectdef.rb +5 -51
- data/lib/puppet/parser/ast/selector.rb +2 -0
- data/lib/puppet/parser/ast/tag.rb +26 -0
- data/lib/puppet/parser/interpreter.rb +89 -74
- data/lib/puppet/parser/lexer.rb +4 -3
- data/lib/puppet/parser/parser.rb +440 -378
- data/lib/puppet/parser/scope.rb +844 -887
- data/lib/puppet/server.rb +12 -1
- data/lib/puppet/server/authconfig.rb +166 -0
- data/lib/puppet/server/authstore.rb +8 -6
- data/lib/puppet/server/ca.rb +23 -26
- data/lib/puppet/server/filebucket.rb +24 -23
- data/lib/puppet/server/fileserver.rb +116 -47
- data/lib/puppet/server/master.rb +58 -19
- data/lib/puppet/server/pelement.rb +176 -0
- data/lib/puppet/server/rights.rb +78 -0
- data/lib/puppet/server/servlet.rb +19 -6
- data/lib/puppet/sslcertificates.rb +4 -2
- data/lib/puppet/sslcertificates/ca.rb +66 -34
- data/lib/puppet/storage.rb +20 -26
- data/lib/puppet/transaction.rb +49 -92
- data/lib/puppet/type.rb +142 -35
- data/lib/puppet/type/cron.rb +29 -14
- data/lib/puppet/type/exec.rb +92 -35
- data/lib/puppet/type/group.rb +29 -11
- data/lib/puppet/type/nameservice.rb +50 -1
- data/lib/puppet/type/nameservice/netinfo.rb +68 -1
- data/lib/puppet/type/nameservice/objectadd.rb +1 -0
- data/lib/puppet/type/package.rb +150 -109
- data/lib/puppet/type/package/apple.rb +27 -0
- data/lib/puppet/type/package/apt.rb +1 -0
- data/lib/puppet/type/package/darwinport.rb +97 -0
- data/lib/puppet/type/package/dpkg.rb +10 -2
- data/lib/puppet/type/package/freebsd.rb +19 -0
- data/lib/puppet/type/package/{bsd.rb → openbsd.rb} +36 -7
- data/lib/puppet/type/package/ports.rb +98 -0
- data/lib/puppet/type/package/rpm.rb +43 -7
- data/lib/puppet/type/package/sun.rb +53 -36
- data/lib/puppet/type/package/yum.rb +5 -16
- data/lib/puppet/type/parsedtype.rb +41 -29
- data/lib/puppet/type/parsedtype/host.rb +13 -5
- data/lib/puppet/type/parsedtype/mount.rb +250 -0
- data/lib/puppet/type/parsedtype/port.rb +8 -6
- data/lib/puppet/type/pfile.rb +284 -30
- data/lib/puppet/type/pfile/checksum.rb +96 -68
- data/lib/puppet/type/pfile/content.rb +16 -13
- data/lib/puppet/type/pfile/ensure.rb +64 -126
- data/lib/puppet/type/pfile/group.rb +12 -5
- data/lib/puppet/type/pfile/mode.rb +16 -4
- data/lib/puppet/type/pfile/source.rb +47 -73
- data/lib/puppet/type/pfile/target.rb +81 -0
- data/lib/puppet/type/pfile/uid.rb +10 -3
- data/lib/puppet/type/pfilebucket.rb +12 -3
- data/lib/puppet/type/schedule.rb +5 -1
- data/lib/puppet/type/service.rb +138 -66
- data/lib/puppet/type/service/debian.rb +9 -3
- data/lib/puppet/type/service/init.rb +51 -56
- data/lib/puppet/type/service/smf.rb +16 -6
- data/lib/puppet/type/state.rb +71 -32
- data/lib/puppet/type/symlink.rb +12 -7
- data/lib/puppet/type/tidy.rb +5 -1
- data/lib/puppet/type/user.rb +116 -20
- data/lib/puppet/type/yumrepo.rb +314 -0
- data/lib/puppet/util.rb +84 -14
- data/test/client/client.rb +41 -18
- data/test/client/master.rb +50 -4
- data/test/executables/puppetbin.rb +31 -4
- data/test/executables/puppetca.rb +18 -2
- data/test/language/ast.rb +201 -31
- data/test/language/interpreter.rb +8 -2
- data/test/{parser → language}/lexer.rb +1 -1
- data/test/language/node.rb +84 -0
- data/test/{parser → language}/parser.rb +1 -1
- data/test/language/scope.rb +101 -2
- data/test/language/snippets.rb +23 -2
- data/test/other/config.rb +99 -1
- data/test/other/filetype.rb +95 -0
- data/test/other/inifile.rb +114 -0
- data/test/other/log.rb +3 -2
- data/test/other/transactions.rb +55 -10
- data/test/puppet/utiltest.rb +25 -1
- data/test/puppettest.rb +140 -46
- data/test/server/authconfig.rb +56 -0
- data/test/server/bucket.rb +32 -18
- data/test/server/fileserver.rb +75 -30
- data/test/server/master.rb +27 -4
- data/test/server/pelement.rb +298 -0
- data/test/server/rights.rb +41 -0
- data/test/server/server.rb +2 -2
- data/test/tagging/tagging.rb +100 -1
- data/test/types/basic.rb +3 -3
- data/test/types/cron.rb +24 -1
- data/test/types/exec.rb +99 -1
- data/test/types/file.rb +298 -2
- data/test/types/filebucket.rb +4 -15
- data/test/types/filesources.rb +43 -14
- data/test/types/group.rb +1 -13
- data/test/types/mount.rb +277 -0
- data/test/types/package.rb +164 -33
- data/test/types/parameter.rb +107 -0
- data/test/types/port.rb +2 -1
- data/test/types/service.rb +37 -2
- data/test/types/state.rb +92 -0
- data/test/types/symlink.rb +30 -2
- data/test/types/tidy.rb +2 -14
- data/test/types/type.rb +35 -1
- data/test/types/user.rb +110 -1
- data/test/types/yumrepo.rb +95 -0
- metadata +316 -290
- data/test/types/filetype.rb +0 -160
data/lib/puppet/log.rb
CHANGED
@@ -108,6 +108,10 @@ module Puppet
|
|
108
108
|
@loglevel = @levels.index(level)
|
109
109
|
end
|
110
110
|
|
111
|
+
def Log.levels
|
112
|
+
@levels.dup
|
113
|
+
end
|
114
|
+
|
111
115
|
# Create a new log destination.
|
112
116
|
def Log.newdestination(dest)
|
113
117
|
# Each destination can only occur once.
|
@@ -120,7 +124,9 @@ module Puppet
|
|
120
124
|
if Syslog.opened?
|
121
125
|
Syslog.close
|
122
126
|
end
|
123
|
-
|
127
|
+
name = Puppet.name
|
128
|
+
name = "puppet-#{name}" unless name =~ /puppet/
|
129
|
+
@destinations[:syslog] = Syslog.open(name)
|
124
130
|
when /^\// # files
|
125
131
|
Puppet.info "opening %s as a log" % dest
|
126
132
|
# first make sure the directory exists
|
@@ -195,14 +201,20 @@ module Puppet
|
|
195
201
|
dest.puts("%s %s (%s): %s" %
|
196
202
|
[msg.time, msg.source, msg.level, msg.to_s])
|
197
203
|
when :console
|
204
|
+
color = ""
|
205
|
+
reset = ""
|
206
|
+
if Puppet[:color]
|
207
|
+
color = @colors[msg.level]
|
208
|
+
reset = RESET
|
209
|
+
end
|
198
210
|
if msg.source == "Puppet"
|
199
|
-
puts
|
211
|
+
puts color + "%s: %s" % [
|
200
212
|
msg.level, msg.to_s
|
201
|
-
] +
|
213
|
+
] + reset
|
202
214
|
else
|
203
|
-
puts
|
215
|
+
puts color + "%s: %s: %s" % [
|
204
216
|
msg.level, msg.source, msg.to_s
|
205
|
-
] +
|
217
|
+
] + reset
|
206
218
|
end
|
207
219
|
when Puppet::Client::LogClient
|
208
220
|
unless msg.is_a?(String) or msg.remote
|
@@ -344,4 +356,4 @@ module Puppet
|
|
344
356
|
end
|
345
357
|
end
|
346
358
|
|
347
|
-
# $Id: log.rb
|
359
|
+
# $Id: log.rb 1124 2006-04-20 07:00:10Z luke $
|
data/lib/puppet/parameter.rb
CHANGED
@@ -30,6 +30,12 @@ module Puppet
|
|
30
30
|
@doc = str
|
31
31
|
end
|
32
32
|
|
33
|
+
def initvars
|
34
|
+
@parametervalues = []
|
35
|
+
@aliasvalues = {}
|
36
|
+
@parameterregexes = []
|
37
|
+
end
|
38
|
+
|
33
39
|
# This is how we munge the value. Basically, this is our
|
34
40
|
# opportunity to convert the value from one form into another.
|
35
41
|
def munge(&block)
|
@@ -56,10 +62,6 @@ module Puppet
|
|
56
62
|
#@munger = block
|
57
63
|
end
|
58
64
|
|
59
|
-
#def inspect
|
60
|
-
# "Parameter(#{self.name})"
|
61
|
-
#end
|
62
|
-
|
63
65
|
# Mark whether we're the namevar.
|
64
66
|
def isnamevar
|
65
67
|
@isnamevar = true
|
@@ -118,27 +120,46 @@ module Puppet
|
|
118
120
|
end
|
119
121
|
end
|
120
122
|
|
123
|
+
# Does the value match any of our regexes?
|
124
|
+
def match?(value)
|
125
|
+
value = value.to_s unless value.is_a? String
|
126
|
+
@parameterregexes.find { |r|
|
127
|
+
r = r[0] if r.is_a? Array # States use a hash here
|
128
|
+
r =~ value
|
129
|
+
}
|
130
|
+
end
|
131
|
+
|
121
132
|
# Define a new value for our parameter.
|
122
133
|
def newvalues(*names)
|
123
|
-
@parametervalues ||= []
|
124
|
-
|
125
134
|
names.each { |name|
|
126
|
-
if
|
127
|
-
|
128
|
-
|
135
|
+
name = name.intern if name.is_a? String
|
136
|
+
|
137
|
+
case name
|
138
|
+
when Symbol
|
139
|
+
if @parametervalues.include?(name)
|
140
|
+
Puppet.warning "%s already has a value for %s" %
|
141
|
+
[name, name]
|
142
|
+
end
|
143
|
+
@parametervalues << name
|
144
|
+
when Regexp
|
145
|
+
if @parameterregexes.include?(name)
|
146
|
+
Puppet.warning "%s already has a value for %s" %
|
147
|
+
[name, name]
|
148
|
+
end
|
149
|
+
@parameterregexes << name
|
150
|
+
else
|
151
|
+
raise ArgumentError, "Invalid value %s of type %s" %
|
152
|
+
[name, name.class]
|
129
153
|
end
|
130
|
-
@parametervalues << name
|
131
154
|
}
|
132
155
|
end
|
133
156
|
|
134
157
|
def aliasvalue(name, other)
|
135
|
-
@parametervalues ||= []
|
136
158
|
unless @parametervalues.include?(other)
|
137
159
|
raise Puppet::DevError,
|
138
160
|
"Cannot alias nonexistent value %s" % other
|
139
161
|
end
|
140
162
|
|
141
|
-
@aliasvalues ||= {}
|
142
163
|
@aliasvalues[name] = other
|
143
164
|
end
|
144
165
|
|
@@ -146,11 +167,12 @@ module Puppet
|
|
146
167
|
@aliasvalues[name]
|
147
168
|
end
|
148
169
|
|
170
|
+
def regexes
|
171
|
+
return @parameterregexes.dup
|
172
|
+
end
|
173
|
+
|
149
174
|
# Return the list of valid values.
|
150
175
|
def values
|
151
|
-
@parametervalues ||= []
|
152
|
-
@aliasvalues ||= {}
|
153
|
-
|
154
176
|
#[@aliasvalues.keys, @parametervalues.keys].flatten
|
155
177
|
if @parametervalues.is_a? Array
|
156
178
|
return @parametervalues.dup
|
@@ -240,36 +262,65 @@ module Puppet
|
|
240
262
|
|
241
263
|
# If the specified value is allowed, then munge appropriately.
|
242
264
|
munge do |value|
|
243
|
-
if self.class.values.empty?
|
265
|
+
if self.class.values.empty? and self.class.regexes.empty?
|
244
266
|
# This parameter isn't using defined values to do its work.
|
245
267
|
return value
|
246
268
|
end
|
269
|
+
|
270
|
+
# We convert to a string and then a symbol so that things like
|
271
|
+
# booleans work as we expect.
|
247
272
|
intern = value.to_s.intern
|
273
|
+
|
248
274
|
# If it's a valid value, always return it as a symbol.
|
249
275
|
if self.class.values.include?(intern)
|
250
276
|
retval = intern
|
251
277
|
elsif other = self.class.alias(intern)
|
252
|
-
self.info "returning alias %s for %s" % [other, intern]
|
253
278
|
retval = other
|
279
|
+
elsif ary = self.class.match?(value)
|
280
|
+
retval = value
|
254
281
|
else
|
282
|
+
# If it passed the validation but is not a registered value,
|
283
|
+
# we just return it as is.
|
255
284
|
retval = value
|
256
285
|
end
|
286
|
+
|
257
287
|
retval
|
258
288
|
end
|
259
289
|
|
260
290
|
# Verify that the passed value is valid.
|
261
291
|
validate do |value|
|
262
|
-
|
263
|
-
|
292
|
+
vals = self.class.values
|
293
|
+
regs = self.class.regexes
|
294
|
+
|
295
|
+
if regs.is_a? Hash # this is true on states
|
296
|
+
regs = regs.keys
|
297
|
+
end
|
298
|
+
if vals.empty? and regs.empty?
|
264
299
|
# This parameter isn't using defined values to do its work.
|
265
300
|
return
|
266
301
|
end
|
302
|
+
newval = value
|
267
303
|
unless value.is_a?(Symbol)
|
268
|
-
|
304
|
+
newval = value.to_s.intern
|
269
305
|
end
|
270
|
-
|
271
|
-
|
272
|
-
|
306
|
+
|
307
|
+
unless vals.include?(newval) or
|
308
|
+
self.class.alias(newval) or
|
309
|
+
self.class.match?(value) # We match the string, not the symbol
|
310
|
+
str = "Invalid '%s' value %s. " %
|
311
|
+
[self.class.name, value.inspect]
|
312
|
+
|
313
|
+
unless vals.empty?
|
314
|
+
str += "Valid values are %s. " % vals.join(", ")
|
315
|
+
end
|
316
|
+
|
317
|
+
unless regs.empty?
|
318
|
+
str += "Valid values match %s." % regs.collect { |r|
|
319
|
+
r.to_s
|
320
|
+
}.join(", ")
|
321
|
+
end
|
322
|
+
|
323
|
+
raise ArgumentError, str
|
273
324
|
end
|
274
325
|
end
|
275
326
|
|
@@ -277,12 +328,12 @@ module Puppet
|
|
277
328
|
# it possible to call for states, too.
|
278
329
|
def value
|
279
330
|
if self.is_a?(Puppet::State)
|
280
|
-
# We should return the 'is' value if there's not 'should'
|
281
|
-
# This might be bad, though, because the 'should'
|
282
|
-
# knows whether to return an array or not and that info
|
283
|
-
# not exposed, and the 'is' value could be a symbol. I
|
284
|
-
# seem to create a test in which this is a problem, but
|
285
|
-
# mean it's not one.
|
331
|
+
# We should return the 'is' value if there's not 'should'
|
332
|
+
# value. This might be bad, though, because the 'should'
|
333
|
+
# method knows whether to return an array or not and that info
|
334
|
+
# is not exposed, and the 'is' value could be a symbol. I
|
335
|
+
# can't seem to create a test in which this is a problem, but
|
336
|
+
# that doesn't mean it's not one.
|
286
337
|
if self.should
|
287
338
|
return self.should
|
288
339
|
else
|
data/lib/puppet/parser/ast.rb
CHANGED
@@ -69,15 +69,16 @@ module Puppet
|
|
69
69
|
except.file ||= @file
|
70
70
|
raise
|
71
71
|
rescue => detail
|
72
|
-
if Puppet[:debug]
|
73
|
-
|
74
|
-
end
|
72
|
+
#if Puppet[:debug]
|
73
|
+
# puts detail.backtrace
|
74
|
+
#end
|
75
75
|
error = Puppet::DevError.new(
|
76
76
|
"Child of type %s failed with error %s: %s" %
|
77
77
|
[self.class, detail.class, detail.to_s]
|
78
78
|
)
|
79
79
|
error.line ||= @line
|
80
80
|
error.file ||= @file
|
81
|
+
error.backtrace = detail.backtrace
|
81
82
|
raise error
|
82
83
|
end
|
83
84
|
end
|
@@ -145,5 +146,6 @@ require 'puppet/parser/ast/objectref'
|
|
145
146
|
require 'puppet/parser/ast/selector'
|
146
147
|
require 'puppet/parser/ast/typedefaults'
|
147
148
|
require 'puppet/parser/ast/vardef'
|
149
|
+
require 'puppet/parser/ast/tag'
|
148
150
|
|
149
|
-
# $Id: ast.rb
|
151
|
+
# $Id: ast.rb 1106 2006-04-11 22:32:51Z luke $
|
@@ -13,6 +13,7 @@ class Puppet::Parser::AST
|
|
13
13
|
|
14
14
|
# Are we the default option?
|
15
15
|
def default?
|
16
|
+
# Cache the @default value.
|
16
17
|
if defined? @default
|
17
18
|
return @default
|
18
19
|
end
|
@@ -38,13 +39,21 @@ class Puppet::Parser::AST
|
|
38
39
|
end
|
39
40
|
|
40
41
|
# You can specify a list of values; return each in turn.
|
41
|
-
def eachvalue
|
42
|
+
def eachvalue(scope)
|
42
43
|
if @value.is_a?(AST::ASTArray)
|
43
44
|
@value.each { |subval|
|
44
|
-
|
45
|
+
if scope
|
46
|
+
yield subval.evaluate(:scope => scope)
|
47
|
+
elsif subval.is_a? AST::Leaf
|
48
|
+
yield subval.value
|
49
|
+
end
|
45
50
|
}
|
46
51
|
else
|
47
|
-
|
52
|
+
if scope
|
53
|
+
yield @value.evaluate(:scope => scope)
|
54
|
+
elsif @value.is_a? AST::Leaf
|
55
|
+
yield @value.value
|
56
|
+
end
|
48
57
|
end
|
49
58
|
end
|
50
59
|
|
@@ -52,7 +61,7 @@ class Puppet::Parser::AST
|
|
52
61
|
# our option matched.
|
53
62
|
def evaluate(hash)
|
54
63
|
scope = hash[:scope]
|
55
|
-
return @statements.safeevaluate(:scope => scope
|
64
|
+
return @statements.safeevaluate(:scope => scope)
|
56
65
|
end
|
57
66
|
|
58
67
|
def tree(indent = 0)
|
@@ -15,7 +15,7 @@ class Puppet::Parser::AST
|
|
15
15
|
|
16
16
|
# Iterate across the options looking for a match.
|
17
17
|
@options.each { |option|
|
18
|
-
if option.eachvalue { |opval| break true if opval == value }
|
18
|
+
if option.eachvalue(scope) { |opval| break true if opval == value }
|
19
19
|
# we found a matching option
|
20
20
|
retvalue = option.safeevaluate(:scope => scope)
|
21
21
|
found = true
|
@@ -49,7 +49,7 @@ class Puppet::Parser::AST
|
|
49
49
|
if option.default?
|
50
50
|
@default = option
|
51
51
|
end
|
52
|
-
option.eachvalue { |val|
|
52
|
+
option.eachvalue(nil) { |val|
|
53
53
|
if values.include?(val)
|
54
54
|
raise Puppet::ParseError,
|
55
55
|
"Value %s appears twice in case statement" %
|
@@ -24,24 +24,14 @@ class Puppet::Parser::AST
|
|
24
24
|
:name => objname,
|
25
25
|
:keyword => self.keyword
|
26
26
|
)
|
27
|
-
|
27
|
+
newcontext = hash[:newcontext]
|
28
|
+
|
29
|
+
unless self.is_a? AST::HostClass and ! newcontext
|
28
30
|
#scope.warning "Setting context to %s" % self.object_id
|
29
31
|
scope.context = self.object_id
|
30
32
|
end
|
31
33
|
@scope = scope
|
32
34
|
|
33
|
-
# The type is the component or class name
|
34
|
-
#scope.type = objtype
|
35
|
-
|
36
|
-
# The name is the name the user has chosen or that has
|
37
|
-
# been dynamically generated. This is almost never used
|
38
|
-
#scope.name = objname
|
39
|
-
|
40
|
-
#scope.keyword = self.keyword
|
41
|
-
|
42
|
-
#if self.is_a?(Node)
|
43
|
-
# scope.isnodescope
|
44
|
-
#end
|
45
35
|
|
46
36
|
# Additionally, add a tag for whatever kind of class
|
47
37
|
# we are
|
@@ -146,4 +136,4 @@ class Puppet::Parser::AST
|
|
146
136
|
end
|
147
137
|
end
|
148
138
|
|
149
|
-
# $Id: component.rb
|
139
|
+
# $Id: component.rb 972 2006-03-03 18:23:53Z luke $
|
@@ -69,6 +69,18 @@ class Puppet::Parser::AST
|
|
69
69
|
# Lower-case words.
|
70
70
|
class Name < AST::Leaf; end
|
71
71
|
|
72
|
+
# Host names, either fully qualified or just the short name
|
73
|
+
class HostName < AST::Leaf
|
74
|
+
def initialize(hash)
|
75
|
+
super
|
76
|
+
|
77
|
+
unless @value =~ %r{^[0-9a-zA-Z\-]+(\.[0-9a-zA-Z\-]+)*$}
|
78
|
+
raise Puppet::DevError,
|
79
|
+
"'%s' is not a valid hostname" % @value
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
72
84
|
# A simple variable. This object is only used during interpolation;
|
73
85
|
# the VarDef class is used for assignment.
|
74
86
|
class Variable < Name
|
@@ -19,10 +19,6 @@ class Puppet::Parser::AST
|
|
19
19
|
)
|
20
20
|
scope.context = self.object_id
|
21
21
|
|
22
|
-
# Mark this scope as a nodescope, so that classes will be
|
23
|
-
# singletons within it
|
24
|
-
scope.isnodescope
|
25
|
-
|
26
22
|
# Now set all of the facts inside this scope
|
27
23
|
facts.each { |var, value|
|
28
24
|
scope.setvar(var, value)
|
@@ -43,6 +39,10 @@ class Puppet::Parser::AST
|
|
43
39
|
# And then evaluate our code.
|
44
40
|
@code.safeevaluate(:scope => scope)
|
45
41
|
|
42
|
+
# Mark our node name as a class, too, but strip it of the domain
|
43
|
+
# name.
|
44
|
+
scope.setclass(self.object_id, @type.sub(/\..+/, ''))
|
45
|
+
|
46
46
|
return scope
|
47
47
|
end
|
48
48
|
|
@@ -65,8 +65,7 @@ class Puppet::Parser::AST
|
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
|
-
|
69
|
-
hash = getdefaults(objtype, scope)
|
68
|
+
hash = {}
|
70
69
|
|
71
70
|
# then set all of the specified params
|
72
71
|
@params.each { |param|
|
@@ -105,52 +104,9 @@ class Puppet::Parser::AST
|
|
105
104
|
error.backtrace = detail.backtrace
|
106
105
|
raise error
|
107
106
|
end
|
108
|
-
# else
|
109
|
-
# # but things like components create a new type; if we find
|
110
|
-
# # one of those, evaluate that with our arguments
|
111
|
-
# #Puppet.debug("Calling object '%s' with arguments %s" %
|
112
|
-
# # [object.name, hash.inspect])
|
113
|
-
# #obj = object.safeevaluate(scope,hash,objtype,objname)
|
114
|
-
# obj = object.safeevaluate(
|
115
|
-
# :scope => scope,
|
116
|
-
# :arguments => hash,
|
117
|
-
# :type => objtype,
|
118
|
-
# :name => objname
|
119
|
-
# )
|
120
|
-
#
|
121
|
-
# # and pass the result on
|
122
|
-
# obj
|
123
|
-
# end
|
124
107
|
}.reject { |obj| obj.nil? }
|
125
108
|
end
|
126
109
|
|
127
|
-
# Retrieve the defaults for our type
|
128
|
-
def getdefaults(objtype, scope)
|
129
|
-
# first, retrieve the defaults
|
130
|
-
begin
|
131
|
-
defaults = scope.lookupdefaults(objtype)
|
132
|
-
if defaults.length > 0
|
133
|
-
#Puppet.debug "Got defaults for %s: %s" %
|
134
|
-
# [objtype,defaults.inspect]
|
135
|
-
end
|
136
|
-
rescue => detail
|
137
|
-
raise Puppet::DevError,
|
138
|
-
"Could not lookup defaults for %s: %s" %
|
139
|
-
[objtype, detail.to_s]
|
140
|
-
end
|
141
|
-
|
142
|
-
hash = {}
|
143
|
-
# Add any found defaults to our argument list
|
144
|
-
defaults.each { |var,value|
|
145
|
-
Puppet.debug "Found default %s for %s" %
|
146
|
-
[var,objtype]
|
147
|
-
|
148
|
-
hash[var] = value
|
149
|
-
}
|
150
|
-
|
151
|
-
return hash
|
152
|
-
end
|
153
|
-
|
154
110
|
# Create our ObjectDef. Handles type checking for us.
|
155
111
|
def initialize(hash)
|
156
112
|
@checked = false
|
@@ -192,7 +148,7 @@ class Puppet::Parser::AST
|
|
192
148
|
unless type.validattr?(pname)
|
193
149
|
error = Puppet::ParseError.new(
|
194
150
|
"Invalid parameter '%s' for type '%s'" %
|
195
|
-
[pname,type.name]
|
151
|
+
[pname, type.name]
|
196
152
|
)
|
197
153
|
error.line = self.line
|
198
154
|
error.file = self.file
|
@@ -213,12 +169,10 @@ class Puppet::Parser::AST
|
|
213
169
|
raise Puppet::DevError, detail.to_s
|
214
170
|
end
|
215
171
|
|
216
|
-
# FIXME This should look through the scope tree, not in a global
|
217
|
-
# hash
|
218
172
|
unless objtype.validarg?(pname)
|
219
173
|
error = Puppet::ParseError.new(
|
220
174
|
"Invalid parameter '%s' for type '%s'" %
|
221
|
-
[pname,objtype]
|
175
|
+
[pname,objtype.type]
|
222
176
|
)
|
223
177
|
error.line = self.line
|
224
178
|
error.file = self.file
|
@@ -285,7 +239,7 @@ class Puppet::Parser::AST
|
|
285
239
|
return true unless defined? @scope and @scope
|
286
240
|
|
287
241
|
# Unless we can look up the type, throw an error
|
288
|
-
unless
|
242
|
+
unless typeobj = @scope.lookuptype(objtype)
|
289
243
|
error = Puppet::ParseError.new(
|
290
244
|
"Unknown type '%s'" % objtype
|
291
245
|
)
|
@@ -297,7 +251,7 @@ class Puppet::Parser::AST
|
|
297
251
|
# Now that we have the type, verify all of the parameters.
|
298
252
|
# Note that we're now passing an AST Class object or whatever
|
299
253
|
# as the type, not a simple string.
|
300
|
-
self.paramcheck(builtin,
|
254
|
+
self.paramcheck(builtin, typeobj)
|
301
255
|
end
|
302
256
|
end
|
303
257
|
|