summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-07-01 12:57:56 -0500
committerLuke Kanies <luke@madstop.com>2008-07-01 12:57:56 -0500
commitee9d0025eeebda1522d450b5bd3cda769d7455d5 (patch)
tree9c03a2ff0d8d943674d00ae1de388085b533e590
parent117869fa1614cd3b4ff4e5e0df5ece699eb1fe56 (diff)
downloadpuppet-ee9d0025eeebda1522d450b5bd3cda769d7455d5.tar.gz
puppet-ee9d0025eeebda1522d450b5bd3cda769d7455d5.tar.xz
puppet-ee9d0025eeebda1522d450b5bd3cda769d7455d5.zip
Fixed #1114 - Facts in plugin directories should now be autoloaded,
as long as you're using Facter 1.5.
-rw-r--r--CHANGELOG3
-rw-r--r--lib/puppet/network/client/master.rb37
-rwxr-xr-xtest/network/client/master.rb16
3 files changed, 30 insertions, 26 deletions
diff --git a/CHANGELOG b/CHANGELOG
index a87702a10..ae490cf8f 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,4 +1,7 @@
0.24.?
+ Fixed #1114 - Facts in plugin directories should now be autoloaded,
+ as long as you're using Facter 1.5.
+
Fixed #1195 - Updated Gentoo init scripts
Fixed #1367 - Updated Rakefile for new daily builds
diff --git a/lib/puppet/network/client/master.rb b/lib/puppet/network/client/master.rb
index 22bb3fa4e..0de3a117b 100644
--- a/lib/puppet/network/client/master.rb
+++ b/lib/puppet/network/client/master.rb
@@ -26,6 +26,20 @@ class Puppet::Network::Client::Master < Puppet::Network::Client
down = Puppet[:downcasefacts]
+ Facter.clear
+
+ # Reload everything.
+ if Facter.respond_to? :loadfacts
+ Facter.loadfacts
+ elsif Facter.respond_to? :load
+ Facter.load
+ else
+ Puppet.warning "You should upgrade your version of Facter to at least 1.3.8"
+ end
+
+ # This loads all existing facts and any new ones. We have to remove and
+ # reload because there's no way to unload specific facts.
+ loadfacts()
facts = Facter.to_hash.inject({}) do |newhash, array|
name, fact = array
if down
@@ -115,6 +129,9 @@ class Puppet::Network::Client::Master < Puppet::Network::Client
def getconfig
dostorage()
+ # Retrieve the plugins.
+ getplugins() if Puppet[:pluginsync]
+
facts = nil
Puppet::Util.benchmark(:debug, "Retrieved facts") do
facts = self.class.facts
@@ -122,9 +139,6 @@ class Puppet::Network::Client::Master < Puppet::Network::Client
raise Puppet::Network::ClientError.new("Could not retrieve any facts") unless facts.length > 0
- # Retrieve the plugins.
- getplugins() if Puppet[:pluginsync]
-
Puppet.debug("Retrieving catalog")
# If we can't retrieve the catalog, just return, which will either
@@ -340,23 +354,6 @@ class Puppet::Network::Client::Master < Puppet::Network::Client
files << resource[:path]
end
- ensure
- # Clear all existing definitions.
- Facter.clear
-
- # Reload everything.
- if Facter.respond_to? :loadfacts
- Facter.loadfacts
- elsif Facter.respond_to? :load
- Facter.load
- else
- raise Puppet::Error,
- "You must upgrade your version of Facter to use centralized facts"
- end
-
- # This loads all existing facts and any new ones. We have to remove and
- # reload because there's no way to unload specific facts.
- loadfacts()
end
# Retrieve the plugins from the central server. We only have to load the
diff --git a/test/network/client/master.rb b/test/network/client/master.rb
index 9f71247fa..0c1405217 100755
--- a/test/network/client/master.rb
+++ b/test/network/client/master.rb
@@ -177,10 +177,12 @@ end
assert(File.exists?(destfile), "Did not get fact")
- assert_equal(hostname, Facter.value(:hostname),
+ facts = Puppet::Network::Client.master.facts
+
+ assert_equal(hostname, facts["hostname"],
"Lost value to hostname")
- assert_equal("yayness", Facter.value(:myfact),
+ assert_equal("yayness", facts["myfact"],
"Did not get correct fact value")
# Now modify the file and make sure the type is replaced
@@ -194,20 +196,22 @@ end
assert_nothing_raised {
Puppet::Network::Client.master.getfacts
}
+ facts = Puppet::Network::Client.master.facts
- assert_equal("funtest", Facter.value(:myfact),
+ assert_equal("funtest", facts["myfact"],
"Did not reload fact")
- assert_equal(hostname, Facter.value(:hostname),
+ assert_equal(hostname, facts["hostname"],
"Lost value to hostname")
# Now run it again and make sure the fact still loads
assert_nothing_raised {
Puppet::Network::Client.master.getfacts
}
+ facts = Puppet::Network::Client.master.facts
- assert_equal("funtest", Facter.value(:myfact),
+ assert_equal("funtest", facts["myfact"],
"Did not reload fact")
- assert_equal(hostname, Facter.value(:hostname),
+ assert_equal(hostname, facts["hostname"],
"Lost value to hostname")
end