Puppet Function: invoke

Defined in:
lib/puppet/parser/functions/invoke.rb
Function type:
Ruby 3.x API

Overview

invoke()Any

Invoke macro as a statement.

This function ivokes a macro defined with ‘Puppet::Macros.newmacro` method. The function takes macro name as first argument and macro parameters as the rest of arguments. The number of arguments provided by user is validated against macro’s arity.

Example:

Let say, you have defined the following macro in puppet/macros/print.rb:

# puppet/macros/pring.rb
Puppet::Macros.newmacro 'print' do |msg|
  print msg
end

You may then invoke the macro from puppet as follows:

invoke('print',"hello world!\\n")

Returns:

  • (Any)


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/puppet/parser/functions/invoke.rb', line 5

newfunction(:invoke, :type => :statement, :doc => <<-EOT
Invoke macro as a statement.

This function ivokes a macro defined with `Puppet::Macros.newmacro`
method. The function takes macro name as first argument and macro parameters
as the rest of arguments. The number of arguments provided by user is
validated against macro's arity.

*Example*:

Let say, you have defined the following macro in
*puppet/macros/print.rb*:

    # puppet/macros/pring.rb
    Puppet::Macros.newmacro 'print' do |msg|
      print msg
    end

You may then invoke the macro from puppet as follows:

    invoke('print',"hello world!\\n")
EOT
) do |args|
  Puppet::Macros.call_macro_from_func(self,:invoke,args)
end