[chef] Re: Re: Running resources & not_if { } qualifier


Chronological Thread 
  • From: Dreamcat4 < >
  • To:
  • Subject: [chef] Re: Re: Running resources & not_if { } qualifier
  • Date: Thu, 2 Dec 2010 15:53:06 +0000
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=wngATw4mjXgz9Bnt9IIxRo7spVWqJJCQWsRHIhm9N7EfTeCgOsZPIUfQ0GdCqgq6M8 IPACBKgGh53pnJgFwfkIq8/tFZqDKDxAajZXvhRnbRGemQbIpKkfVoCoclp1q3M8gh1V cy5PYCIbz/ZSWvO16VJmrym8hXbtJy95JEbMw=

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




Archive powered by MHonArc 2.6.16.

§