diff options
author | Thom May <thom@joost.com> | 2008-09-16 10:24:18 +0100 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2008-09-20 19:34:38 +1000 |
commit | 09057346dd7207e36c81bae479d1343fb7cc8d0a (patch) | |
tree | 287a2f10ed57d6f956ac45ae7c8c77f9ff27b6b9 /lib/puppet/module.rb | |
parent | 11b0848b8c6eaaded608f4a485990ddb5bbd5e80 (diff) | |
download | puppet-09057346dd7207e36c81bae479d1343fb7cc8d0a.tar.gz puppet-09057346dd7207e36c81bae479d1343fb7cc8d0a.tar.xz puppet-09057346dd7207e36c81bae479d1343fb7cc8d0a.zip |
Allow a templatedir to be colon separated.
Signed-off-by: Thom May <thom@clearairturbulence.org>
Signed-off-by: Paul Nasrat <pnasrat@googlemail.com>
Diffstat (limited to 'lib/puppet/module.rb')
-rw-r--r-- | 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 544d94ea9..4bdfab092 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, |