Thanks Luke. I was trying to override the insync method and couldn't figure out 
where it was getting the value being passed in, but now I see it was because I 
wasn't overriding retrieve. 

On Oct 18, 2010, at 11:50 AM, Luke Kanies <[email protected]> wrote:

> Hi Carl,
> 
> As Markus indicates - you nearly always need to override the 'insync?' and 
> 'retrieve' methods to return the appropriate values.  That is, the default 
> version of these methods only return :absent or :present from 'retrieve' and 
> do a boolean comparison in 'insync?'.
> 
> You should also be able to drastically simplify your newvalue hooks - that 
> style might still exist in some examples, but it shouldn't.  You should be 
> able to do things like:
> 
> newvalue(:absent) do
>   provider.destroy
> end
> 
> The transaction is smart enough to only ever call 'destroy' if the provider 
> isn't already absent.
> 
> On Oct 18, 2010, at 7:14 AM, Markus Roberts wrote:
> 
>> Carl --
>> 
>> What's in your manifest?  Are you doing "ensure => latest"?  
>> 
>> If so, the results you are seeing could makes sense if you haven't done 
>> anything to make "insync?" aware of versions.  It would detect the resource 
>> as "present" and then set it to "latest" each time.
>> 
>> See lib/puppet/type/package.rb to see an example of making "insync?" 
>> version-aware (though this is probably more complex than you need, as it's 
>> also dealing with other issues at the same time).
>> 
>> -- Markus
>> 
>> On Sun, Oct 17, 2010 at 4:32 PM, Carl Caum <[email protected]> wrote:
>> Hello all.  I can't seem to get my ensurable to work for a custom type I'm 
>> working on.   Every time I run puppet I just get the message "ensure changed 
>> 'present' to 'latest'".  I feel like I'm missing something obvious.
>> 
>> 
>>    ensurable do
>>        desc "Possible values are *present*, *absent*, *installed*, and 
>> *latest*."
>> 
>>        newvalue(:absent) do
>>            if provider.exists?
>>                provider.destroy
>>            end
>>        end
>> 
>>        newvalue(:present) do
>>            unless provider.exists?
>>                provider.create
>>            end
>>        end
>>        aliasvalue(:installed, :present)
>> 
>>        newvalue(:latest) do
>>            unless provider.latest?
>>                provider.update
>>            end
>>        end
>>    end
>> 
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Puppet Developers" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to 
>> [email protected].
>> For more options, visit this group at 
>> http://groups.google.com/group/puppet-dev?hl=en.
>> 
>> 
>> 
>> 
>> -- 
>> -----------------------------------------------------------
>> The power of accurate observation is 
>> commonly called cynicism by those 
>> who have not got it.  ~George Bernard Shaw
>> ------------------------------------------------------------
>> 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Puppet Developers" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to 
>> [email protected].
>> For more options, visit this group at 
>> http://groups.google.com/group/puppet-dev?hl=en.
> 
> 
> -- 
> There are three kinds of death in this world.  There's heart death,
> there's brain death, and there's being off the network.  -- Guy Almes
> ---------------------------------------------------------------------
> Luke Kanies  -|-   http://puppetlabs.com   -|-   +1(615)594-8199
> 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Puppet Developers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/puppet-dev?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to