Querying PuppetDB for nodes that match certain facts

302 views
Skip to first unread message

ab...@littlewiki.in

unread,
Dec 11, 2014, 3:14:21 PM12/11/14
to puppet...@googlegroups.com
Hello.

I want to get the ip-addresses of all Linux machines. Here's my query using curl

query=["=", "name", "ipaddress"],["in", "certname",["extract", "certname", ["select-nodes",["and",["=", "name", "kernel"],["=", "value", "Linux"]]]]]


This returns me the ipaddresses of all the machines. If I add an and condition to the two blocks, it returns a query malformed error. Essentially, I want to get nodes that match factA=B and factC=D and return factX. and factY of each matched node.


How do I go about doing this?

--
Abhi

Wyatt Alt

unread,
Dec 11, 2014, 7:06:56 PM12/11/14
to puppet...@googlegroups.com, ab...@littlewiki.in
Abhi,

Try this:
curl -X GET http://localhost:8080/v4/facts/ipaddress --data-urlencode 'query=["in","certname",["extract","certname",["select-nodes",["=",["fact","kernel"],"Linux"]]]]

Wyatt
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/8fd9d60b-4e25-4e25-8c98-7559bec45ba4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Pete Brown

unread,
Dec 15, 2014, 3:21:22 AM12/15/14
to puppet...@googlegroups.com, ab...@littlewiki.in
I use Erik Dalén's puppetdbquery module to do this sort of thing from
the puppet DSL.
https://forge.puppetlabs.com/dalen/puppetdbquery
> https://groups.google.com/d/msgid/puppet-users/548A3198.8030901%40puppetlabs.com.
>
> For more options, visit https://groups.google.com/d/optout.



--
Pete Brown
Director and Primary Systems Engineer
Abstract IT Pty Ltd.
Reply all
Reply to author
Forward
0 new messages