How to convert array to comma separated string in Puppet 2.7

jaksky picture jaksky · Aug 30, 2013 · Viewed 15.5k times · Source

I am using Puppet 2.7 and I need to convert an array to comma separated list.

$hosts_fqdn= ['host1','host2','host3']

And I need to convert it to desired result: 'host1,host2,host3'

I guess that Puppet 3.2 offers lambda expression - reduce. But unfortunately that is not possible with 2.7.

Answer

jaksky picture jaksky · Aug 30, 2013

Function join from puppetlabs/stdlib:

join($hosts_fqdn,",")