I have a puppet config that correctly installs a file. I want it to install several files. The config looks roughly like this (in the part that is relevant here):
$stuff = hiera('stuff')
$site_filename = $stuff['site_file']
file { "/path/to/my/file/called/$site_filename":
ensure => present,
owner => 'the-owner',
group => 'the-group',
mode => 644,
source => "puppet:///modules/this-module/$site_filename",
require => [Package['something'],
User['someone']]
}
file { "/path/to/my/symlink/called/$site_filename":
ensure => 'link',
target => "/path/to/my/file/called/$site_filename",
require => Package['something'],
}
Works great, the right file is installed on the right host. But I'd now like to install a variable number of (very similar) files, the number being different on each host.
My hiera files currently look like this:
stuff:
site_file: "hey-i-am-the-site-file-on-host-awesomeness"
In principle, I want to say something like this:
stuff:
site_file: ["hey-i-am-the-site-file-on-host-awesomeness",
"i-am-also-a-site-file-for-awesomeness",
"do-not-forget-me-too",
"someday-you-will-want-me-as-well"]
And here I am hitting the limits of my puppet and hiera knowledge. I understand that when I think I should iterate in puppet, I'm probably wrong, but I'm a bit confused how to do this.
Any pointers on how to do it or what to read about to learn?