Details
-
Bug
-
Status: Closed
-
Normal
-
Resolution: Fixed
-
PUP 5.5.0, PUP 6.2.0
-
Froyo
-
Platform Core KANBAN
-
Needs Assessment
-
Bug Fix
-
The `call()` function was only able to call functions in puppet core. This is now fixed so that any function in the environment is visible and can be called.
-
Needs Assessment
Description
Using custom functions, I'm unable to call them using the call() function.
Test case:
modules/call_me/functions/pfunction.pp
function call_me::pfunction( |
Optional[String] $args = undef |
) {
|
"returned from pfunction" |
}
|
test.pp;
$message = call_me::pfunction() |
notify {'direct function call': message => $message, } |
|
|
$deferred = Deferred('call_me::pfunction') |
$message3 = $deferred.call() |
notify {'deferred, function name hardcoded': message => $message3, } |
|
|
$function_name = 'call_me::pfunction' |
$deferred2 = Deferred($function_name) |
$message4 = $deferred2.call() |
notify {'deferred, function name in variable': message => $message4, } |
output:
Info: Using configured environment 'production'
|
Info: Retrieving pluginfacts
|
Info: Retrieving plugin
|
Info: Retrieving locales
|
Info: Caching catalog for cyberflox.irken.org
|
Info: Applying configuration version '1549449374'
|
Notice: returned from pfunction
|
Notice: /Stage[main]/Main/Node[default]/Notify[direct function call]/message: defined 'message' as 'returned from pfunction'
|
Notice: returned from pfunction
|
Notice: /Stage[main]/Main/Node[default]/Notify[deferred, function name hardcoded]/message: defined 'message' as 'returned from pfunction'
|
Notice: returned from pfunction
|
Notice: /Stage[main]/Main/Node[default]/Notify[deferred, function name in variable]/message: defined 'message' as 'returned from pfunction'
|
Notice: Applied catalog in 0.02 seconds
|
code that fails:
# THIS BLOCK FAILS
|
$message2 = call('call_me::pfunction')
|
notify{'call(call_me::pfunction)': message => $message2, }
|
output:
Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Function Call, Function call(): Unknown function: 'call_me::pfunction' (file: /etc/puppetlabs/code/environments/production/manifests/site.pp, line: 9, column: 15) on node cyberflox.irken.org
|
Warning: Not using cache on failed catalog
|
Error: Could not retrieve catalog; skipping run
|