r/Puppet • u/tek0011 • Sep 22 '15
How to chain stdlib functions?
Can this be chained in puppet 3.7.3 (without future parser)?
where $::somefact = ['rEd', 'red', 'orange']
(
$somevariable_downcase = downcase($::somefact),
$somevariable_unique = unique($somevariable_downcase),
$somevariable_join = join($somevariable_unique , ",")
)
expecting end result = red,orangeI am trying to do this all on one line. Is this possible?
Edit: quick answer in case google crawls this and someone searches, i know I wish I would have found an example..
$somevariable_join = join(unique(downcase($::somefact)), ",")
0
Upvotes
2
Sep 23 '15
Handy hint for testing, use:
puppet apply -e 'insert code here'So to test this you can do:
puppet apply -e '
$var = join(unique(downcase(["a", "B", "b", "c"])), ",")
notify { $var: }'
1
u/Fluxbob Sep 22 '15
I would say yes, without any testing of this. Did you tried it? What output did you get?