Search on puppetDB (query)




A few month ago I faced an issue which was caused by puppet. I tried to search (and I found) the reason, why puppet generate config-file for non-exist host for bacula (but it could be happened everywhere, like in nagios config; /etc/hosts entry;…). Now I will explain one tool what you can use for see, what is in puppetDB.


You can use this method in puppet-master host. The command:

curl -X GET http://localhost:8080/v3/resources --data-urlencode query@your_query

Where “your_query” file contain the following:

["=", "certname", "test-mysql01"],
["=", "exported", "true"]

Lets explain it:

The curl command will be query your request. The only variable, what you must to edit is “your_query” . Replace it with your file-name where you declared the search-terms.

The example of file-content will be search for host with test-mysql01 certification-name & filter the result just to exported resources.


For first usage I recommend to start an empty search to see, which kind of data you have on db. After it is much more easier to filter & use the right resource-name.

curl -X GET http://localhost:8080/v3/resources --data-urlencode query@

Warning: Couldn’t read data from file “query@”, this makes an empty POST.
Of course you can use linux commands like grep to filter your result.

For more possibility, please visit Puppet’s official site .

Leave a Reply