Hello Austin,
Thanks for your reply.

The issue is I am trying to return certnames based on server_role which I
dont think is a fact, correct me if I am wrong. And since puppet 5.2, we
have nested key, values and not sure how do I reach that leaf. Please check
the json snippet, if you haven't checked yet.

Thanks
Biraj

On Wed, Jul 17, 2019 at 3:55 AM Austin Blatt <austin.bl...@puppet.com>
wrote:

> Apologies in advance if I didn't interpret your query properly, but I
> believe you are looking to return the certnames of servers that have a
> specific fact with a specific value, the best endpoint for that would
> probably be inventory
> <https://puppet.com/docs/puppetdb/6.3/api/query/v4/inventory.html> (or
> maybe fact-contents
> <https://puppet.com/docs/puppetdb/6.3/api/query/v4/fact-contents.html>).
> A curl command for the inventory endpoint could look like this.
>
> curl -X POST http://<your-server>:8080/pdb/query/v4 \
>   -H 'Content-Type:application/json' \
>   -d '{"query": "inventory[certname] { facts.path.to.fact = \"your-value\"
> }" }'
>
> The fact-content query would look similar, but you'd need to match path
> and value there and it doesn't support dot notation like the inventory
> endpoint.
>
> On Tue, Jul 16, 2019 at 10:16 AM Biraj Sahu <birajk.s...@gmail.com> wrote:
>
>>
>> PuppetDB version- 5.2
>>
>> I want to retrieve list of servers with a specific role- tata_umg
>>
>>
>>
>> The json is in below format:
>>
>> [
>>
>>  {
>>
>>      "certname":"<hostname>",
>>
>>      "environment":"xxxx",
>>
>>      "name":"xxxx_clientname",
>>
>>      "value":{
>>
>>         "clientabc":{
>>
>>            "xxxx_productname":{
>>
>>               "tata":{
>>
>>                  "xxxx_instanceid":"0",
>>
>>                  "xxxx_serverrole":[
>>
>>                     "tata_umg"
>>
>>                  ]
>>
>>               }
>>
>>            }
>>
>>         }
>>
>>      }
>>
>>   }]
>>
>> Can use below 2 get requests to reterive:
>>
>> curl -X GET '
>> http://puppetdb.aws.internal:8080/pdb/query/v4/facts/xxxx_clientname'
>>
>> curl -X GET 'http://puppetdb.aws.internal:8080/pdb/query/v4/facts'
>> --data-urlencode 'query=["=", "name", "xxxx_clientname"]'
>>
>>
>>
>> But this gives me a json with all server's - 'xxxx_clientname' and not
>> specific to a certain role.
>>
>>
>>
>> Can anyone please help me update the query to make it work as per my need.
>>
>> --
>> 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/8d2e4bc6-762e-4349-ac28-e20d587d36df%40googlegroups.com
>> <https://groups.google.com/d/msgid/puppet-users/8d2e4bc6-762e-4349-ac28-e20d587d36df%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
> *Austin Blatt*
> Associate Software Engineer
> austin.bl...@puppet.com
>
> --
> 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/CADVW12Mn9LhuvtmqLpxbG5BWPbvsGHJaRK6Pybywg5eHEA__7g%40mail.gmail.com
> <https://groups.google.com/d/msgid/puppet-users/CADVW12Mn9LhuvtmqLpxbG5BWPbvsGHJaRK6Pybywg5eHEA__7g%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
BIRAJ
Pune
Ph no-08861077222

-- 
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/CAHJs-WDtJgYOJyGnxR2k1p2x39rezU-ghJD0Oms-L8snvWh%2B3Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to