diff options
author | Jesse Wolfe <jes5199@gmail.com> | 2010-01-08 17:35:51 -0800 |
---|---|---|
committer | Jesse Wolfe <jes5199@gmail.com> | 2010-01-08 22:10:39 -0800 |
commit | 0a7e212cb824a3a13bc00abf2e69aa3852c6c4d9 (patch) | |
tree | 5f853107d4560da13ec1782f7d6e4bc64206a766 /lib/puppet | |
parent | dd22b71161b0ab943bc3f6edbf6f104e1c882a14 (diff) | |
download | puppet-0a7e212cb824a3a13bc00abf2e69aa3852c6c4d9.tar.gz puppet-0a7e212cb824a3a13bc00abf2e69aa3852c6c4d9.tar.xz puppet-0a7e212cb824a3a13bc00abf2e69aa3852c6c4d9.zip |
Fix #2887 'service' tests paths too early
The 'service' type was testing to see if init script directories exist
too early, causing failures if you expected to be able to create those
directories via puppet.
This patch moves that logic into the 'init' provider.
Signed-off-by: Jesse Wolfe <jes5199@gmail.com>
Diffstat (limited to 'lib/puppet')
-rwxr-xr-x | lib/puppet/provider/service/init.rb | 20 | ||||
-rw-r--r-- | lib/puppet/type/service.rb | 15 |
2 files changed, 19 insertions, 16 deletions
diff --git a/lib/puppet/provider/service/init.rb b/lib/puppet/provider/service/init.rb index 965773d96..c05a32677 100755 --- a/lib/puppet/provider/service/init.rb +++ b/lib/puppet/provider/service/init.rb @@ -70,8 +70,23 @@ Puppet::Type.type(:service).provide :init, :parent => :base do @initscript ||= self.search(@resource[:name]) end + def paths + @paths ||= @resource[:path].find_all do |path| + if File.directory?(path) + true + else + if File.exist?(path) and ! File.directory?(path) + self.debug "Search path #{path} is not a directory" + else + self.debug "Search path #{path} does not exist" + end + false + end + end + end + def search(name) - @resource[:path].each { |path| + paths.each { |path| fqname = File.join(path,name) begin stat = File.stat(fqname) @@ -84,7 +99,8 @@ Puppet::Type.type(:service).provide :init, :parent => :base do # if we've gotten this far, we found a valid script return fqname } - @resource[:path].each { |path| + + paths.each { |path| fqname_sh = File.join(path,"#{name}.sh") begin stat = File.stat(fqname_sh) diff --git a/lib/puppet/type/service.rb b/lib/puppet/type/service.rb index 04fd9042c..d2ba82afd 100644 --- a/lib/puppet/type/service.rb +++ b/lib/puppet/type/service.rb @@ -115,20 +115,7 @@ module Puppet value = [value] unless value.is_a?(Array) # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] # It affects stand-alone blocks, too. - paths = value.flatten.collect { |p| x = p.split(":") }.flatten.find_all do |path| - if FileTest.directory?(path) - true - else - if FileTest.exist?(path) and ! FileTest.directory?(path) - @resource.debug "Search path %s is not a directory" % [path] - else - @resource.debug("Search path %s does not exist" % [path]) - end - false - end - end - - paths + paths = value.flatten.collect { |p| x = p.split(":") }.flatten end defaultto { provider.class.defpath if provider.class.respond_to?(:defpath) } |