R.I. Pienaar wrote:

> 
> > On 19 Jul 2018, at 21:19, Henrik Lindberg
> > <henrik.lindb...@puppet.com> wrote:
> > 
> >> On 2018-07-19 17:15, Helmut Schneider wrote:
> >> Hi,
> >> ---
> >> profiles:
> >>   vpn:
> >>     openvpn:
> >>       defaults:
> >>         client:
> >>           dev:               'tun'
> >>           proto:             'udp'
> >>           resolv-retry:      'infinite'
> >>           nobind:
> >>           user:              'nobody'
> >>           group:             'nogroup'
> >>           persist-key:
> >>           persist-tun:
> >>           ca:                '/etc/openvpn/ca-charlieroot.de.crt'
> >>           cert:
> '/etc/openvpn/mail.helmut-ritter.de.crt' >>           key:
> '/etc/openvpn/mail.helmut-ritter.de.key' >>           ns-cert-type:
> 'server' >>           # OpenVPN <= 2.3
> >>           comp-lzo:          'yes'
> >>           # OpenVPN > 2.3
> >>           # compress:          'lz4'
> >>           log-append:        '/var/log/openvpn.log'
> >>           verb:              '4'
> >>           script-security:   '2'
> >>           up:                '/etc/openvpn/update-resolv-conf'
> >> The eep is called by
> >> content => epp("openvpn/etc/openvpn/config.epp", { openvpnConf =>
> >> $openvpnConf, openvpnMode => $openvpnMode, instance => $instance
> }), >> The epp:
> >> <%- | Hash $openvpnConf, String $openvpnMode, String $instance |
> -%> >> <% ({
> >> 'Mode' => [
> >>         "$openvpnMode",
> >> ],
> >> 'Connection' => [
> >>         'remote',
> >>         'proto',
> >>         'dev',
> >>         'persist-tun',
> >>         'nobind',
> >>         'resolv-retry',
> >>         'compress',
> >>         'comp-lzo',
> >> ],
> >> 'Privileges' => [
> >>         'user',
> >>         'group',
> >>         'persist-key',
> >> ],
> >> 'Authentication' => [
> >>         'cert',
> >>         'key',
> >>         'ca',
> >>         'ns-cert-type',
> >> ],
> >> 'Logging' => [
> >>         'verb',
> >>         'log-append',
> >> ],
> >> 'Misc' => [
> >>         'script-security',
> >>         'plugin',
> >>         'up',
> >>         'down',
> >> ],
> >> }).each |$category, $parameters| { -%>
> >> ### <%= $category %> ###
> >> <%#= $openvpnConf %>
> >> <% $parameters.each |$parameter| { -%>
> >> <% if $parameter == 'remote' { -%>
> >> <%= $parameter %> <%= $openvpnConf['server'] %> <%=
> >> $openvpnConf['port'] %>
> >> <% } elsif $openvpnConf[$parameter] { -%>
> >> <%= $parameter %> <%= regsubst($openvpnConf[$parameter],
> >> '__INSTANCE__', $instance) %>
> >> <% } elsif defined($openvpnConf[$parameter]) { -%>
> >> <%= $parameter %>
> >> <% } -%>
> >> <% } %>
> >> <% } -%>
> >> The problem: compress does not exist in the hiera but is printed
> in the >> epp. How can I test if the key "compress" exists in the
> >> $openvpnConf-Hash?
> > 
> > You can simply check if the hash has an Undef value for that key.
> > 
> >  $openvpnConf['compress'] == undef

Did not work as I also want to print keys without values.

> Another option:
> 
> If “compress” in $openvpnConf { }

Works for me, 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 puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/xn0lcoc3m2d60t5001%40news.gmane.org.
For more options, visit https://groups.google.com/d/optout.

Reply via email to