summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Turnbull <james@lovedthanlost.net>2008-06-17 19:37:23 +1000
committerJames Turnbull <james@lovedthanlost.net>2008-06-17 19:37:23 +1000
commit463aab8d55cd7d1ba9abd941e82cb2d4483d0e52 (patch)
tree78d3c0623734730f7d6c6badd86ea23f8b5d6885
parent0f501e327dc767bb09d92429693f51629782065a (diff)
parent2380fcd4d187e8592398015e96605ce4b5d63e7d (diff)
downloadpuppet-463aab8d55cd7d1ba9abd941e82cb2d4483d0e52.tar.gz
puppet-463aab8d55cd7d1ba9abd941e82cb2d4483d0e52.tar.xz
puppet-463aab8d55cd7d1ba9abd941e82cb2d4483d0e52.zip
Merge branch 'tickets/0.24.x/1012' of git://github.com/lak/puppet into 0.24.x
Conflicts: CHANGELOG
-rw-r--r--CHANGELOG4
-rw-r--r--lib/puppet/module.rb6
-rwxr-xr-xspec/unit/module.rb13
3 files changed, 19 insertions, 4 deletions
diff --git a/CHANGELOG b/CHANGELOG
index f34f59ced..bbf35de19 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -3,7 +3,9 @@
Fixed #1370 - removed test/util/loadedfile.rb tests
- Fixed #1221 - aliases to titles now work for resources.
+ Fixed #1221 - aliases to titles now work for resources.
+
+ Fixed #1012 - templates in the templatedir are preferred to module templates.
Fixed #1360 - allowdupe works on groups again.
diff --git a/lib/puppet/module.rb b/lib/puppet/module.rb
index b86931664..544d94ea9 100644
--- a/lib/puppet/module.rb
+++ b/lib/puppet/module.rb
@@ -63,6 +63,10 @@ class Puppet::Module
return template
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)
+
path, file = split_path(template)
# Because templates don't have an assumed template name, like manifests do,
@@ -76,7 +80,7 @@ class Puppet::Module
if mod
return mod.template(file)
else
- return File.join(Puppet.settings.value(:templatedir, environment), template)
+ return td_file # Return this anyway, since we're going to fail.
end
end
diff --git a/spec/unit/module.rb b/spec/unit/module.rb
index 06b2d016d..2dadaa501 100755
--- a/spec/unit/module.rb
+++ b/spec/unit/module.rb
@@ -80,6 +80,14 @@ describe Puppet::Module, " when searching for templates" do
File.stubs(:directory?).returns(true)
Puppet::Module.find_template("mymod/mytemplate").should == "/one/mymod/templates/mytemplate"
end
+
+ it "should return the file in the templatedir if it exists" do
+ Puppet.settings.expects(:value).with(:templatedir, nil).returns("/my/templates")
+ Puppet[:modulepath] = "/one:/two"
+ File.stubs(:directory?).returns(true)
+ File.stubs(:exists?).returns(true)
+ Puppet::Module.find_template("mymod/mytemplate").should == "/my/templates/mymod/mytemplate"
+ end
it "should use the main templatedir if no module is found" do
Puppet.settings.expects(:value).with(:templatedir, nil).returns("/my/templates")
@@ -100,9 +108,10 @@ describe Puppet::Module, " when searching for templates" do
end
it "should use the node environment if specified" do
- Puppet.settings.expects(:value).with(:modulepath, "myenv").returns("/my/templates")
+ Puppet.settings.stubs(:value).returns.returns("/my/directory")
+ Puppet.settings.expects(:value).with(:modulepath, "myenv").returns("/my/modules")
File.stubs(:directory?).returns(true)
- Puppet::Module.find_template("mymod/envtemplate", "myenv").should == "/my/templates/mymod/templates/envtemplate"
+ Puppet::Module.find_template("mymod/envtemplate", "myenv").should == "/my/modules/mymod/templates/envtemplate"
end
after { Puppet.settings.clear }