Hello all,
let's assume the following structure in a yaml:
profiles:
vpn:
openvpn:
instances:
client:
myclient:
remote: 'openvpn_host 1194'
I would now like to check if e.g. "client" exists:
if ($profiles['vpn']['openvpn']['instances']['client'])
This works as long as the structure
profiles:
vpn:
openvpn:
instances:
exists and fails if not (because OpenVPN should not be available for
that client):
Error: Could not retrieve catalog from remote server: Error 500 on
SERVER: Server Error: Evaluation Error: Operator '[]' is not applicable
to an Undef Value. at
/etc/puppetlabs/code/modules/openvpn/manifests/init.pp:17:7 on node
my_client
Is there a way to check the existence of a hierarchy without creating
an empty hierarchy or doing something like
if is_hash($profiles) {
if has_key($profiles, 'vpn') {
if has_key($profiles['vpn'], 'openvpn') {
if has_key($profiles['vpn']['openvpn'], 'instances') {
...and so on
}
}
}
}
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/xn0lcc078szqyl1000%40news.gmane.org.
For more options, visit https://groups.google.com/d/optout.