Sometimes you might want a list of all nodes where a fact does not exist. For example, you might need to identify and update older servers that don’t have a particular custom fact set.
Version and installation information
PE version: All supported
Solution
To run this query, you need to have an authentication token. If you don’t have one, generate a token using the steps in our documentation.
This query returns infrastructure nodes that don’t have a specified fact (test_fact
).
puppet query 'nodes[certname]{ ! certname in fact_contents[certname]{name ~ "test_fact"}}'
It returns nodes in the infrastructure and uses a second query to filter the results. The second query uses the fact_contents
endpoint to return all nodes that have a fact called test_fact
. !
(not equal to) returns all of the nodes that do not have test_fact
.
You can return a list of the nodes where the fact doesn’t exist by running:
You can use this query (or any PQL query) to target nodes by running:
-
A job in the console or on the command line
-
A task in the console or on the command line
-
A plan in the console or on the command line
How can we improve this article?
0 comments
Please sign in to leave a comment.
Related articles