Loop through hash in puppet define
As of Puppet version 3.3, the Puppet DSL language does not support iteration.
You should check out the create_resources()
function from Puppet Labs:
https://puppet.com/docs/puppet/latest/function.html#createresources
Example
# A hash of user resources:
$myusers = {
'nick' => { uid => '1330',
group => allstaff,
groups => ['developers', 'operations', 'release'], }
'dan' => { uid => '1308',
group => allstaff,
groups => ['developers', 'prosvc', 'release'], }
}
create_resources(user, $myusers)
However, as of Puppet 4.0, the Future Parser now supports iteration with Lambdas:
$data = ['a','b','c']
$data.each |Integer $index, String $value| {
notice("${index} = ${value}")
}