Last Updated: June 22, 2016
·
3.867K
· petems

Could not understand source - puppet error

Have you ever seen an error that looks like this?

Error: Parameter source failed on File[/etc/foo/bar.cnf]: Could not understand source # File managed by Puppet

And you spend ages trying to figure out what's wrong with your code:

file { '/etc/foo/bar.cnf':
  ensure  => present,
  owner   => 'root',
  group   => 'root',
  mode    => '0644',
  replace => true,
  source  => template('etc/foo/bar.cnf.erb'),
}

Your template looks fine, no illegal characters, it's compiling to ERB on the command-line when you try, You pull your hair for ages, and nothing seems to fix it? It's because you've done source instead of content for a template. The fix is simple:

file { '/etc/foo/bar.cnf':
  ensure  => present,
  owner   => 'root',
  group   => 'root',
  mode    => '0644',
  replace => true,
  content  => template('etc/foo/bar.cnf.erb'),
}

Just thought I'd made a tip for it, as I've seen a lot of google searches for similar errors, and it's such a simple issue to fix :)

5 Responses
Add your response

I love that this is first result on Google. I've been staring at this code for too long missing this simple mistake. Thanks!

over 1 year ago ·

<3

over 1 year ago ·

I owe you a beer. Thanks.

over 1 year ago ·

Thanks. Very useful tip :-)

over 1 year ago ·

This was really helpful :)

over 1 year ago ·