You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jclouds.apache.org by Arulanand Dayalan <ar...@yahoo.com> on 2014/06/23 20:11:00 UTC

Get attributes for a cookbook version


Hi,

I am trying to get list of attributes for a cookbook version and its returning empty. I had checked it in Chef server console and there are attributes available under attribute folder in default.rb file in that cookbook.I am using jclouds version 1.7.3, can you please let me know if this feature is supported currently. Also, can you please let me know if there is a way to get hold of json from rest calls to chef server, so that i can parse it and consume in client.

Regards,
Arul.

Re: Get attributes for a cookbook version

Posted by Chris Custine <ch...@gmail.com>.
When you browse a cookbook in the Chef UI and you see the attributes, you
are actually viewing the files themselves (unless a new version of the UI
has some enhancements that I have not yet seen).

If you control your cookbooks, the easiest way to accomplish what you want
is to document your attributes in your metadata.rb file for the cookbook.
This gives you display names, descriptions, choices, types. etc.  GUI
editing of attributes is exactly what this was meant for.  You can see an
example of this in the attribute section of the docs for metadata here:
http://docs.opscode.com/essentials_cookbook_metadata.html#settings

I used to have some code using jclouds-chef that did exactly what you are
doing but I can't locate it any more.  Should be fairly simple if you use
metadata.

Chris

--
Chris Custine



On Tue, Jun 24, 2014 at 10:55 AM, Arulanand Dayalan <
arul_anand_2000@yahoo.com> wrote:

> Thanks Ignasi. I am trying to build an web app in which recipes of a
> cookbook  would be listed. User select the recipes and attaches it to
> a node. And later runs chef-client to execute it. I was looking to list out
> the attributes used in recipe, so that user can override when
> using chef-client with -j attribute. May be I need to explore other ways of
> fetching attributes.
>
> Regards,
> Arul.
>
>
>   On Tuesday, June 24, 2014 2:47 PM, Ignasi Barrera <na...@apache.org>
> wrote:
>
>
> Hi Arul,
> In Chef, attributes are associated to nodes, roles and environments, but
> not to cookbooks. Cookbooks contain a set of "attribute files" with default
> values for some attributes, but don't "define" them nor set a "complete
> attribute set".
> If you have a look at the Chef server API [1] you'll see that a cookbook
> version does not return any attribute; just a reference to each attribute
> file.
> Having said this, what are you trying to do? You might want to change your
> code to read the attributes from a node.
> Also, looking at the jclouds code, we'll have to change the cookbook
> version "attributes" variable [2] to return a set of Resource (just as the
> recipes do) instead of Attributes. This may have caused confusion. I'll
> open a JIRA to fix this on our side.
>  HTH!
> Ignasi
>
> [1] http://docs.opscode.com/api_chef_server.html#id5
> [2]
> https://github.com/jclouds/jclouds-chef/blob/master/core/src/main/java/org/jclouds/chef/domain/CookbookVersion.java#L171
> El 23/06/2014 20:14, "Arulanand Dayalan" <ar...@yahoo.com>
> escribió:
>
>
> Hi,
>
> I am trying to get list of attributes for a cookbook version and its
> returning empty. I had checked it in Chef server console and there are
> attributes available under attribute folder in default.rb file in that
> cookbook.I am using jclouds version 1.7.3, can you please let me know if
> this feature is supported currently. Also, can you please let me know if
> there is a way to get hold of json from rest calls to chef server, so that
> i can parse it and consume in client.
>
> Regards,
> Arul.
>
>
>
>
>

Re: Get attributes for a cookbook version

Posted by Arulanand Dayalan <ar...@yahoo.com>.
Thanks Ignasi. I am trying to build an web app in which recipes of a cookbook  would be listed. User select the recipes and attaches it to a node. And later runs chef-client to execute it. I was looking to list out the attributes used in recipe, so that user can override when using chef-client with -j attribute. May be I need to explore other ways of fetching attributes. 

Regards,
Arul. 


On Tuesday, June 24, 2014 2:47 PM, Ignasi Barrera <na...@apache.org> wrote:
  


Hi Arul, 
In Chef, attributes are associated to nodes, roles and environments, but not to cookbooks. Cookbooks contain a set of "attribute files" with default values for some attributes, but don't "define" them nor set a "complete attribute set". 
If you have a look at the Chef server API [1] you'll see that a cookbook version does not return any attribute; just a reference to each attribute file.
 
Having said this, what are you trying to do? You might want to change your code to read the attributes from a node. 
Also, looking at the jclouds code, we'll have to change the cookbook version "attributes" variable [2] to return a set of Resource (just as the recipes do) instead of Attributes. This may have caused confusion. I'll open a JIRA to fix this on our side.
 
HTH! 
Ignasi

 
[1] http://docs.opscode.com/api_chef_server.html#id5
[2] https://github.com/jclouds/jclouds-chef/blob/master/core/src/main/java/org/jclouds/chef/domain/CookbookVersion.java#L171 
El 23/06/2014 20:14, "Arulanand Dayalan" <ar...@yahoo.com> escribió:


>
>Hi,
>
>
>I am trying to get list of attributes for a cookbook version and its returning empty. I had checked it in Chef server console and there are attributes available under attribute folder in default.rb file in that cookbook.I am using jclouds version 1.7.3, can you please let me know if this feature is supported currently. Also, can you please let me know if there is a way to get hold of json from rest calls to chef server, so that i can parse it and consume in client. 
>
>
>Regards,
>Arul.
>
>
>
>

Re: Get attributes for a cookbook version

Posted by Ignasi Barrera <na...@apache.org>.
Hi Arul,

In Chef, attributes are associated to nodes, roles and environments, but
not to cookbooks. Cookbooks contain a set of "attribute files" with default
values for some attributes, but don't "define" them nor set a "complete
attribute set".

If you have a look at the Chef server API [1] you'll see that a cookbook
version does not return any attribute; just a reference to each attribute
file.

Having said this, what are you trying to do? You might want to change your
code to read the attributes from a node.

Also, looking at the jclouds code, we'll have to change the cookbook
version "attributes" variable [2] to return a set of Resource (just as the
recipes do) instead of Attributes. This may have caused confusion. I'll
open a JIRA to fix this on our side.

HTH!

Ignasi

[1] http://docs.opscode.com/api_chef_server.html#id5
[2]
https://github.com/jclouds/jclouds-chef/blob/master/core/src/main/java/org/jclouds/chef/domain/CookbookVersion.java#L171
El 23/06/2014 20:14, "Arulanand Dayalan" <ar...@yahoo.com>
escribió:

>
> Hi,
>
> I am trying to get list of attributes for a cookbook version and its
> returning empty. I had checked it in Chef server console and there are
> attributes available under attribute folder in default.rb file in that
> cookbook.I am using jclouds version 1.7.3, can you please let me know if
> this feature is supported currently. Also, can you please let me know if
> there is a way to get hold of json from rest calls to chef server, so that
> i can parse it and consume in client.
>
> Regards,
> Arul.
>
>
>