[chef] Re: Re: Re: Re: Attributes not getting set from wrapper cookbook


Chronological Thread 
  • From: millisami r < >
  • To: chef < >
  • Subject: [chef] Re: Re: Re: Re: Attributes not getting set from wrapper cookbook
  • Date: Thu, 12 Dec 2013 08:50:31 +0545

I've already gone through your blog post as well.

Looks like everyone should define their attributes in a single level.
But what for the cases like below where redefining the attributes that take multilevel hash.

    default['rvm']['user_installs'] = [
      { 'user'          => node['asm']['user'],
        'rubies'        => [node["asm"]["rvm"]["ruby"]],
        'default_ruby'    => node["asm"]["rvm"]["ruby"],
        'global_gems' => [
            { 'name'    => 'bundler' },
            { 'name'    => 'rake',
              'version' => '10.1.0'
            },
            {
              'name' => 'unicorn'
            }
        ]
      }
    ]

Do I've to redefine the whole attributes for `default['rvm']['user_installs']` just to override the 
`node['asm']['user']` in the wrapper cookbook.

Or is the idea of nesting attributes is wrong?




@millisami
~Sachin Sagar Rai
Ruby on Rails Developer
http://tfm.com.np
http://nepalonrails.com


On Wed, Dec 11, 2013 at 11:00 PM, Julian C. Dunn < " target="_blank"> > wrote:
On Wed, Dec 11, 2013 at 3:03 AM, millisami r < "> > wrote:
> Thanks for the reply.
> I've modified the case below.
>
> =================================
> app-cookbook
>   - attributes
>     default['asm']['user'] = "vagrant"
>     default['asm']['deploy_to'] = "/home/#{node['asm']['user']}/myapp"
>   - recipes
>     - default.rb
>
>     user node['asm']['user'] do
>       password node['asm']['password']
>       home "/home/#{node['asm']['user']}"
>     end
> ---------------------------------
> app-wrapper-cookbook
>   - recipes
>     - default.rb
>     node.set['asm']['user'] = 'otheruser'
>     include_recipe "app-cookbook::default"
> =================================
>
> In app-cookbook, I've another attribute `['asm']['deploy_to']` which uses
> the `['asm']['user']` to interpolate
> the value to `['asm']['deploy_to']`.
>
> Now running the `app-wrapper-cookbook`, the value for `['asm']['user']` is
> overriden with the value `otheruser`,
> but the value of `['asm']['deploy_to']` still has the `vagrant` in path.
> i.e. It generates `/home/vagrant/myapp` which should also have been
> overridden by `/home/otheruser/myapp`
>
> Is this the way that computed attributes works?
> How chef will resolve such issue?

Because default['asm']['deploy_to'] was computed at attribute load
time, you also need to redefine that in your wrapper. I addressed that
in my blog post as well. :-)

- Julian

--
[ 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.

§