[PATCH 1/1] Allow a templatedir to be colon separated.

0 views
Skip to first unread message

Thom May

unread,
Sep 3, 2008, 12:57:25 PM9/3/08
to puppe...@googlegroups.com

Signed-off-by: Thom May <th...@clearairturbulence.org>
---
lib/puppet/module.rb | 18 +++++++++++++++---
1 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/lib/puppet/module.rb b/lib/puppet/module.rb
index 544d94e..64f3f1a 100644
--- a/lib/puppet/module.rb
+++ b/lib/puppet/module.rb
@@ -19,6 +19,15 @@ class Puppet::Module
end
end

+ # Return an array of paths by splitting the +templatedir+ config
+ # parameter.
+ def self.templatepath(environment = nil)
+ dirs = Puppet.settings.value(:templatedir, environment).split(":")
+ dirs.select do |p|
+ p =~ /^#{File::SEPARATOR}/ && File::directory?(p)
+ end
+ end
+
# Find and return the +module+ that +path+ belongs to. If +path+ is
# absolute, or if there is no module whose name is the first component
# of +path+, return +nil+
@@ -64,9 +73,12 @@ class Puppet::Module
end

# If we can find the template in :templatedir, we return that.
- td_file = File.join(Puppet.settings.value(:templatedir, environment), template)
- return td_file if File.exists?(td_file)
-
+ td_file = templatepath(environment).collect { |path|
+ File::join(path, template)
+ }.find { |f| File.exists?(f) }
+
+ return td_file unless td_file == nil
+
path, file = split_path(template)

# Because templates don't have an assumed template name, like manifests do,
--
1.5.6.3

Thom May

unread,
Sep 3, 2008, 12:58:38 PM9/3/08
to puppe...@googlegroups.com
(this is for bug #1550)
Reply all
Reply to author
Forward
0 new messages