Closed mcasper closed 8 years ago
/cc @dalen
Hi, sorry about the late reply.
This looks good to me. But could make it use dotted notation that hiera and the query language uses for nested facts instead?
So instead of ['networking', 'interfaces', 'eth0', 'network']
it would be 'networking.interfaces.eth0.network'
. That way it would be more in line with the syntax for that in other places.
You can likely just split the string on dots and otherwise use the same code.
@dalen Sure thing, just pushed up that change. I left it as a separate commit right now so that it's easier to review, can squash if this gets approved
@dalen bump
I've just been testing this, because it solves an issue that I have. Unfortunately, it seems to have an issue:
jerome root% puppet query facts 'Class["Exim"]'
Error: wrong number of arguments (1 for 2)
Error: Try 'puppet help query facts' for usage
jerome root% puppet query facts 'Class["Exim"]' 'networking'
Error: puppet query facts takes 1 argument, but you gave 2
Error: Try 'puppet help query facts' for usage
I'd expect the first option to give me all facts for the node and the second to give me just the networking section of the facts.
@dpash Thanks for reporting this, I've pushed up a fix for the face CLI, with the exception that your second command needs to be tweaked:
puppet query facts 'Class["Exim"]' --facts 'networking'
Other than that, they both should be working now
@dalen bump
+1
+1
bump @dalen
Facter 3 introduced a lot of facts that are large hashes, which gets difficult to work with in Puppet when using query_nodes or query_facts. The types don't seem to coerce just right, so you'll get back a hash of values with the type
Runtime[ruby string]
, which Puppet doesn't know what to do with at the manifest level.This PR introduces the ability to pass a dotted fact to query for nested facts. You can do something like:
to get back eth0 network for all matching nodes.
It's implemented for both query_nodes and query_facts in this PR.