Bug #4986
Facter Does Not Report Individual Facts Properly
| Status: | Duplicate | Start date: | 10/12/2010 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | - | % Done: | 0% |
|
| Category: | - | |||
| Target version: | - | |||
| Keywords: | Affected Facter version: | |||
| Branch: | ||||
| Votes: | 0 |
Description
We have a few issues with Facter being unable to report individual facts properly.
Take this, for example:
dev-box:~# facter lsbdistdescription
dev-box:~# facter | grep lsbdistdescription
lsbdistdescription => Debian GNU/Linux 5.0.3 (lenny)
dev-box:~# facter memoryfree
dev-box:~# facter | grep memoryfree
memoryfree => 390.38 MB
Whereas this and nearly every other fact work:
dev-box:~# facter rubysitedir
/usr/local/lib/site_ruby/1.8
dev-box:~# facter facterversion
1.5.1
dev-box:~# facter kernelrelease
2.6.26-2-amd64
It appears that it’s not properly loading the lsb facts, along with several others, when requested directly.
For our internal builds of facter, I was able to get this to work as we’d expect by forcing Facter to load all facts first like this (line 123, /usr/bin/facter):
120 if names.empty?
121 facts = Facter.to_hash
122 else
123 Facter.loadfacts
124 facts = {}
125 names.each { |name|
126 begin
127 facts[name] = Facter.value(name)
128 rescue => error
129 STDERR.puts "Could not retrieve %s: #{error}" % name
130 exit 10
131 end
132 }
133 end
Loading all facts to retrieve whatever is in ARGV seems a bit excessive and, depending on the facts on that machine, can take a long time. Was there some magic that I’m missing that would allow Facter to just load an individual fact, or is this a sane fix?
Related issues
History
Updated by donavan m over 1 year ago
Jeremy,
I think this is a dupe of Facter issue 1365. 1365 has been marked as closed against Facter 1.5.8, but personally I haven’t verified that yet.
The issue you’re seeing is that Facter relies (relied?) on Rubys library autoloading. Because of that calling ‘require foo’ would autoload foo.rb, which would contain your ‘foo’ fact. If the requested fact ‘bar’ is in foo.rb you will see your observed behavior. Your workaround simply loads all facts in your library path.
Updated by Jeremy Jack over 1 year ago
- Status changed from Unreviewed to Closed
Thank you for this. It does appear to be a duplicate of 1365, which was fixed in 1.5.8. You have to love packages not being up to date :)
It looks like the fix in 1.5.8 does essentially the same thing: load all facts when accessing via the commandline.
It’s time to start building packages for 1.5.8. I appreciate your quick response on this.
Updated by Rein Henrichs over 1 year ago
- Status changed from Closed to Duplicate