dalen / puppet-puppetdbquery

Query functions for PuppetDB

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

query declared classes of a specific node

unki opened this issue · comments

Previously I was using query_resource() to retrieve all declared classes on a specific node. This was done by:

query_resources("certname=somehost", "Class")

Since I updated to PuppetDB 3.2 and switched to puppetdbquery 2.1.1 the above query does not fail, but retrieves nothing.

I'm not sure how I shall rework that query. I tried already:

query_resource("certname=somehost", "type[class]")
query_resource("certname=somehost", "type[class]{name~'.*'}")

They succeed but also returned no result. Querying PuppetDB directly I would use this query string to retrieve all classes:

curl -X GET http://localhost:8080/pdb/query/v4/resources --data-urlencode 'query=["and", ["=","certname","somehost"], ["=","type","Class"]]'

But I have no clue how I get it work with puppetdbquery.

if I pass around parser and extend query_resources.rb around line 51 by...

if resquery != 'Class'
resquery = parser.parse resquery, :none if resquery and resquery.is_a? String
else
resquery = ["=","type","Class"]
end

... I'm able to restore the previous behaviour