Using Ruby puppet db library - syntax question

101 views
Skip to first unread message

JonY

unread,
Jan 20, 2015, 3:00:14 PM1/20/15
to puppet...@googlegroups.com
I'm hoping to use this library (or something similar) to request a single fact from all nodes. The equiv curl request would be 'curl -X GET http://host:8080/v3/facts --data-urlencode 'query=["=","name","fs_space"]'.

I've been looking at the docs on 'https://github.com/puppetlabs/puppetdb-ruby' but I can't seem to get the syntax correct for this type of request. Suggestions?

Nick Howes

unread,
Jan 23, 2015, 8:04:54 AM1/23/15
to puppet...@googlegroups.com
On Tuesday, 20 January 2015 20:00:14 UTC, JonY wrote:
I'm hoping to use this library (or something similar) to request a single fact from all nodes. The equiv curl request would be 'curl -X GET http://host:8080/v3/facts --data-urlencode 'query=["=","name","fs_space"]'.

I've been looking at the docs on 'https://github.com/puppetlabs/puppetdb-ruby' but I can't seem to get the syntax correct for this type of request. Suggestions?


It'll look like this:

response = client.request(
  'facts',
  [:'=', 'name', 'fs_space']
)

nodes = response.data 

The response data will be an array of hashes - each hash containing the node's "certname" and the "name" and "value" of its fact.

JonY

unread,
Jan 23, 2015, 9:20:19 AM1/23/15
to puppet...@googlegroups.com
Tried that - got this error:

/usr/local/lib/ruby/gems/2.1.0/gems/puppetdb-ruby-0.0.1/lib/puppetdb/client.rb:79:in `raise_if_error': PuppetDB::APIError (PuppetDB::APIError)
        from /usr/local/lib/ruby/gems/2.1.0/gems/puppetdb-ruby-0.0.1/lib/puppetdb/client.rb:101:in `request'
        from ./check.rb:8:in `<main>'
 
Reply all
Reply to author
Forward
0 new messages