Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
This should be asked on I have put in a request for it to be transferred there. – Caleb Apr 12 '11 at 14:28
@Caleb: Puppet is a programming language, but it's a very specific very limited programming language for system administration. It's totally on topic here, even if it is also on-topic on StackOverflow. – freiheit Apr 12 '11 at 15:06
What are you expecting to print? If you set the IPPriveeInstance variable to one address or the other, you'll only have... one address. Give us more information on what you're trying to accomplish (populating a config file? passing those in to a module?), and we'll be able to help. – Shane Madden Apr 12 '11 at 19:46
Hi im trying to test if files (named with IPPriveeInstance exist in client) so the need of an array as you see.Thanks – bazic Apr 13 '11 at 7:53

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:

share|improve this answer

You're trying to reference the full array at once when you want the individual parts of the arrays separately. Try this:

$IPPriveeInstance = "10.248.33.$IP[0]"
$IPPriveeInstance = "10.248.33.$IP[1]"

The first index in an array is always zero.

share|improve this answer
Sorry,but that doesn't seem to be working.Thanks anyway – bazic Apr 12 '11 at 16:11

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.