On Tue, Jun 19, 2012 at 9:55 AM, David Schmitt <da...@dasz.at> wrote:

> On 19.06.2012 16:48, Erik Dalén wrote:
>
>> I've created a set of functions that exposes the PuppetDB query API
>> from inside puppet. Feel free to give them a spin and get back to me
>> with any bugs or feedback.
>>
>> https://github.com/dalen/**puppet-puppetdbquery<https://github.com/dalen/puppet-puppetdbquery>
>>
>> They require ruby-restclient, ruby-json and the puppetdb-terminus.
>>
>> To give you an example of a query you can do inside puppet code using
>> these functions and PuppetDB:
>>
>> # Return an array of active nodes with an uptime more than 30 days and
>> # having the class 'apache'
>> $hosts = pdbnodequery([ 'and', [ '=', [ 'node', 'active' ], true ],
>> ['>', [ 'fact', 'uptime_days' ], 30 ] ],
>>   [ 'and', [ '=', 'type', 'Class' ], [ '=', 'title', 'Apache' ] ] )"
>>
>> This can be used for example to populate lists of nodes behind load
>> balancers and such dynamically instead of writing them down in your
>> puppet code.
>>
>
> Nice! Do you have any number comparing the performance of this against
> collection of a similar amount of resources by the puppetmaster?
>

Looking at the code, it's issuing queries against the same HTTP endpoint as
the PuppetDB resource terminus. For the same query, it should perform
(quite literally) exactly the same; the functions are getting the same data
in the same way from the same place.

Keep in mind, though, that these functions allow for more advanced queries
than collection syntax currently allows: arbitrarily nested booleans, you
can query for things other than resources, you can query across types, etc.
So it's not _quite_ apples-to-apples. :)

deepak

--
Deepak Giridharagopal / Puppet Labs / grim_radical

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to