Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

This might do it for you, I didn't test it so make you you play with it:

(your_array).each |Integer $index, String $value| {
file "/opt/key${index}": {
ensure => file
content => $value
}

Reference:
https://docs.puppet.com/puppet/latest/reference/lang_iteration.html#common-lambda-arguments

click to hide/show revision 2
No.2 Revision

This might do it for you, I didn't test it so make you you play with it:


(your_array).each $output.each |Integer $index, String $value| { 
{ file "/opt/key${index}": {
"/opt/key${index}.conf": ensure => file
file, content => $value
$value, } }

Reference:
https://docs.puppet.com/puppet/latest/reference/lang_iteration.html#common-lambda-arguments

click to hide/show revision 3
No.3 Revision

This If you're running Puppet 4, this might do it for you, I didn't test it so make you you play with it:

$output.each |Integer $index, String $value| {
    file { "/opt/key${index}.conf":
        ensure  => file,
        content => $value,
    }
}

Reference:
https://docs.puppet.com/puppet/latest/reference/lang_iteration.html#common-lambda-arguments