Where possible you should try to set the attributes in your wrapper
cookbook's attributes file, not the recipe itself. It is safe (and
recommended) to do so if you only have app-wrapper-cookbook in your
run list and depend on app-cookbook in metadata; app-cookbook's
attributes will get loaded first and then overridden by the wrapper.
In the wrapper's attributes file you need only do
default['asm']['user'] = 'otheruser'
There is no need to use "set" priority. "default" will do fine, given
merge order.
Even if you want to change the attribute in recipe context, you are
modifying the attribute in the wrong order. You need to do this before
include_recipe. That's because include_recipe will compile and add the
user to the resource collection before you've had a chance to change
the attribute.
You can read http://www.getchef.com/blog/2013/12/03/doing-wrapper-cookbooks-right/
for more background & guidance on wrapper cookbooks.
regards,
Julian
--
On Tue, Dec 10, 2013 at 11:37 PM, millisami r < "> > wrote:
>
> Ohai! Chefs!
>
> Having issues with the attribute while developing wrapper cookbook to deploy
> the app cookbook.
> Following are the 2 cookbooks to explain the problem.
>
> =================================
> app-cookbook
> - attributes
> default['asm']['user'] = "vagrant"
> - recipes
> - default.rb
>
> user node['asm']['user'] do
> password node['asm']['password']
> home "/home/#{node['asm']['user']}"
> end
> ---------------------------------
> app-wrapper-cookbook
> - recipes
> - default.rb
>
> include_recipe "app-cookbook::default"
> node.set['asm']['user'] = 'otheruser'
> =================================
>
> When I run the `app-wrapper-cookbook`, the attribute set in wrapper cookbook
> `node.set['asm']['user'] = 'otheruser'` doesn't take effect.
> Instead it reads the value `vagrant`.
> It should have been `otheruser` ?
>
> How to solve this attribute precedence while building the wrapper cookbook ?
>
>
> @millisami
> ~Sachin Sagar Rai
> Ruby on Rails Developer
> http://tfm.com.np
> http://nepalonrails.com
[ Julian C. Dunn < "> > * 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 ]
Archive powered by MHonArc 2.6.16.