List of properties in provider

22 views
Skip to first unread message

Frederik Wagner

unread,
Sep 17, 2014, 9:26:32 AM9/17/14
to puppet...@googlegroups.com
Hi everyone,

currently I'm writing a custom provider to configure mailing lists.

In the provider I'm writing I need to access the list of all
properties (set or unset) defined in the type via 'newproperty'. I'm
wondering if there's a way to do that. It feels strange if there
wouldn't.

What I need to do:
Since upon initial creation of a mailing list not all properties can
be set, I need to put all defined properties into the @property_hash
to have them finally set by the flush method. Therefore I need code
like:

def exists?
... create mailing list...

all_properties_from_type.each { |prop|
@property_hash[prop] = @resource[prop] unless @resource[prop].nil?
}
end

Thanks for any help.

Bye
Frederik

Nan Liu

unread,
Sep 17, 2014, 12:44:25 PM9/17/14
to puppet...@googlegroups.com
I don't know what your type is called (replace mailing_list with your type name):

Puppet::Type.type(:mailing_list).properties.each { ... }

FYI, puppet-dev is probably the better mailing list for these questions since the puppet core dev monitor that and would know if the internal API have been updated recently.

Thanks,

Nan

Frederik Wagner

unread,
Sep 18, 2014, 2:43:37 AM9/18/14
to puppet...@googlegroups.com
Hi Nan,

thanks a lot. That works and gave me the right direction, in the end
one can use:
resource_type.validproperties (or self.class.resource_type.validproperties)

Next time I'll check out puppet-dev.

Bye
Frederik

P.S.: BTW nice introductory book ;-)
> --
> 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/CACqVBqA6SK1eyYCpRByzcuOEFeEWHxtDC2_QHbjG_mYHphkaVw%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages