Puppet concatenate templates

In the module I'm currently working on, I got a load of configuration options that need to be set, have default values ... and should be fragmented into shorter template files as else it would be a scrolling nightmare.

The recommended way to do so was to use some third party modules. Is there no built in way?


Solution 1:

Another possible solution that surprisingly works (and about which I couldn't find any documentation), is the array syntax inside the template() function:

file { "${location}/final-file.php":
    ensure  => file,
    content => template(
        'wppuppet/template.a.erb',
        'wppuppet/template.b.erb',
        'wppuppet/template.c.erb'
    ),
}

Solution 2:

One possible solution is to fetch templates in variables. Then concatenate the string and push it into an inline_template():

$a = template( 'wppuppet/my-file.a.erb' )
$b = template( 'wppuppet/my-file.b.erb' )
$c = template( 'wppuppet/my-file.c.erb' )

file { "${location}/final-file.php":
    ensure  => file,
    content => inline_template( "${a}${b}${c}" ),
}