Have you considered switching to an EPP template? You can limit the data passed in to only valid types (otherwise catalog compilation failure), it's quite useful.
https://puppet.com/docs/puppet/5.5/lang_template_epp.html In the example below, you might do something like: $content = epp('modulename/template.epp', { 'dev' => $openvpnConf['dev'], }) file { '/path/to/file': content => $content, } With your template: ---------- <% | String $dev, | -%> ### <%= $dev %> ### ---------- If $dev inside the template ends up as anything but a string, splat goes your catalog with a helpful error message. On Fri, Jul 13, 2018 at 02:37:08PM +0000, Helmut Schneider wrote: > Hi, > > openvpn.yaml: > [...] > profiles: > vpn: > openvpn: > defaults: > client: > dev: 'tun' > proto: 'udp' > resolv-retry: 'infinite' > nobind: > user: 'nobody' > group: 'nogroup' > persist-key: > persist-tun: > > init.pp: > [...] > $openvpnConf = $profiles['vpn']['openvpn']['defaults']['client'] > [...] > > In the template: > > ### <%= @openvpnConf['dev'] %> ### > ### <%= @openvpnConf['nobind'] %> ### > > The result is > > ### tun ### > ### undef ### > > but I would expect > > ### tun ### > ### ### > > The problem is that testing for defined?, .nil? and also != 'undef' all > fail. > > How can I test if a key has a value withn the template? > > Thank you! > > -- > 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/xn0lcerxlvsqnut003%40news.gmane.org. > For more options, visit https://groups.google.com/d/optout. -- 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/20180713150136.ohps2c6upmxyb5xq%40iniquitous.heresiarch.ca. For more options, visit https://groups.google.com/d/optout.
