Ask Your Question

Query PuppetDB for 2 facts at once

asked 2015-08-12 14:41:27 -0600

Robert Keating gravatar image

I tried variations of the following, but no luck: ('["or", ["=", "name", "kernelversion"], ["=", "name", "instance_uuid"]]')

thank you for your help!

edit retag flag offensive close merge delete


Can you post the exact command that you're using as well as the response from the API?

GregLarkin gravatar imageGregLarkin ( 2015-08-12 23:32:47 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2015-08-13 10:29:18 -0600

Robert Keating gravatar image

updated 2015-08-14 22:02:54 -0600

GregLarkin gravatar image

(edit) Oppps - this is not an 'Answer', its a comment: I get 2 outputs per node. How can I get one output per node?


curl -X GET \
  --data-urlencode 'query=["or", ["=", "name", "kernelversion"], ["=", "name", "instance_uuid"]]' \
  --tlsv1 \
  --cacert .ca.pem \
  --cert .public.pem \
  --key .private.pem


}, {
  "certname" : "",
  "name" : "instance_uuid",
  "value" : "a5348a51-624c-40b0-9b6b-dfb2dae1b796"
}, {
  "certname" : "",
  "name" : "kernelversion",
  "value" : "2.6.32"
edit flag offensive delete link more


Actually its a new question, not even a comment. Either way, the answer is subqueries: The example uses PDB 3.0 and the v4 api fyi.

ken gravatar imageken ( 2015-08-17 06:43:02 -0600 )edit

answered 2015-08-14 22:09:37 -0600

GregLarkin gravatar image

AFAICT, each fact result will be returned in a separate JSON array, according to

Do you want the response to look like this?

  "certname" : "",
    { "name" : "instance_uuid", "value" : "a5348a51-624c-40b0-9b6b-dfb2dae1b796" },
    { "name" : "kernelversion", "value" : "2.6.32" }

I'm sure that's not valid JSON syntax, but you'll probably get the idea. Unfortunately, it doesn't look like the API can do that, so I guess the best option would be to write a script that consumes the output from the API and rearranges it to the form that you need.

edit flag offensive delete link more


I don't believe this is entirely true Greg - the API can handle some of it with subqueries, see my comment above. What it can't do is returning that fact data at the same time.

ken gravatar imageken ( 2015-08-17 06:43:37 -0600 )edit

Thank you for the clarification and correct answer above, Ken.

GregLarkin gravatar imageGregLarkin ( 2015-08-18 11:40:39 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2015-08-12 14:41:27 -0600

Seen: 97 times

Last updated: Aug 14 '15