FAQ
I'm trying to query puppetdb for a list of hosts maching a certain regex
(on hostname) and only returns 2 facts (ipaddress and hostname)

I'm trying to follow:
http://docs.puppetlabs.com/puppetdb/latest/api/query/tutorial.html

and I'm not even quite sure, wether or not, I should use a facts or a
nodes, or a resources query ?

I get some of the queries to return just fine.. f.ex. I can query on nodes:
curl -X GET -H 'Accept: application/json' http://localhost:8080/v2/nodes
--data-urlencode 'query=["~", ["fact", "hostname"], "webserver"]'

But I can't figure out how I can make that query, return 1 extra fact
(ipaddress).. ?

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to puppet-users@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Klavs Klavsen at Sep 2, 2013 at 1:41 pm
    I also tried https://github.com/dalen/puppet-puppetdbquery - but that
    didn't really get me any closer :(

    --
    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+unsubscribe@googlegroups.com.
    To post to this group, send email to puppet-users@googlegroups.com.
    Visit this group at http://groups.google.com/group/puppet-users.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Klavs Klavsen at Sep 2, 2013 at 2:00 pm
    This gives me the ipaddress (and hostname).. now to figure out how to
    filter on hostname regex..

    'query=["=", "name", "ipaddress"]'

    --
    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+unsubscribe@googlegroups.com.
    To post to this group, send email to puppet-users@googlegroups.com.
    Visit this group at http://groups.google.com/group/puppet-users.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Ken Barber at Sep 3, 2013 at 6:09 pm
    Is it acceptable to do the search based on 'certname'? ie:

    curl -G 'http://localhost:8080/v2/facts' --data-urlencode
    'query=["and",["~","certname","puppetdb?"],["or",["=","name","ipaddress"],["=","name","hostname"]]]'

    ken.
    On Mon, Sep 2, 2013 at 7:00 AM, Klavs Klavsen wrote:
    This gives me the ipaddress (and hostname).. now to figure out how to filter
    on hostname regex..

    'query=["=", "name", "ipaddress"]'

    --
    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+unsubscribe@googlegroups.com.
    To post to this group, send email to puppet-users@googlegroups.com.
    Visit this group at http://groups.google.com/group/puppet-users.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    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+unsubscribe@googlegroups.com.
    To post to this group, send email to puppet-users@googlegroups.com.
    Visit this group at http://groups.google.com/group/puppet-users.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Klavs Klavsen at Sep 4, 2013 at 12:35 pm
    Den tirsdag den 3. september 2013 20.09.19 UTC+2 skrev Ken Barber:
    Is it acceptable to do the search based on 'certname'? ie:

    curl -G 'http://localhost:8080/v2/facts' --data-urlencode
    'query=["and",["~","certname","puppetdb?"],["or",["=","name","ipaddress"],["=","name","hostname"]]]'

      Thank you - that worked beautifully :)

    Only "detail" - is that it shows 2 results for each host - one for each
    fact being retrieved.

    --
    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+unsubscribe@googlegroups.com.
    To post to this group, send email to puppet-users@googlegroups.com.
    Visit this group at http://groups.google.com/group/puppet-users.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Robert keating at Aug 12, 2015 at 8:03 pm
    Can you help with this query? I am trying to get 2 facts from all of our
    puppet clients in PuppetDB.
    I tried variations of the following, but no luck: ('["or", ["=", "name",
    "kernelversion"], ["=", "name", "instance_uuid"]]')

    Thank you!
    On Tuesday, September 3, 2013 at 11:09:19 AM UTC-7, Ken Barber wrote:

    Is it acceptable to do the search based on 'certname'? ie:

    curl -G 'http://localhost:8080/v2/facts' --data-urlencode
    'query=["and",["~","certname","puppetdb?"],["or",["=","name","ipaddress"],["=","name","hostname"]]]'


    ken.

    On Mon, Sep 2, 2013 at 7:00 AM, Klavs Klavsen <kl...@enableit.dk
    <javascript:>> wrote:
    This gives me the ipaddress (and hostname).. now to figure out how to filter
    on hostname regex..

    'query=["=", "name", "ipaddress"]'

    --
    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 <javascript:>.
    To post to this group, send email to puppet...@googlegroups.com
    <javascript:>.
    Visit this group at http://groups.google.com/group/puppet-users.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    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+unsubscribe@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/0a5346a6-2668-42bd-ab1b-334089b17133%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Ken Barber at Aug 12, 2015 at 8:23 pm

    Can you help with this query? I am trying to get 2 facts from all of our
    puppet clients in PuppetDB.
    I tried variations of the following, but no luck: ('["or", ["=", "name",
    "kernelversion"], ["=", "name", "instance_uuid"]]')
    For me this query works. Here is the full curl example in the latest
    PDB (I replaced instance_uuid with operatingsystem, since I don't have
    that fact and I wanted to show it working with _something_):

    # curl -G 'http://localhost:8080/pdb/query/v4/facts' --data-urlencode
    'query=["or",["=","name","kernelversion"],["=","name","operatingsystem"]]'
    [ {
       "certname" : "kb.local",
       "environment" : "production",
       "name" : "operatingsystem",
       "value" : "Darwin"
    }, {
       "certname" : "kb.local",
       "environment" : "production",
       "name" : "kernelversion",
       "value" : "14.4.0"
    } ]%

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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppuppet-users @
categoriespuppet
postedSep 2, '13 at 1:26p
activeAug 12, '15 at 8:23p
posts7
users3
websitepuppetlabs.com

People

Translate

site design / logo © 2022 Grokbase