You cannot access local variables from outside a lambda using the each
function - its contract is to return the input to allow chaining. What
you are actually doing is reducing a collection of interfaces to a
single value - which you can do with the reduce() function. In this
particular case it seems much simpler as you are really asking if
there is any interface that has something that is true for 'ip6' - you
can therefore use the `any()` function.
Perhaps something like this:
if $netconfig['interfaces'].any() |$k, $v| { $v['ip6'] =~ NotUndef } {
# do something
}
No need for a variable or anything - if you do need one do this:
$myvariable = $netconfig['interfaces'].any() |$k, $v| {
$v['ip6'] =~ NotUndef
}
if $myvariable {
# do something
}
- henrik
--
Visit my Blog "Puppet on the Edge"
http://puppet-on-the-edge.blogspot.se/