Adding a parameter to a custom Puppet type/provider

332 views
Skip to first unread message

Gonzalo Servat

unread,
Nov 15, 2011, 12:48:19 AM11/15/11
to puppet...@googlegroups.com
Hi All,

I've downloaded a Puppet module and I'm trying to add a parameter to it by editing lib/puppet/type/<resource>.rb. I simply added:

    newproperty(:pcfree) do
        desc "My description here"
    end

In the corresponding file in lib/puppet/provider, I do something with :pcfree.

Whenever I call the resource from Puppet with my new parameter, it keeps saying "Invalid parameter pcfree".

Do I have to define the new parameter in any other file?

Thanks in advance.

- Gonzalo

Gonzalo Servat

unread,
Nov 15, 2011, 1:10:51 AM11/15/11
to puppet...@googlegroups.com
... and I just found this (http://docs.puppetlabs.com/guides/troubleshooting.html):

err: Could not retrieve catalog: Invalid parameter ‘foo’ for type ‘bar’

When you are developing new custom types, you should restart both the puppetmasterd and the puppetd before running the configuration using the new custom type. The pluginsync feature will then synchronise the files and the new code will be loaded when both daemons are restarted.



Restarted puppetmaster and it's now OK. Caused me many hours of grief!!

- Gonzalo

Jason Koppe

unread,
Dec 6, 2011, 1:22:09 PM12/6/11
to Puppet Users
restarting the puppet master didn't help me.

Jason Koppe

unread,
Dec 6, 2011, 1:34:47 PM12/6/11
to Puppet Users
http://pastie.org/private/t9nl5wa91bd6rx1afad7sq is a pastie of my
changes to https://github.com/puppetlabs/puppet-lvm and the error i'm
seeing is

err: Could not retrieve catalog from remote server: Error 400 on
SERVER: Invalid parameter physical_volume at file.pp:26 at node

Stefan Schulte

unread,
Dec 7, 2011, 7:01:20 AM12/7/11
to Puppet Users
On Tue, Dec 06, 2011 at 10:34:47AM -0800, Jason Koppe wrote:
> http://pastie.org/private/t9nl5wa91bd6rx1afad7sq is a pastie of my
> changes to https://github.com/puppetlabs/puppet-lvm and the error i'm
> seeing is
>
> err: Could not retrieve catalog from remote server: Error 400 on
> SERVER: Invalid parameter physical_volume at file.pp:26 at node
>

Parameter validation happens on your puppet master so I guess you have
to update

/var/lib/puppet/lib/puppet/type/logical_volume.rb

on your master first.

-Stefan

Jason Koppe

unread,
Feb 11, 2012, 10:31:36 AM2/11/12
to puppet...@googlegroups.com
I do have /var/lib/puppet/lib/puppet/type/logical_volume.rb on my puppet master and I still get the same error.
--
Jason Koppe
Jason.Rob...@gmail.com
Cell (210) 445-8242

Stefan Schulte

unread,
Feb 11, 2012, 11:21:19 AM2/11/12
to puppet...@googlegroups.com
Can you provide your resource definition where you use the
logical_volume type?

-Stefan

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

Jason Koppe

unread,
Feb 12, 2012, 4:06:46 PM2/12/12
to Puppet Users
Added to the pastie: http://pastie.org/private/em9dve6walcxyfjyssvya

On Feb 11, 10:21 am, Stefan Schulte <stefan.schu...@taunusstein.net>
wrote:
> Can you provide your resource definition where you use the
> logical_volume type?
>
> -Stefan
>
>
>
>
>
>
>
> On Sat, Feb 11, 2012 at 09:31:36AM -0600, Jason Koppe wrote:
> > I do have /var/lib/puppet/lib/puppet/type/logical_volume.rb on my puppet
> > master and I still get the same error.
>
> > On Wed, Dec 7, 2011 at 6:01 AM, Stefan Schulte <
> > stefan.schu...@taunusstein.net> wrote:
>
> > > On Tue, Dec 06, 2011 at 10:34:47AM -0800, Jason Koppe wrote:
> > > >http://pastie.org/private/t9nl5wa91bd6rx1afad7sqis a pastie of my
> > > > changes tohttps://github.com/puppetlabs/puppet-lvmand the error i'm
> > > > seeing is
>
> > > > err: Could not retrieve catalog from remote server: Error 400 on
> > > > SERVER: Invalid parameter physical_volume at file.pp:26 at node
>
> > > Parameter validation happens on your puppet master so I guess you have
> > > to update
>
> > >    /var/lib/puppet/lib/puppet/type/logical_volume.rb
>
> > > on your master first.
>
> > > -Stefan
>
> > --
> > Jason Koppe
> > Jason.Robert.Ko...@gmail.com

xkrantz

unread,
Aug 6, 2012, 3:42:28 PM8/6/12
to puppet...@googlegroups.com
Hi Jason,

Did you find a solution to your issue ?

Because I'm facing the same, and I would be very glad to have some feed back :)

Thanks in advance,
> > To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.

Josh Cooper

unread,
Aug 7, 2012, 12:32:38 AM8/7/12
to puppet...@googlegroups.com
Hi Stefan,

On Wed, Dec 7, 2011 at 4:01 AM, Stefan Schulte
<stefan....@taunusstein.net> wrote:
> Parameter validation happens on your puppet master so I guess you have
> to update
>
> /var/lib/puppet/lib/puppet/type/logical_volume.rb
>
> on your master first.

Recently Nick L and I "discovered" that parameter validation does not
occur on the master (in 2.7.x) yet many people believe this to be
true. Specifically the munge and validate methods for parameters and
properties are not called on the puppet master. However, the type &
provider code is loaded, so for example, requiring a windows gem at
the top level would prevent the master (not running windows) from
being able to compile catalogs.

Did puppet actually used to invoke the validate method on the master,
e.g. before 2.6? Or is that just how people thought/think it should
work?

Josh

--
Josh Cooper
Developer, Puppet Labs

jcbollinger

unread,
Aug 7, 2012, 9:44:04 AM8/7/12
to puppet...@googlegroups.com


On Monday, August 6, 2012 11:32:38 PM UTC-5, Josh Cooper wrote:
Recently Nick L and I "discovered" that parameter validation does not
occur on the master (in 2.7.x) yet many people believe this to be
true. Specifically the munge and validate methods for parameters and
properties are not called on the puppet master. However, the type &
provider code is loaded, so for example, requiring a windows gem at
the top level would prevent the master (not running windows) from
being able to compile catalogs.

Did puppet actually used to invoke the validate method on the master,
e.g. before 2.6? Or is that just how people thought/think it should
work?

In 0.24.8 there were Puppet parameters "typecheck" and "paramcheck" defined in defaults.rb, both initialized to true, and documented to control "Whether to validate types during parsing" and "Whether to validate parameters during parsing", respectively.  These do not appear to actually have been used in that version, however.  Without digging through the code, I'm not certain whether that means parse-time type and parameter checking were always on or always off.

To the extent that validation is a function of the type, as opposed to the selected provider, I would expect it to be performed by the master.  I can see some reasons why it might make sense for the agent to perform such type-level validations again, but not to excuse the master from doing them.

I find it surprising that the master loads providers.  On the other hand, it should be possible for Puppet (any face) to load any installed provider, including those that are not applicable to the host on which it is running.  I take this as part of Puppet's contract with providers, thus the responsibility of the provider author.  On the flip side, it is (should be) Puppet's responsibility to check provider applicability after loading, and to avoid using inapplicable providers for any purpose.


John

Reply all
Reply to author
Forward
0 new messages