summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/indirector/indirection.rb2
-rw-r--r--lib/puppet/indirector/node/exec.rb7
-rw-r--r--lib/puppet/indirector/node/ldap.rb4
-rw-r--r--lib/puppet/indirector/yaml.rb5
-rw-r--r--lib/puppet/node.rb2
5 files changed, 18 insertions, 2 deletions
diff --git a/lib/puppet/indirector/indirection.rb b/lib/puppet/indirector/indirection.rb
index 129676e9c..d47433c60 100644
--- a/lib/puppet/indirector/indirection.rb
+++ b/lib/puppet/indirector/indirection.rb
@@ -162,7 +162,7 @@ class Puppet::Indirector::Indirection
# See if our instance is in the cache and up to date.
if cache? and cache.has_most_recent?(key, terminus(terminus_name).version(key))
- Puppet.info "Using cached %s %s" % [self.name, key]
+ Puppet.debug "Using cached %s %s" % [self.name, key]
return cache.find(key, *args)
end
diff --git a/lib/puppet/indirector/node/exec.rb b/lib/puppet/indirector/node/exec.rb
index 71f4fa8e1..dcfc625b2 100644
--- a/lib/puppet/indirector/node/exec.rb
+++ b/lib/puppet/indirector/node/exec.rb
@@ -24,6 +24,13 @@ class Puppet::Node::Exec < Puppet::Indirector::Exec
return create_node(name, result)
end
+ # Use the version of the facts, since we assume that's the main thing
+ # that changes. If someone wants their own way of defining version,
+ # they can easily provide their own, um, version of this class.
+ def version(name)
+ Puppet::Node::Facts.version(name)
+ end
+
private
# Turn our outputted objects into a Puppet::Node instance.
diff --git a/lib/puppet/indirector/node/ldap.rb b/lib/puppet/indirector/node/ldap.rb
index 9320f3ba1..8537e1cf3 100644
--- a/lib/puppet/indirector/node/ldap.rb
+++ b/lib/puppet/indirector/node/ldap.rb
@@ -122,4 +122,8 @@ class Puppet::Node::Ldap < Puppet::Indirector::Ldap
end
filter
end
+
+ def version(name)
+ Puppet::Node::Facts.version(name)
+ end
end
diff --git a/lib/puppet/indirector/yaml.rb b/lib/puppet/indirector/yaml.rb
index 16816d941..4baeb38db 100644
--- a/lib/puppet/indirector/yaml.rb
+++ b/lib/puppet/indirector/yaml.rb
@@ -40,6 +40,11 @@ class Puppet::Indirector::Yaml < Puppet::Indirector::Terminus
end
end
+ def version(name)
+ return nil unless FileTest.exist?(path(name))
+ return File.stat(path(name)).mtime
+ end
+
private
def from_yaml(text)
diff --git a/lib/puppet/node.rb b/lib/puppet/node.rb
index c0628ecdc..c39f364bc 100644
--- a/lib/puppet/node.rb
+++ b/lib/puppet/node.rb
@@ -10,7 +10,7 @@ class Puppet::Node
extend Puppet::Indirector
# Use the node source as the indirection terminus.
- indirects :node, :terminus_setting => :node_terminus, :doc => "Where to find node information.
+ indirects :node, :terminus_setting => :node_terminus, :cache_class => :yaml, :doc => "Where to find node information.
A node is composed of its name, its facts, and its environment."
# Retrieve a node from the node source, with some additional munging