Skip to content

Instantly share code, notes, and snippets.

@deanwilson
Created December 29, 2010 13:21
Show Gist options
  • Save deanwilson/758527 to your computer and use it in GitHub Desktop.
Save deanwilson/758527 to your computer and use it in GitHub Desktop.
Wildcard fact listings hack
[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