Details
-
Bug
-
Status: Closed
-
Normal
-
Resolution: Fixed
-
PUP 4.10.0
-
Puppet Developer Experience
-
2
-
PDE 2017-05-03, PDE 2017-05-31
-
Bug Fix
-
It was not possible to call a function defined in the main manifest from logic in a module. This now works for those special occasions when it is actually needed, but the best practice is to autoload functions.
-
Manual
Description
Per https://docs.puppet.com/puppet/4.10/lang_write_functions_in_puppet.html it is possible to write Puppet-language functions in the main manifest (top-scope). The warning in the documentation indicates that the behavior, as with other top-scope items, would be to have the function accessible to all modules.
However, if you define a function in the main manifest and then try to call it from a module you will receive an error such as: "Error: Evaluation Error: Unknown function: 'testfunc'". It works fine when called from the main manifest. Calling it with the leading "::" indicating top-scope has no change in behavior.
The expected behavior is that top-scope Puppet language functions would work per the documentation and similarly to their Ruby counterparts.