Working with arrays in puppet

puppet

I have a variable $IP = [ "91" , "92" ]and $IPPriveeInstance = "10.248.33.$IP".

You guessed it, I want to use this variable 2 times,but when I print IPPriveeInstance, I got the output as 10.248.33.9192.

Best Answer

Puppet does not iterate array items. The example below demonstrates with inline_template, but you should use a custom function to perform this task.

$ip      = ['91', '92']
$address = '10.248.33.'
$array   = inline_template("<%= ip.collect{|x| address+x.to_s} %>")

You can also write this via the Ruby DSL: http://projects.puppetlabs.com/projects/1/wiki/Ruby_Dsl