Henrik Lindberg wrote: > On 2018-07-14 13:47, Johan Fleury wrote: > > I meant bool2str, sorry. > > > > https://github.com/puppetlabs/puppetlabs-stdlib/blob/master/README.md#bool2str > > > > 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' }
I find the existing documentation in the net very confusing so I havent' used epp yet. E.g. according to https://puppet.com/docs/puppet/5.4/lang_template_epp.html this should work: content => epp("openvpn/etc/openvpn/config.epp", { openvpnConf => $openvpnConf, openvpnMode => $openvpnMode, instance => $instance }), <%- | Hash $openvpnConf, String $openvpnMode, String $category, String $parameters, String $instance | -%> <% ({ 'Misc' => [ 'script-security', 'plugin', 'up', 'down', ], }).each |$category, $parameters| { -%> <%= $category %> <% } -%> Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Function Call, epp(): Invalid EPP: Ambiguous EPP parameter expression. Probably missing '<%-' before parameters to remove leading whitespace at /etc/puppetlabs/code/modules/openvpn/templates/etc/openvpn/config.epp:6: 6 at /etc/puppetlabs/code/modules/openvpn/manifests/init.pp:28:22 on node h2786452.stratoserver.net The same documentation uses different sysntax, once without '$' $servers.each |server| and then with '$' $ntp::restrict.flatten.each |$restrict| What is correct? And what is wrong with the code above? Do I need to declare only variables that I pass to the epp or also those I create within the epp? -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/xn0lchjp4yls1g2008%40news.gmane.org. For more options, visit https://groups.google.com/d/optout.
