PuppetDB allows you to perform subqueries to combine data from different endpoints (resources, facts, nodes, and fact-contents) in a single query. This is useful when the result of one query (e.g., finding all nodes with a specific class) needs to be used as a filter for another query (e.g., finding the IP addresses of those specific nodes).
Available subquery operators:
select_resources: Takes a resource query and returns the resulting resources.select_facts: Performs a subquery against the facts endpoint.select_nodes: Performs a subquery against the nodes endpoint.select_fact_contents: Performs a subquery against the fact-contents endpoint.
Subqueries can be nested and used from any queryable endpoint.
["and",
["=", "name", "ipaddress"],
["in", "certname",
["extract", "certname", ["select_resources",
["and",
["=", "type", "Class"],
["=", "title", "Apache"]
]]]
]
]