hash of arrays to call a define

31 views
Skip to first unread message

backg...@gmail.com

unread,
Mar 24, 2014, 1:10:24 AM3/24/14
to puppet...@googlegroups.com
Given this hash of arrays:

$players = {
  'joe' => [
    '150',
    '200',
  ],
  'janet' =>
    '120',
    '240',
  ],
}

... and given a define that's like this:

profile::generate {$player:
  source => "puppet:///modules/$module_name/$player"
}

... how do you call profile::generater without hardcoding 2 defines?

  

Ellison Marks

unread,
Mar 24, 2014, 2:46:44 PM3/24/14
to puppet...@googlegroups.com
Normally, I'd say create_resources(), but that needs a hash of hashes, not a hash of arrays. Might I ask what the numbers represent, if they aren't present in the define?

jcbollinger

unread,
Mar 25, 2014, 1:35:15 PM3/25/14
to puppet...@googlegroups.com


It's not entirely clear what you're after.  I'm guessing you want to declare one defined type instance for each element of each (array) value of your $players hash, but I don't see how those elements are expected to be exposed to the profile::generator definition.

It is anyway likely that the answer involves another level of defined type, but the details depend on the nature of the data and what you are trying to do with it.  In particular, if you can rely on the numbers being globally unique then that could make things simpler.


John

Reply all
Reply to author
Forward
0 new messages