I have defined a puppet function check_value
in module test_one
test_one
|- functions
|- check_value.pp
and the function declaration:
test_one::check_value(String $check) >> String {
...
}
I declared a class test_functions
within the same module.
test_one
|- functions
|- check_value.pp
|- manifests
|- test_functions.pp
Everything seems to be perfect and I can call this function check_value
from the class test_functions
within the same module and could fetch the return value.
However, if I call this function from another module, I get Evaluation Error: Unknown function: ...
test_two
|- manifests
|- test_external_function.pp
In the class test_external_function
, I tried several ways to call check_value
but with no luck:
1. $x = test_one::check_value("t")
2. include test_one
$x = check_value("t")
3. include test_one
$x = test_one::check_value("t")
All trials have failed. Is it possible to call and use these puppet (non-ruby) functions from another module? I couldn't seem to find a way. Google is of no help so far!
As per the puppet documentation, it is possible: Puppet Functions
Functions are autoloaded and made available to other modules unless those modules specify dependencies. Once a function is written and available (in a module where the autoloader can find it), you can call that function in any Puppet manifest that lists the containing module as a dependency, and also from your main manifest.