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?

2 Answers 2


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(
  • Cool! How did you find it out? May 3, 2014 at 6:30
  • Assumption > Try > Error > Repeat and a lot of patience in between :) ... My IDE only supports PHP and JS :P
    – kaiser
    May 3, 2014 at 6:54
  • 1
    This is in the puppetlabs documentation: docs.puppetlabs.com/guides/templating.html#combining-templates
    – daxlerod
    May 3, 2014 at 15:49
  • @daxlerod then I overread that part :P Wonder why those modules then are so popular.
    – kaiser
    May 3, 2014 at 16:57
  • 1
    The modules typically offer some more flexibility, you may not know ahead of time where your fragments will come from. Also, take a look at how the mcollective::plugin type in the puppetlabs-mcollective module uses datacat to combine multiple directories. github.com/puppetlabs/puppetlabs-mcollective
    – daxlerod
    May 3, 2014 at 21:10

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}" ),

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .