rjcdhg
Last Updated: June 22, 2016
·
2.808K
· petems
0b05e9bcbaaf6d39601a4e550819eecf

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 :)

Say Thanks
Respond

5 Responses
Add your response

15192
Pict0058 normal

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 ·
22643
None

<3

over 1 year ago ·
24641
None

I owe you a beer. Thanks.

over 1 year ago ·
25283
None

Thanks. Very useful tip :-)

over 1 year ago ·
27797

This was really helpful :)

over 1 year ago ·
Filed Under