Custom provider woes and questions

28 views
Skip to first unread message

Peter Berghold

unread,
Dec 7, 2015, 9:54:19 AM12/7/15
to puppet-users
This email has two parts:

First part

Looking at "Sh*t Gary Says" seems to imply I may be going about creating custom types/providers.  I am currently creating a type under lib/puppet/type/{typename}.rb without that logic doing anything with the actual logic being in lib/puppet/provider/{typename}/ruby.rb which has worked fine for me in the past.  

Someone confirm/deny.

Second part 

I've created a pair of custom types/providers, one to set parameters and the other to set state.   The issue I'm running into is the state provider is trying to work and the parameter provider doesn't even seem to be loading in Puppet at all without any sort of error showing up.

Here is how they are being invoked in a manifest:

myparmtype { 'instance':
    parm1=>'value1',
    parm2=>'value2'
-> 
mystatetype{'instance':
   state =>'mystate'

Sorry for the obfuscation, but what I'm working on is largely company proprietary. 

Thoughts anybody?   

Is there a limit to the number of types/providers a module can have?

Peter Berghold

unread,
Dec 7, 2015, 2:31:10 PM12/7/15
to puppet-users
Nevermind... figured out what was going on..   and fixed that problem and now a more bugs to squash...

How do I raise a failed exception in a provider (this before I start googleing) :-)    

Corey Osman

unread,
Dec 8, 2015, 12:00:08 PM12/8/15
to Puppet Users
I'll be releasing a type/provider generator that creates these files with basic code and unit tests in the next release of puppet-retrospec.  You can use right now if you want to compile the gem yourself. https://github.com/nwops/puppet-retrospec/tree/development

Types and providers are documented pretty good inside the source code, so if your editor allows you to click on Parent classes and such (Rubymine) its a little bit easier to see how things work and the Puppet Types and Providers book by Nan Liu and Dan Bode is well written and can help explain many things in a somewhat concise way. 


Corey

Gareth Rushgrove

unread,
Dec 13, 2015, 8:13:16 AM12/13/15
to puppet...@googlegroups.com
On 7 December 2015 at 19:30, Peter Berghold <salty....@gmail.com> wrote:
> Nevermind... figured out what was going on.. and fixed that problem and
> now a more bugs to squash...
>
> How do I raise a failed exception in a provider (this before I start
> googleing) :-)
>

You can use the fail method as seen here.

https://github.com/garethr/garethr-digitalocean/blob/master/lib/puppet/provider/droplet/v2.rb#L96

Gareth
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to puppet-users...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/CAArvnv20aBVzYQyU5ifFJQcuVQPEaCp63VntLMMXBBmP9%3D5SRw%40mail.gmail.com.
>
> For more options, visit https://groups.google.com/d/optout.



--
Gareth Rushgrove
@garethr

devopsweekly.com
morethanseven.net
garethrushgrove.com
Reply all
Reply to author
Forward
0 new messages