- From: KC Braunschweig <
>
- To: John Vincent <
>
- Cc: Chef Dev <
>
- Subject: [chef-dev] Re: need help fixing CHEF-2345 unable to override supports :status for redhat services
- Date: Thu, 7 Jun 2012 14:34:14 +0200
Oops, dropped the list.
On Thu, Jun 7, 2012 at 2:33 PM, KC Braunschweig
<
>
wrote:
>
Like:
>
>
@new_resource.supports[:status] ||= true
>
>
That won't work because this bit of code seems to run after the
>
settings from the recipe have been pulled in. Otherwise you'd be able
>
to override and this wouldn't be a bug. So whether :status == false
>
because of the default or :status == false because it was set
>
explicitly, it'll get flipped to true regardless. If it were me, I'd
>
probably have made the default nil rather than explicitly false so
>
they could be differentiated, but that would probably require wider
>
changes at this point.
>
>
KC
>
>
On Thu, Jun 7, 2012 at 2:16 PM, John Vincent
>
<
>
>
wrote:
>
> Would an ||= work in that case? I've not dug into the providers in
>
> quite some time.
>
>
>
> On Thu, Jun 7, 2012 at 7:26 AM, KC Braunschweig
>
> <
>
>
> wrote:
>
>> Hoping you guys can help me as I couldn't quite come up with a fix for
>
>> this bug. I think the desired feature was that :status should default
>
>> to true for Redhat rather than false with other providers, but because
>
>> lib/chef/provider/service/redhat.rb does:
>
>>
>
>> @new_resource.supports[:status] = true
>
>>
>
>> The effect is that :status always = true and you can't set it to false
>
>> such as if you have a misbehaving 3rd party init script you can't fix.
>
>> This is lame. Problem is that the defaults come from the resource code
>
>> not the provider so I think that the way to fix this is in
>
>> lib/chef/resource/service.rb when the defaults are set:
>
>>
>
>> @supports = { :restart => false, :reload => false, :status => false }
>
>>
>
>> But to do this I need to inspect the provider to know if we're on
>
>> redhat, something like:
>
>>
>
>> if provider == 'Chef::Provider::Service::Redhat'
>
>>
>
>> = { :restart => false, :reload => false, :status => true }
>
>> else
>
>>
>
>> = { :restart => false, :reload => false, :status => false }
>
>> end
>
>>
>
>> But provider is nil at that point. Tried calling straight to
>
>> Chef::Platform.provider_for_resource(self) but that doesn't work
>
>> either because the run_context isn't set at that point.
>
>>
>
>> Anyone got another angle or a way to make this work?
>
>>
>
>> Thanks,
>
>>
>
>> KC
Archive powered by MHonArc 2.6.16.