summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser/interpreter.rb
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-06-13 18:09:40 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-06-13 18:09:40 +0000
commitb4b3c27ff4d0c748c68efd856865dffb65f0ba90 (patch)
tree3460c6de945fc8d04a202a375c4ba415f1aa9788 /lib/puppet/parser/interpreter.rb
parentba4071cba3fc4c975538199933945f09bd4d28b2 (diff)
downloadpuppet-b4b3c27ff4d0c748c68efd856865dffb65f0ba90.tar.gz
puppet-b4b3c27ff4d0c748c68efd856865dffb65f0ba90.tar.xz
puppet-b4b3c27ff4d0c748c68efd856865dffb65f0ba90.zip
Adding support for default nodes as requested in #136.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1261 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet/parser/interpreter.rb')
-rw-r--r--lib/puppet/parser/interpreter.rb27
1 files changed, 21 insertions, 6 deletions
diff --git a/lib/puppet/parser/interpreter.rb b/lib/puppet/parser/interpreter.rb
index eeb0e4cca..bde5bc39f 100644
--- a/lib/puppet/parser/interpreter.rb
+++ b/lib/puppet/parser/interpreter.rb
@@ -73,7 +73,8 @@ module Puppet
@usenodes = true
end
- @nodesources = [:file]
+ # By default, we only search the parse tree.
+ @nodesources = []
if Puppet[:ldapnodes]
@nodesources << :ldap
@@ -139,19 +140,33 @@ module Puppet
end
end
- # Search for our node in the various locations.
+ # Search for our node in the various locations. This only searches
+ # locations external to the files; the scope is responsible for
+ # searching the parse tree.
def nodesearch(node)
# At this point, stop at the first source that defines
# the node
@nodesources.each do |source|
method = "nodesearch_%s" % source
+ parent = nil
+ nodeclasses = nil
if self.respond_to? method
parent, nodeclasses = self.send(method, node)
- end
- if nodeclasses and !nodeclasses.empty?
- Puppet.info "Found %s in %s" % [node, source]
- return parent, nodeclasses
+ Puppet.info "Yo?"
+ if parent or (nodeclasses and !nodeclasses.empty?)
+ Puppet.info "Found %s in %s" % [node, source]
+ return parent, nodeclasses
+ else
+ # Look for a default node.
+ Puppet.info "looking for default node"
+ parent, nodeclasses = self.send(method, "default")
+ if parent or (nodeclasses and !nodeclasses.empty?)
+ Puppet.info "Found default node for %s in %s" %
+ [node, source]
+ return parent, nodeclasses
+ end
+ end
end
end