Trying to construct a string.
I can do:
"Blah blah ${::osfamily} blah blah"
"Blah blah ${$::osfamily} blah blah"
But whats the syntax to call a function with a variable as parameter and have string interpolation work?
None of the following worked:
"Blah blah ${downcase($::osfamily)} blah blah"
"Blah blah ${downcase($osfamily)} blah blah"
"Blah blah ${downcase(::osfamily)} blah blah"
"Blah blah ${$downcase(osfamily)} blah blah"
"Blah blah ${$downcase($osfamily)} blah blah"
and so on.
All I get is:
Error 400 on SERVER: Syntax error at '('; expected ')'
Is that even possible in Puppet language?
Best Answer
It isn't possible. Puppet's language is a little ideosyncratic, in that many things you'd think would work just... don't. You'll need to assign the return value from the function to a variable, then interpolate that variable into the string, like this:
Of course, a string by itself isn't any use, so presumably you're assigning that string to a variable of its own, or using it as the value for a resource attribute.