diff options
author | Dan Bode <bodepd@gmail.com> | 2011-01-08 17:34:19 -0600 |
---|---|---|
committer | Matt Robinson <matt@puppetlabs.com> | 2011-01-24 16:44:41 -0800 |
commit | a2036ea693996cb6ba5eb9f8f52fefa843a320a6 (patch) | |
tree | 65784cdbd7a048ca492e6f2f2e36a9679a8c8d83 /lib/puppet/parser/compiler.rb | |
parent | 18ca97b0d16fae149a1eab04c520421b5eb38969 (diff) | |
download | puppet-a2036ea693996cb6ba5eb9f8f52fefa843a320a6.tar.gz puppet-a2036ea693996cb6ba5eb9f8f52fefa843a320a6.tar.xz puppet-a2036ea693996cb6ba5eb9f8f52fefa843a320a6.zip |
(#5045) External node classifiers should be able to specify params for classes
It facilitates the support for param classes from the ENC. It adds
support for classes to be passed as a hash to the evaluate_classes
method. If a hash of classes is specified, it also evaluates duplicates.
I also had to convert the hash to an array for tags to be applied
correctly.
Reviewed-by: Matt Robinson
Diffstat (limited to 'lib/puppet/parser/compiler.rb')
-rw-r--r-- | lib/puppet/parser/compiler.rb | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/lib/puppet/parser/compiler.rb b/lib/puppet/parser/compiler.rb index c60e1d4fb..3134e03d9 100644 --- a/lib/puppet/parser/compiler.rb +++ b/lib/puppet/parser/compiler.rb @@ -139,12 +139,23 @@ class Puppet::Parser::Compiler def evaluate_classes(classes, scope, lazy_evaluate = true) raise Puppet::DevError, "No source for scope passed to evaluate_classes" unless scope.source found = [] + param_classes = nil + # if we are a param class, save the classes hash + # and transform classes to be the keys + if classes.class == Hash + param_classes = classes + classes = classes.keys + end classes.each do |name| # If we can find the class, then make a resource that will evaluate it. if klass = scope.find_hostclass(name) - found << name and next if scope.class_scope(klass) - resource = klass.ensure_in_catalog(scope) + if param_classes + resource = klass.ensure_in_catalog(scope, param_classes[name] || {}) + else + found << name and next if scope.class_scope(klass) and !param_classes + resource = klass.ensure_in_catalog(scope) + end # If they've disabled lazy evaluation (which the :include function does), # then evaluate our resource immediately. @@ -432,7 +443,11 @@ class Puppet::Parser::Compiler @resources = [] # Make sure any external node classes are in our class list - @catalog.add_class(*@node.classes) + if @node.classes.class == Hash + @catalog.add_class(*@node.classes.keys) + else + @catalog.add_class(*@node.classes) + end end # Set the node's parameters into the top-scope as variables. |