Created
December 29, 2010 13:21
-
-
Save deanwilson/758527 to your computer and use it in GitHub Desktop.
Wildcard fact listings hack
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[dwilson@xeny ~]$ diff -u /usr/bin/facter facter-wildcard | |
--- /usr/bin/facter 2010-08-28 17:38:56.000000000 +0100 | |
+++ facter-wildcard 2010-12-29 13:19:42.278609734 +0000 | |
@@ -139,12 +139,15 @@ | |
unless names.empty? | |
facts = {} | |
names.each { |name| | |
- begin | |
- facts[name] = Facter.value(name) | |
- rescue => error | |
- STDERR.puts "Could not retrieve %s: #{error}" % name | |
- exit 10 | |
- end | |
+ matched = Facter.to_hash.keys.grep(/#{name}/) | |
+ matched.each { |match| | |
+ begin | |
+ facts[match] = Facter.value(match) | |
+ rescue => error | |
+ STDERR.puts "Could not retrieve %s: #{error}" % match | |
+ exit 10 | |
+ end | |
+ } | |
} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment