summaryrefslogtreecommitdiff
path: root/lib/chef/provider/execute.rb
diff options
context:
space:
mode:
authorPavel Valodzka <pavel@valodzka.name>2013-02-05 05:03:09 +0700
committerBryan McLellan <btm@opscode.com>2013-04-12 11:35:38 -0700
commit7bc64aacd0acbcde66077515d54c101ca8e61310 (patch)
tree7490bc0b2378beb818309d7a03f8c3f770d0ce80 /lib/chef/provider/execute.rb
parent084cec650a242c261c7987a45baa475cd67b8edf (diff)
downloadchef-7bc64aacd0acbcde66077515d54c101ca8e61310.tar.gz
execute check existense of sentiel file with respect to cwd
Diffstat (limited to 'lib/chef/provider/execute.rb')
-rw-r--r--lib/chef/provider/execute.rb27
1 files changed, 22 insertions, 5 deletions
diff --git a/lib/chef/provider/execute.rb b/lib/chef/provider/execute.rb
index d6b2f91bab..8d2a7d997d 100644
--- a/lib/chef/provider/execute.rb
+++ b/lib/chef/provider/execute.rb
@@ -37,11 +37,9 @@ class Chef
def action_run
opts = {}
- if sentinel_file = @new_resource.creates
- if ::File.exists?(sentinel_file)
- Chef::Log.debug("#{@new_resource} sentinel file #{sentinel_file} exists - nothing to do")
- return false
- end
+ if sentinel_file = sentinel_file_if_exists
+ Chef::Log.debug("#{@new_resource} sentinel file #{sentinel_file} exists - nothing to do")
+ return false
end
# original implementation did not specify a timeout, but ShellOut
@@ -63,6 +61,25 @@ class Chef
Chef::Log.info("#{@new_resource} ran successfully")
end
end
+
+ private
+
+ def sentinel_file_if_exists
+ if sentinel_file = @new_resource.creates
+ relative = Pathname(sentinel_file).relative?
+ cwd = @new_resource.cwd
+ if relative && !cwd
+ Chef::Log.warn "You have provided relative path for execute#creates (#{sentinel_file}) without execute#cwd (see CHEF-3819)"
+ end
+
+ if ::File.exists?(sentinel_file)
+ sentinel_file
+ elsif cwd && relative
+ sentinel_file = ::File.join(cwd, sentinel_file)
+ sentinel_file if ::File.exists?(sentinel_file)
+ end
+ end
+ end
end
end
end