Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to create a file based on templates, but I'm getting an error that the template(s) cannot be found.

My directory setup is /etc/puppet/modules//templates/

Under templates, if have a directory for each host, plus a common template. Under the host directory I have a template specific to that host.


class {

file { "/tmp/<file>":
    ensure  => present,
    content => template('<module>/${hostname}/default.erb', '<module>/common.erb'),
    audit   => content,
    notify  => File["/tmp/<file2>"],

file { "/tmp/<file2>":
    ensure => present,
    source => "/tmp/file",
    audit   => content,


when I run the puppet agent, I get the error on the content option of the first file statement. I don't know if the template function needs the templates directly under the template directory or if it's not interpreting the hostname variable correctly.

share|improve this question
Please post the error you're getting. – EEAA Jul 31 '12 at 12:51
And if you can help it, use actual values rather than syntactically incorrect placeholders like <file> and <module>, because this distracts from the real issue. – larsks Jul 31 '12 at 12:56
If you run puppet in debug mode (-d), you'll get lots of diagnostic output and you'll probably be able to see if $hostname is expanding as you expect. – larsks Jul 31 '12 at 12:57
Variables aren't parsed inside single quotes. Use double quotes when you need to interpolate $variables. – czervik Jul 31 '12 at 15:36
Thanks czervik. The double quotes took care of the issue. Another example of "don't follow the documentation too closely". – Todd Strauch Aug 1 '12 at 10:17

Variables aren't parsed inside single quotes. Use double quotes when you need to interpolate $variables.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.