Search code examples
rubypuppet

Can a custom Ruby function defined in one Puppet module be called from a .pp file in another module?


I have a custom function that I need to call (server-side) from at least two different puppet modules. The calls are to be made in Puppet DSL defined types, not Ruby-based custom types and providers.

I know that if I put the definition in a .rb file in the "lib\puppet\parser\functions" directory it is accessible in that module. Can that function be called from other modules, perhaps with some module qualifier before it? Or do I need to use some other approach? The function accepts two string arguments and returns a hash.

The little that I know about custom functions is found here:

https://docs.puppetlabs.com/guides/custom_functions.html

https://docs.puppetlabs.com/guides/plugins_in_modules.html

The following blog post seems to suggest that all functions from all modules are accessible from any module, but I may be misunderstanding it:

http://www.masterzen.fr/2011/10/29/puppet-extension-points-part-1/


Solution

  • If you have pluginsync enabled, puppet will make available all of your custom facts, types, functions, etc.

    In puppet.conf set pluginsync=true

    Reference

    Plugins in modules