Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-9477

Unable to use call() on custom functions

    XMLWordPrintable

Details

    • 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
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            vStone Jan Vansteenkiste
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Zendesk Support