Helmut, before digging yourself deeper into problems by using work
around on top of problems - do consider using EPP since it protects you
from the issues of needing to know how puppet represents things in Ruby;
which is complicated as puppet handles things differently in different
parts of the code base for backwards compatibility reasons.
Many of the functions in stdlib are smelly as they are sometimes quite
imprecise and not always correct. The "bool2str" however, does what it
is supposed to, but will error if not given a boolean true or false.
That is, it will error if given empty string, undef, or the ruby symbol
:undef. (Thus, in your case, you may get another surprise/error if you
try to use that function).
In puppet language (in EPP) you can do this:
$result = if $val { 'it is truthy' } else { 'it is falsey' }
To get the truthy string if value is neither false nor undef, and
otherwise the falsey value. (An empty string is truthy).
In EPP (as in the rest of puppet), if parameters are declared with
a data type then you will get automatic parameter checking
and get an error message that explains the difference (expected type
vs. actual data type of given value). In an ERB template you need to
do that all by yourself. As you have seen, not doing that can give you
problems somewhere deep in the middle of the template instead of much
closer to where the problem actually is.
So, best (as also suggested earlier by Christopher Wood), is to use EPP
and to declare the data types of the parameters the template expects.
If you also declare the data types of the class parameters in the class
where you are using the template you move the issue of argument value
correctness even closer to the source.
Hope this helps.
Best,