> Thanks, but I says about query like this:
>
> ["and",
>   ["and",
>     ["=", "type", "Class"],
>     ["=", "title", "Php"]],
>   ["and",
>     ["=", "type", "Class"],
>     ["=", "title", "Nginx"]]]

Think about what this does behind the scenes on the resources endpoint
(see the query here:
https://gist.github.com/kbarber/d557da843b363ce3af3a#file-gistfile1-sql-L9-L13)
, it ultimately is just going to attempt to find a class resource that
has the title php AND nginx. Since a column can't have two values,
this will return nothing. If you had a base OR at the top, it would
return both the php and nginx classes, but this still isn't going to
provide you everything, but at least it will give you enough
information to break this down on the client end.

In the SQL world, the way I might construct such a query, is to get
all the class resources with nginx and php as the title, and then you
would need a list of distinct certificate names for both, and you
would want to find the overlap between the two, using an intersection
query for example
(http://www.postgresql.org/docs/9.3/static/queries-union.html). None
of this is supported by the PuppetDB query API today.

> Unfortunately, this query doesn't work.
>
> I use generate function and my own python script for puppetdb query. My
> question is how get list of nodes with two resources in one query.

Take another look at my suggestion:
https://gist.github.com/kbarber/6840f5b1a74d985d8167. It _is_ one
query. There is no shame in doing some work on the client side to
finish the job, you should be able to accomplish this last step in
Python quite easily.

ken.

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CAE4bNTnm0N038Xg6vScyzwvU%3Dfz9DpBnxVnp7E6c5bCFU7DUag%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to