[chef] Re: Querying a Chef server through it's API


Chronological Thread 
  • From: Brandon Raabe < >
  • To:
  • Subject: [chef] Re: Querying a Chef server through it's API
  • Date: Fri, 23 Jan 2015 14:09:42 -0700

Hi Angela,

It sounds like you might be getting a nil or empty response back from the chef server. I would try running the same thing in a pry/irb session and see what the return value looks like from rest.get_rest('/nodes').

For what it's worth, you might also want to give ridley a try.


Thanks,
Brandon

On Fri, Jan 23, 2015 at 10:48 AM, ANGELA EBIRIM < " target="_blank"> > wrote:
Hello everyone,

I'm new to Chef so be gentle!

I'm trying to query a Chef server through it's API and have developed the following code:-

require 'chef/config'
require 'chef/log'
require 'chef/rest'
chef_server_url = "http//chef.prod.practor.service"
client_name = "ace67"
signing_key_filename=File.dirname(__FILE__) + "/.chef/ace67.pem"
 
rest = Chef::REST.new(chef_server_url, client_name, signing_key_filename)
nodes = rest.get_rest("/nodes")
 
nodes.keys.each do |node_name|
    puts "Node name: #{node_name}"
end

It's a simple Ruby script to query the Chef server. through it's API, for a list of nodes. However when I run the script, I get an error of TypeError: can't dup NilClass. It's occurring on the nodes  =  rest.get_rest("/nodes") line.

I'm running Chef version 11.16.2

I'd appreciate any assistance with this.

Many thanks

Angela Ebirim

Sent from iCloud




Archive powered by MHonArc 2.6.16.

§