On Thursday, December 8, 2011 at 9:44 AM, ghellings wrote:
> I've been trying to create a custom provider and I keep running into
> the same error
> err: /Stage[main]/Rvmspokeo::Install/Rvmgem[gearman-ruby]: Could not
> evaluate: No ability to determine if rvmgem exists
> 
> My type and provider seem pretty straight forward to me, what am I
> doing wrong?
> 
> lib/puppet/type/rvmgem.rb
> 
> Puppet::Type.newtype(:rvmgem) do
> @doc = "Manage RVM Gems"
> ensurable
> newproperty(:provider) do
> desc "Provider from gem"
> newvalue(:gem)
> end
> newparam(:name) do
> desc "Name of gem"
> isnamevar
> end
> newparam(:version) do
> desc "Version of gem"
> end
> end
> 
> lib/puppet/provider/rvmgem/gem.rb
> 
> Puppet::Type.type(:rvmgem).provide(:gem) do
> desc "Provides RVM Gem support"
> commands :gemcmd => "su - rvmuser -c"
> def exists?
> if resource[:version].empty?
> gemcmd "'gem query -n #{resource[:gem]} -i'"
> else
> gemcmd "'gem query -n #{resource[:gem]} -v #{resource[:version]}
> -i'"
> end
> return true
> end
> def create
> if resource[:version].empty?
> gemcmd "'gem install #{resource[:gem]}'"
> else
> gemcmd "'gem install #{resource[:gem]} -v
> #{resource[:version]}'"
> end
> end
> def destroy
> gemcmd "'gem uninstall #{resource[:gem]}'"
> end
> end
> 
> --
> Greg
> 

You don't need to explicitly specify newproperty(:provider). There is a default 
provider parameter which is added when you create a provider for the type. That 
default parameter handles making the provider available via resource.provider 
(rather than the usual resource[:provider]), which is how the default ensure 
property interacts with it. So currently Puppet doesn't realize your type has a 
provider as Puppet understand providers. Other than that, your code looks fine. 
Remove the provider property, and it should work.
> 
> -- 
> 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] 
> (mailto:[email protected]).
> To unsubscribe from this group, send email to 
> [email protected] 
> (mailto:[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