Am 10.01.2022 um 08:04 schrieb 'Dirk Heinrichs' via Puppet Users:
Am Sonntag, dem 09.01.2022 um 15:31 +0100 schrieb Helmut Schneider:
Unfortunately I'm not able to adapt it to my needs:
$array = []
[1, 2, 3].each |$variable| {
add $variable to $array
}
Any tips?
The first link you posted already has the answer. Puppet variables are
immutable so you can't create an empty array and then add vaules to it.
It must be done in one step and, as that answer says, you'll have to use
the map function, like
$array = [1, 2, 3].map |$var| { $var }
HTH...
I'm afraid I still do not unterstand this correctly:
profiles:
vpn:
openvpn:
syslogd:
40-openvpn.conf:
openvpn:
'*.*': '/var/log/openvpn.log'
$array = [1].map |$var| {
keys($profiles).each |$category| {
if $profiles[$category] =~ Hash {
keys($profiles[$category]).each |$app| {
"$app"
}
}
}
}
notify {"Array: $array":}
This returned "vpn" ($category) while I'd expect "openvpn" ($app).
--
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/srhcb3%2496n%241%40ciao.gmane.io.