Satish
Satish

Reputation: 17397

puppet define array loop

I am playing with define array but not understand why its not working in following example. I am trying to create following directions

/tmp/foo.0
/tmp/foo.1
/tmp/foo.2

My init.pp

class loop {

define loop ( $x ) {

exec {"$name":
        command => "/bin/mkdir /tmp/$name.$x",
        creates => "/tmp/$name.$x",
        }
}
loop{ "foo": x => ["0", "1", "2"] }

}

Its creating directory like /tmp/tomcat7.012

Upvotes: 1

Views: 2016

Answers (1)

doc75
doc75

Reputation: 351

Not sure this is a good idea to name the define with same name than class.

It would work if you invert the $name and $x

class loop {

  define loop::loop ( $x ) {

    exec {"$x":
      command => "/bin/mkdir /tmp/$x.$name",
      creates => "/tmp/$x.$name",
    }
  }
  loop::loop{ ["0", "1", "2"]: x => "foo" }
}

Hope this helps

Upvotes: 4

Related Questions