Anyway I'm interested to know if is it possibile to achieve the same result in a more elegant/efficient way too :-)
Il 08/feb/2014 03:18 "Mick Brooks" <
">
> ha scritto:
>
> Hi,
>
> I'm trying to write a wrapper cookbook for postfix, with the intention of just setting some attributes for my organisation. However, some of the attributes defined in the postfix cookbook are 'conditional' i.e. whether they're defined depends on values of other attributes. That decision is being made when postfix's attributes/default.rb file is processed, which is before the attributes for my wrapper are processed, and so (some of) the attributes I'm setting in the wrapper are being ignored. Well, not ignored exactly: their values are updated, but the values of attributes defined conditionally on them are not.
>
> Here's a concrete example. The postfix cookbook has an attributes/default.rb file with:
> ----
> if node['postfix']['main']['smtp_sasl_auth_enable'] == 'yes'
> ...
> default['postfix']['main']['smtp_sasl_security_options'] = 'noanonymous'
> ...
> end
> ----
>
> In my wrapper I added an attributes/default.rb file with:
> ----
> override['postfix']['main']['smtp_sasl_auth_enable'] = 'yes'
> ----
>
> but, when the postfix recipe is run the node['postfix']['main']['smtp_sasl_auth_enable'] value is not being defined i.e. my override has not fully taken effect.
>
> Is there a way to set the node['postfix']['main']['smtp_sasl_auth_enable'] value from my wrapper
> such that node['postfix']['main']['smtp_sasl_security_options'] = 'noanonymous' is declared as in
> the postfix cookbook?
>
> I did find the documentation about reloading attributes[1], but updating my recipes/default.rb file
> to:
> ----
> ruby_block 'some_code' do
> block do
> node.from_file(run_context.resolve_attribute("postfix", "default"))
> end
> action :create
> end
>
> include_recipe 'postfix::default'
> include_recipe 'postfix::sasl_auth'
> ----
>
> didn't seem to help. What am I doing wrong?
>
> Thanks in advance,
>
> Mick
>
> [1]
http://docs.opscode.com/essentials_cookbook_recipes.html#reload-attributes
>
> --
> Mick Brooks -
">
>
http://www.accu.org/ - Professionalism in Programming