Ask Your Question
0

how can I print the original source location of a template in a comment

asked 2015-04-17 11:07:52 -0500

psyber gravatar image

Is there an erb way to print the original source location of a template so I can tell where the template came from i.e.

#<%= magiclocation %>

yields

#foo/templates/bar.erb
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2015-04-17 15:13:10 -0500

JohnsonEarls gravatar image

This comes from looking at the puppet 3.7.4 source, so this is in no way a supported method and your mileage may vary:

/etc/puppet/modules/foo/manifests/init.pp:

class foo {
    file { '/tmp/foo':
        ensure => present ,
        template => "foo/bar.erb"
    }
}

/etc/puppet/modules/foo/templates/bar.erb:

<%= @__file__ %>

After puppet apply -e "include foo", /tmp/foo contains:

/etc/puppet/modules/foo/templates/bar.erb
edit flag offensive delete link more

Comments

works exactly as advertised!

psyber gravatar imagepsyber ( 2015-04-27 15:56:50 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2015-04-17 11:07:52 -0500

Seen: 336 times

Last updated: Apr 17 '15