Chef Server API Call and Docs

Hello,

I am using https://docs.getchef.com/api_chef_server.html as a reference point for generating HTTP API calls against the Chef Server. The tasks I am trying to accomplish are chiefly programmatic creation and querying of organizations and users. When I follow the examples on that page I think there is an error, or unspoken assumptions. From https://docs.getchef.com/server_orgs.html , a user is contained within an organization. But the API docs are referencing accessing the root of all organizations with a user. Which one is right? Or is there a “superuser” I do not know of?

For example, the API docs reference making calls against “/organizations” for a list of organizations. When I try to do this I get a 404 error. But if I query my organization as “/organizations/dantestshort”, then all is good. The current code I am using (IP Addresses modified):

require 'rubygems’
require 'chef/config’
require 'chef/log’
require 'chef/rest’
require ‘chef’

Not real IP Address

chef_server_url=“https://1.2.3.4:443/organizations/dantestshort"
Chef::Config.from_file(”.chef/knife.rb")
rest = Chef::REST.new(chef_server_url)
nodes = rest.get_rest("/cookbooks")

nodes.each do |node|
puts node
end

What am I doing wrong?
-Dan

This communication is Confidential Information. By using this message and attachments you implicitly consent to terms and conditions set forth at http://www.taos.com/email_disclaimer. If you do not consent or received this message in error, please destroy it.

Which version of the Chef server are you using?

On Mon, Nov 17, 2014 at 8:48 AM, Daniel Klopp dklopp@taos.com wrote:

Hello,

I am using Chef Infra Server API as a reference
point for generating HTTP API calls against the Chef Server. The tasks I
am trying to accomplish are chiefly programmatic creation and querying of
organizations and users. When I follow the examples on that page I think
there is an error, or unspoken assumptions. From
Organizations and Groups , a user is contained within an
organization. But the API docs are referencing accessing the root of all
organizations with a user. Which one is right? Or is there a "superuser"
I do not know of?

For example, the API docs reference making calls against "/organizations"
for a list of organizations. When I try to do this I get a 404 error. But
if I query my organization as "/organizations/dantestshort", then all is
good. The current code I am using (IP Addresses modified):

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

Not real IP Address

chef_server_url="https://1.2.3.4:443/organizations/dantestshort"
Chef::Config.from_file(".chef/knife.rb")
rest = Chef::REST.new(chef_server_url)
nodes = rest.get_rest("/cookbooks")

nodes.each do |node|
puts node
end

What am I doing wrong?
-Dan

This communication is Confidential Information. By using this message and
attachments you implicitly consent to terms and conditions set forth at
Taos is now IBM Platform Engineering Services | IBM. If you do not consent or received
this message in error, please destroy it.

12.0.0-rc.5

-Dan


From: James Scott [jamescott@opscode.com]
Sent: Monday, November 17, 2014 8:53 AM
To: chef@lists.opscode.com
Subject: [chef] Re: Chef Server API Call and Docs

Which version of the Chef server are you using?

On Mon, Nov 17, 2014 at 8:48 AM, Daniel Klopp <dklopp@taos.commailto:dklopp@taos.com> wrote:
Hello,

I am using https://docs.getchef.com/api_chef_server.html as a reference point for generating HTTP API calls against the Chef Server. The tasks I am trying to accomplish are chiefly programmatic creation and querying of organizations and users. When I follow the examples on that page I think there is an error, or unspoken assumptions. From https://docs.getchef.com/server_orgs.html , a user is contained within an organization. But the API docs are referencing accessing the root of all organizations with a user. Which one is right? Or is there a “superuser” I do not know of?

For example, the API docs reference making calls against “/organizations” for a list of organizations. When I try to do this I get a 404 error. But if I query my organization as “/organizations/dantestshort”, then all is good. The current code I am using (IP Addresses modified):

require 'rubygems’
require 'chef/config’
require 'chef/log’
require 'chef/rest’
require ‘chef’

Not real IP Address

chef_server_url=“https://1.2.3.4:443/organizations/dantestshort"
Chef::Config.from_file(”.chef/knife.rb")
rest = Chef::REST.new(chef_server_url)
nodes = rest.get_rest("/cookbooks")

nodes.each do |node|
puts node
end

What am I doing wrong?
-Dan

This communication is Confidential Information. By using this message and attachments you implicitly consent to terms and conditions set forth at http://www.taos.com/email_disclaimer. If you do not consent or received this message in error, please destroy it.

Hello Dan,

You're right in that there is a superuser you're not aware of. It's
called the pivotal user and it's setup when you create your Chef server.
It's primary function is to be used by Manage, the WebUI, to be able to
make calls to do things like you're doing and setup organizations. A
normal user in the system does not have access to do this.

The chef-server-ctl org-create and related commands also make user of
the pivotal user in this way. In fact, the chef-server-ctl commands are
currently just a wrapper over knife-opc (which stands for knife opscode
private chef, a bit outdated in its naming now). knife-opc is a knife
addon that when configured with the pivotal user can perform cross
organization calls.

If you want to look at knife-opc as an example of what it's doing, it is
open source and can be found here: GitHub - chef-boneyard/knife-opc: Knife plugin for managing Chef Server Organizations

Thanks,

Mark Mzyk

Daniel Klopp mailto:dklopp@taos.com
November 17, 2014 at 12:00 PM
12.0.0-rc.5

-Dan

From: James Scott [jamescott@opscode.com]
Sent: Monday, November 17, 2014 8:53 AM
To: chef@lists.opscode.com
Subject: [chef] Re: Chef Server API Call and Docs

Which version of the Chef server are you using?

Daniel Klopp mailto:dklopp@taos.com
November 17, 2014 at 11:48 AM
Hello,

I am using Chef Infra Server API as a
reference point for generating HTTP API calls against the Chef
Server. The tasks I am trying to accomplish are chiefly programmatic
creation and querying of organizations and users. When I follow the
examples on that page I think there is an error, or unspoken
assumptions. From Organizations and Groups , a user
is contained within an organization. But the API docs are referencing
accessing the root of all organizations with a user. Which one is
right? Or is there a "superuser" I do not know of?

For example, the API docs reference making calls against
"/organizations" for a list of organizations. When I try to do this I
get a 404 error. But if I query my organization as
"/organizations/dantestshort", then all is good. The current code I
am using (IP Addresses modified):

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

Not real IP Address

chef_server_url="https://1.2.3.4:443/organizations/dantestshort"
Chef::Config.from_file(".chef/knife.rb")
rest = Chef::REST.new(chef_server_url)
nodes = rest.get_rest("/cookbooks")

nodes.each do |node|
puts node
end

What am I doing wrong?
-Dan

This communication is Confidential Information. By using this message
and attachments you implicitly consent to terms and conditions set
forth at Taos is now IBM Platform Engineering Services | IBM. If you do not consent
or received this message in error, please destroy it.

Mark,

Thanks, that worked great. I was able to create an organization.

Where can I fork the docs or submit a doc update request? I feel that the pivotal user should be mentioned as a requirement to using the API calls. Also it might be helpful to have an actual configuration example for polling the server, as for most of the details I was left to finding third party websites for help. As it stands now, https://docs.getchef.com/api_chef_server.html lacks those details.

-Dan


From: Mark Mzyk [mmzyk@getchef.com]
Sent: Monday, November 17, 2014 11:49 AM
To: chef@lists.opscode.com
Subject: [chef] Re: RE: Re: Chef Server API Call and Docs

Hello Dan,

You’re right in that there is a superuser you’re not aware of. It’s called the pivotal user and it’s setup when you create your Chef server. It’s primary function is to be used by Manage, the WebUI, to be able to make calls to do things like you’re doing and setup organizations. A normal user in the system does not have access to do this.

The chef-server-ctl org-create and related commands also make user of the pivotal user in this way. In fact, the chef-server-ctl commands are currently just a wrapper over knife-opc (which stands for knife opscode private chef, a bit outdated in its naming now). knife-opc is a knife addon that when configured with the pivotal user can perform cross organization calls.

If you want to look at knife-opc as an example of what it’s doing, it is open source and can be found here: https://github.com/opscode/knife-opc

Thanks,

Mark Mzyk

[cid:part1.09030801.08040003@getchef.com]
Daniel Kloppmailto:dklopp@taos.com
November 17, 2014 at 12:00 PM
12.0.0-rc.5

-Dan


From: James Scott [jamescott@opscode.commailto:jamescott@opscode.com]
Sent: Monday, November 17, 2014 8:53 AM
To: chef@lists.opscode.commailto:chef@lists.opscode.com
Subject: [chef] Re: Chef Server API Call and Docs

Which version of the Chef server are you using?

[cid:part1.09030801.08040003@getchef.com]
Daniel Kloppmailto:dklopp@taos.com
November 17, 2014 at 11:48 AM
Hello,

I am using https://docs.getchef.com/api_chef_server.html as a reference point for generating HTTP API calls against the Chef Server. The tasks I am trying to accomplish are chiefly programmatic creation and querying of organizations and users. When I follow the examples on that page I think there is an error, or unspoken assumptions. From https://docs.getchef.com/server_orgs.html , a user is contained within an organization. But the API docs are referencing accessing the root of all organizations with a user. Which one is right? Or is there a “superuser” I do not know of?

For example, the API docs reference making calls against “/organizations” for a list of organizations. When I try to do this I get a 404 error. But if I query my organization as “/organizations/dantestshort”, then all is good. The current code I am using (IP Addresses modified):

require 'rubygems’
require 'chef/config’
require 'chef/log’
require 'chef/rest’
require ‘chef’

Not real IP Address

chef_server_url=“https://1.2.3.4:443/organizations/dantestshort"https://1.2.3.4:443/organizations/dantestshort
Chef::Config.from_file(”.chef/knife.rb")
rest = Chef::REST.new(chef_server_url)
nodes = rest.get_rest("/cookbooks")

nodes.each do |node|
puts node
end

What am I doing wrong?
-Dan

This communication is Confidential Information. By using this message and attachments you implicitly consent to terms and conditions set forth at http://www.taos.com/email_disclaimer. If you do not consent or received this message in error, please destroy it.

On Mon, Nov 17, 2014 at 7:28 PM, Daniel Klopp dklopp@taos.com wrote:

Mark,

Thanks, that worked great. I was able to create an organization.

Where can I fork the docs or submit a doc update request? I feel that the
pivotal user should be mentioned as a requirement to using the API calls.
Also it might be helpful to have an actual configuration example for
polling the server, as for most of the details I was left to finding third
party websites for help. As it stands now,
Chef Infra Server API lacks those details.

Hi Daniel,

The docs are all reStructuredText over at
GitHub - chef-boneyard/chef-web-docs-2016: DEPRECATED - All The Documentation. If you know RST you can submit a
patch, otherwise just put in a GitHub issue.

  • Julian

--
[ Julian C. Dunn jdunn@aquezada.com * Sorry, I'm ]
[ WWW: Julian Dunn's Blog - Commentary on media, technology, and everything in between. * only Web 1.0 ]
[ gopher://sdf.org/1/users/keymaker/ * compliant! ]
[ PGP: 91B3 7A9D 683C 7C16 715F 442C 6065 D533 FDC2 05B9 ]

I added a quick warning yesterday based on this thread. The pivotal user is
required for the following endpoints:

/organizations
/users

I would love it if you could send me a usage example for polling the
server. Please send it to docs@getchef.com and I'm happy to do the backend
work in the chef-docs repo to get it added to the docs collection. A github
issue or PR is fine, of course, if you prefer those routes.

james

On Mon, Nov 17, 2014 at 6:53 PM, Julian C. Dunn jdunn@aquezada.com wrote:

On Mon, Nov 17, 2014 at 7:28 PM, Daniel Klopp dklopp@taos.com wrote:

Mark,

Thanks, that worked great. I was able to create an organization.

Where can I fork the docs or submit a doc update request? I feel that
the pivotal user should be mentioned as a requirement to using the API
calls. Also it might be helpful to have an actual configuration example
for polling the server, as for most of the details I was left to finding
third party websites for help. As it stands now,
Chef Infra Server API lacks those details.

Hi Daniel,

The docs are all reStructuredText over at
GitHub - chef-boneyard/chef-web-docs-2016: DEPRECATED - All The Documentation. If you know RST you can submit a
patch, otherwise just put in a GitHub issue.

  • Julian

--
[ Julian C. Dunn jdunn@aquezada.com * Sorry, I'm ]
[ WWW: http://www.aquezada.com/staff/julian * only Web 1.0 ]
[ gopher://sdf.org/1/users/keymaker/ * compliant! ]
[ PGP: 91B3 7A9D 683C 7C16 715F 442C 6065 D533 FDC2 05B9 ]

Thanks! I looked at the 800MB doc directory and was a tad intimidated.

I’ll submit an issue with example code in the next day or two.

-Dan


From: James Scott [jamescott@opscode.com]
Sent: Tuesday, November 18, 2014 10:25 AM
To: chef@lists.opscode.com
Subject: [chef] Re: Re: RE: Re: RE: Re: Chef Server API Call and Docs

I added a quick warning yesterday based on this thread. The pivotal user is required for the following endpoints:

/organizations
/users

I would love it if you could send me a usage example for polling the server. Please send it to docs@getchef.commailto:docs@getchef.com and I’m happy to do the backend work in the chef-docs repo to get it added to the docs collection. A github issue or PR is fine, of course, if you prefer those routes.

james

On Mon, Nov 17, 2014 at 6:53 PM, Julian C. Dunn <jdunn@aquezada.commailto:jdunn@aquezada.com> wrote:
On Mon, Nov 17, 2014 at 7:28 PM, Daniel Klopp <dklopp@taos.commailto:dklopp@taos.com> wrote:
Mark,

Thanks, that worked great. I was able to create an organization.

Where can I fork the docs or submit a doc update request? I feel that the pivotal user should be mentioned as a requirement to using the API calls. Also it might be helpful to have an actual configuration example for polling the server, as for most of the details I was left to finding third party websites for help. As it stands now, https://docs.getchef.com/api_chef_server.html lacks those details.

Hi Daniel,

The docs are all reStructuredText over at https://github.com/opscode/chef-docs. If you know RST you can submit a patch, otherwise just put in a GitHub issue.

  • Julian


[ Julian C. Dunn <jdunn@aquezada.commailto:jdunn@aquezada.com> * Sorry, I’m ]
[ WWW: http://www.aquezada.com/staff/julian * only Web 1.0 ]
[ gopher://sdf.org/1/users/keymaker/http://sdf.org/1/users/keymaker/ * compliant! ]
[ PGP: 91B3 7A9D 683C 7C16 715F 442C 6065 D533 FDC2 05B9 ]

This communication is Confidential Information. By using this message and attachments you implicitly consent to terms and conditions set forth at http://www.taos.com/email_disclaimer. If you do not consent or received this message in error, please destroy it.

Haha. True!

It's the PNG images that makes it so large.

I look forward to seeing the example!

james

On Tue, Nov 18, 2014 at 10:28 AM, Daniel Klopp dklopp@taos.com wrote:

Thanks! I looked at the 800MB doc directory and was a tad intimidated.

I'll submit an issue with example code in the next day or two.

-Dan


From: James Scott [jamescott@opscode.com]
Sent: Tuesday, November 18, 2014 10:25 AM
To: chef@lists.opscode.com
Subject: [chef] Re: Re: RE: Re: RE: Re: Chef Server API Call and Docs

I added a quick warning yesterday based on this thread. The pivotal
user is required for the following endpoints:

/organizations
/users

I would love it if you could send me a usage example for polling the
server. Please send it to docs@getchef.com and I'm happy to do the
backend work in the chef-docs repo to get it added to the docs collection.
A github issue or PR is fine, of course, if you prefer those routes.

james

On Mon, Nov 17, 2014 at 6:53 PM, Julian C. Dunn jdunn@aquezada.com
wrote:

On Mon, Nov 17, 2014 at 7:28 PM, Daniel Klopp dklopp@taos.com wrote:

Mark,

Thanks, that worked great. I was able to create an organization.

Where can I fork the docs or submit a doc update request? I feel that
the pivotal user should be mentioned as a requirement to using the API
calls. Also it might be helpful to have an actual configuration example
for polling the server, as for most of the details I was left to finding
third party websites for help. As it stands now,
Chef Infra Server API lacks those details.

Hi Daniel,

The docs are all reStructuredText over at
GitHub - chef-boneyard/chef-web-docs-2016: DEPRECATED - All The Documentation. If you know RST you can submit a
patch, otherwise just put in a GitHub issue.

  • Julian

--
[ Julian C. Dunn jdunn@aquezada.com * Sorry, I'm ]
[ WWW: http://www.aquezada.com/staff/julian * only Web 1.0 ]
[ gopher://sdf.org/1/users/keymaker/ * compliant! ]
[ PGP: 91B3 7A9D 683C 7C16 715F 442C 6065 D533 FDC2 05B9 ]

This communication is Confidential Information. By using this message and
attachments you implicitly consent to terms and conditions set forth at
Taos is now IBM Platform Engineering Services | IBM. If you do not consent or received
this message in error, please destroy it.

James,

I submitted an issue 404

If there are any questions please let me know,
-Dan


From: James Scott [jamescott@opscode.com]
Sent: Tuesday, November 18, 2014 11:40 AM
To: chef@lists.opscode.com
Subject: [chef] Re: RE: Re: Re: RE: Re: RE: Re: Chef Server API Call and Docs

Haha. True!

It’s the PNG images that makes it so large.

I look forward to seeing the example!

james

On Tue, Nov 18, 2014 at 10:28 AM, Daniel Klopp <dklopp@taos.commailto:dklopp@taos.com> wrote:
Thanks! I looked at the 800MB doc directory and was a tad intimidated.

I’ll submit an issue with example code in the next day or two.

-Dan


From: James Scott [jamescott@opscode.commailto:jamescott@opscode.com]
Sent: Tuesday, November 18, 2014 10:25 AM
To: chef@lists.opscode.commailto:chef@lists.opscode.com
Subject: [chef] Re: Re: RE: Re: RE: Re: Chef Server API Call and Docs

I added a quick warning yesterday based on this thread. The pivotal user is required for the following endpoints:

/organizations
/users

I would love it if you could send me a usage example for polling the server. Please send it to docs@getchef.commailto:docs@getchef.com and I’m happy to do the backend work in the chef-docs repo to get it added to the docs collection. A github issue or PR is fine, of course, if you prefer those routes.

james

On Mon, Nov 17, 2014 at 6:53 PM, Julian C. Dunn <jdunn@aquezada.commailto:jdunn@aquezada.com> wrote:
On Mon, Nov 17, 2014 at 7:28 PM, Daniel Klopp <dklopp@taos.commailto:dklopp@taos.com> wrote:
Mark,

Thanks, that worked great. I was able to create an organization.

Where can I fork the docs or submit a doc update request? I feel that the pivotal user should be mentioned as a requirement to using the API calls. Also it might be helpful to have an actual configuration example for polling the server, as for most of the details I was left to finding third party websites for help. As it stands now, https://docs.getchef.com/api_chef_server.html lacks those details.

Hi Daniel,

The docs are all reStructuredText over at https://github.com/opscode/chef-docs. If you know RST you can submit a patch, otherwise just put in a GitHub issue.

  • Julian


[ Julian C. Dunn <jdunn@aquezada.commailto:jdunn@aquezada.com> * Sorry, I’m ]
[ WWW: http://www.aquezada.com/staff/julian * only Web 1.0 ]
[ gopher://sdf.org/1/users/keymaker/http://sdf.org/1/users/keymaker/ * compliant! ]
[ PGP: 91B3 7A9D 683C 7C16 715F 442C 6065 D533 FDC2 05B9 ]

This communication is Confidential Information. By using this message and attachments you implicitly consent to terms and conditions set forth at http://www.taos.com/email_disclaimer. If you do not consent or received this message in error, please destroy it.