- From: Ash Berlin <
>
- To:
- Subject: [chef] Re: Re: Re: Running resources & not_if { } qualifier
- Date: Thu, 2 Dec 2010 15:56:55 +0000
On 2 Dec 2010, at 15:53, Dreamcat4 wrote:
>
On Thu, Dec 2, 2010 at 3:20 PM, Ash Berlin
>
<
>
>
wrote:
>
> On 2 Dec 2010, at 15:13, Dreamcat4 wrote:
>
>> Hi
>
>> When encountering the not_if qualifier, subsequent resource actions are
>
>> not run?
>
>>
>
>>
>
>> rvm default_ruby do
>
>> action :install
>
>> not_if { default_ruby == "system" } # <---- evaluates to 'true'
>
>> end
>
>>
>
>> rvm default_ruby do # <---- this is skipped
>
>> action :set_default
>
>> end
>
>>
>
>>
>
>>
>
>> dreamcat4
>
>>
>
>
>
> I suspect this is because they both have the same name. I think this will
>
> work instead:
>
>
>
> rvm default_ruby do
>
> action default_ruby == "system" ? [ :install, :set_default ] : [
>
> :set_default ]
>
> end
>
>
Ah it works - thanks Ash. Heres another way:
>
>
actions = []
>
actions << :install unless default_ruby == "system"
>
actions << :set_default
>
>
rvm default_ruby do
>
action actions
>
end
>
>
So we can do it manually. Sure.
>
>
I also wonder if this is a bug in chef? Each time the array of actions
>
is wiped out and overwritten. Isn't Chef meant to be smart enough to
>
keep the existing actions when encountering new actions?
>
>
>
dreamcat4
>
I think its that its not creating a new resource but augmenting the existing
one, so the second block is just changing the action for the first one (and
keeping the not_if) since they are both "rvm default_ruby" resources.
-ash
Archive powered by MHonArc 2.6.16.