Created nested attribute layout from wrapper cookbook name


#1

Hi!

We are currently building out a Chef platform using hosted chef.

Situation:
At the moment we are leveraging the creation of two style of cookbooks, library cookbooks which provide the logic to create, install, destroy software like JBoss, and application/service cookbooks which is the name of the service and then contains references back to any libraries it needs to construct the service, like the following:

Library example:
BuildJBoss Cookbook:
Recipes:
createinstance.rb
destroyinstance.rb
installbinary.rb

Attributes:
default.rb:
default[‘BuildJBoss’][‘version’] = “6.0”

Service/Application cookbook:
Myface Cookbook:
Recipes:
appserver.rb:
Include_recipe "BuildJBoss::installbinary.rb"
Include_recipe “BuildJBoss::createinstance.rb”

Attribute:
default.rb:
node.override[‘BuildJBoss’][‘version’] = “6.3”

Problem:
Now when we deploy our application cookbook using the above any attributes are righly so displayed under the BuildJBoss attribute key which is defined in the library.
The problem I currently have is that the organization has a requirement where we want the key to be the name of the service/application cookbook deployed at the top level rather than the key equalling the name of the library that is being deployed.

Example:

Currently deployed:
BuildJBoss {
:version => “6.3” ;
:name => “test”

}

What is desired:
myface{

BuildJBoss { 
     :version => "6.3"
     :name => "test"
}

}

What I’ve tried so far is changing my library cookbook’s attributes and attribute calls to something like node[#{cookbook_name}] but this doesn’t work as the cookbook_name is a method and the hash is expecting a string as it’s key. I’d like to a way to be able to achieve what is described above, I’ve created all of our library cookbooks in house so am not against the idea of a refactor or designing it in a different way.

Many thanks,
Adam Street