[chef] Creating organizations using CHEF::REST


Chronological Thread 
  • From: Carlos Camacho < >
  • To: " " < >
  • Subject: [chef] Creating organizations using CHEF::REST
  • Date: Mon, 14 Sep 2015 15:45:39 +0200

Hello,

I'm trying to access the CHEF::REST API to interact with the Chef
server and I must be missing something as the behavior is quite odd.

Im executing this code:

#-----------------
require 'rubygems'
require 'chef/config'
require 'chef/log'
require 'chef/rest'

chef_server_url = 'http://127.0.0.1'
client_name = 'webui'
signing_key_filename = '/etc/opscode/webui_priv.pem'

rest = Chef::REST.new(chef_server_url, client_name, signing_key_filename)

puts rest.get_rest('/organizations/asdf/users/admin')
puts rest.get_rest('/organizations/asdf/clients')
puts rest.get_rest('/organizations/asdf/users')
puts rest.get_rest('/organizations/asdf/nodes')
puts rest.get_rest('/organizations/asdf')

data = {"username" => "admin", "password" => "4dm1n1str4t0r" }
rest.post_rest('authenticate_user', data)

data = {"name" => "fdsa", "full_name" => "asdf" }
rest.post_rest('organizations', data)
#-----------------

Now, the thing is how to configure correctly the client_name/key in
order to have them working properly?
How this client should be configured correctly?

Depending on the client/key Im getting 401, 403 or empty outputs.

Thanks!



Archive powered by MHonArc 2.6.16.

§