Issue #4085 has been updated by Joel Heenan.
Apologies about the formatting, I screwed that up sorry.
Here is a patch implementing my proposed solution:
<pre>
*** puppet.orig/lib/puppet/parser/files.rb 2010-06-27 15:44:43.000000000
+1000
--- puppet/lib/puppet/parser/files.rb 2010-06-27 15:45:11.000000000 +1000
***************
*** 31,43 ****
return files
end
! # Find the concrete file denoted by +file+. If +file+ is absolute,
! # return it directly. Otherwise try to find it as a template in a
# module. If that fails, return it relative to the +templatedir+ config
# param.
# In all cases, an absolute path is returned, which does not
# necessarily refer to an existing file
def find_template(template, environment = nil)
if template == File.expand_path(template)
return template
end
--- 31,51 ----
return files
end
! # Find the concrete file denoted by +file+. If +file+ begins with
! # modules/, search modules first. If +file+ is absolute, return it
! # directly. Otherwise try to find it as a template in a
# module. If that fails, return it relative to the +templatedir+ config
# param.
# In all cases, an absolute path is returned, which does not
# necessarily refer to an existing file
def find_template(template, environment = nil)
+ if template =~ /^modules\//
+ template.slice!(/^modules\//)
+ if td_file = find_template_in_module(template, environment)
+ return td_file
+ end
+ end
+
if template == File.expand_path(template)
return template
end
</pre>
----------------------------------------
Bug #4085: template() function prefers global templates, no way to explicitly
say I want the module template
http://projects.puppetlabs.com/issues/4085
Author: Joel Heenan
Status: Unreviewed
Priority: Normal
Assigned to:
Category:
Target version:
Affected version: 0.25.5rc3
Keywords:
Branch:
given at site.pp:
<pre>
node "localhost" {
alert("localhost")
import "foo"
}
</pre>
and foo's init.pp:
<pre>
file { "/tmp/foo":
content => template("foo/foo.erb")
}
<pre>
If you have a template in the templatedir directory in a folder foo/foo.erb
that will be preferred over the modules template. And there is no way to say "I
want to explicitly use the modules template".
I propose that the template() function is extended to support syntax in the
form:
template("modules/foo/foo.erb")
so the template can be explicitly requested. I'm working on a patch for this
now.
I have verified this bug affects the latest github code.
--
You have received this notification because you have either subscribed to it,
or are involved in it.
To change your notification preferences, please click here:
http://projects.puppetlabs.com/my/account
--
You received this message because you are subscribed to the Google Groups
"Puppet Bugs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-bugs?hl=en.