Skip to content

Commit a8c8c55

Browse files
committed
Add query that restricts resources per parameter value
It took me so much time today to figure this one out. And I have the answer thanks to bastelfreak who helped me out with it. The nature of the `parameters` field being a hash is not obvious from the PQL documentation.
1 parent 60e1087 commit a8c8c55

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

_docs/pql_queries.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,19 @@ This is useful if you want to get a list of nodes with a specific profile or rol
107107
puppet query 'nodes[certname] {resources {type = "Class" and title = "CapitalizedClassname"}}'
108108
```
109109

110+
### Get all nodes that have a specific class using a specific parameter value
111+
112+
This query expands on the previous example but filters the results even more by
113+
requiring the required class to have one of its parameters be set to a
114+
predetermined value. For example, to obtain all nodes using a specific profile
115+
with a specific cluster name. Note how `parameters` is a field of the resources
116+
endpoint, but since it's a hash we need to use the dot-notation for accessing
117+
sub-elements.
118+
119+
```shell
120+
puppet query 'nodes[certname] {resources {type = "Class" and title = "CapitalizedClassname" and parameters.cluster_name = "ClusterName"}}'
121+
```
122+
110123
### Get a list of all roles / profiles
111124

112125
```shell

0 commit comments

Comments
 (0)