I have to use a tool at work that makes use of Puppet 3.6 (I'm not interested in answers that suggest other versions, I'm stuck with what I'm given!). I am constrained by this tool to putting all my functionality into a single manifest. I can't find the syntax for Puppet 3 as to how to create custom functions, as the docs for Puppet 3 Functions just has a generic link that redirects to the v5.6 docs.
I have to parse some inputs at check for the presence of illegal chars.
define my_module::my_manifest($param1, $param2) {
# $param1 & $param2 are passed to this manifest by the tool I'm working with
function check_for_illegal_chars(String $check_string) {
$illegal_chars = "[&|;]"
if $check_string =~ $illegal_chars {
fail("Illegal char(s) detected in '${check_string}', cannot contain any of '${illegal_chars}'")
}
}
# sample usage
check_for_illegal_chars($param1)
# rest of my_manifest...
}
When I do this, however, I get an error:
Error: Could not parse for environment production: Syntax error at 'check_string'; expected ')' at /path/to/my_manifest.pp: 4
What is the correct syntax please?