Custom functions what way forward

27 views
Skip to first unread message

barry haycock

unread,
Mar 24, 2022, 6:29:20 AM3/24/22
to Puppet Users
I am migrating a Puppet 3.x to Puppet 7.x and am having to rewrite alot of the code.

This includes a number of custom modules and my first foray into writing custom functions/providers.
This is where I am getting stuck as there is not really a lot of information on this.
Looking at existing Puppet modules they all seem to have been written using
'Type.newtype' format,
where as the latest puppet docs state I should be using the 'resourceapi' gem/format.
looking over recent releases on the forge shows that everyone still appears to be using the old format.

What are the brains trust using and have you migrated over to resourceapi?

Would also like some better information on writing/testing custom functions other than
outdated books, URL's if anyone can point them my way.
I haven't had much luck finding anything recent and related.

Baz

Martin Alfke

unread,
Mar 24, 2022, 10:54:11 AM3/24/22
to puppet...@googlegroups.com
Hi Baz,

There are two APIs for custom types/providers within modern Puppet.

The “old” API uses the Puppet::Type.newtype syntax.
I gave a talk on this topic a couple of years ago:

The resourceapi is the “newer” API and uses Puppet::ResourceApi.register_type
It is integrated in PDK (pdk new provider)

Note: The new Resource API can not handle refreshonly as default implementation.
You must implement this behaviour by yourself.

Choose the solution which you are more comfortable with.

Best,
Martin

--
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/0feac523-d4a2-4d15-846c-d9304d0f8cfan%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages