summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSeth Chisamore <schisamo@opscode.com>2012-11-13 16:50:12 -0500
committerSeth Chisamore <schisamo@opscode.com>2012-11-13 17:00:29 -0500
commit27ddd39c19e508a2cdf6ea0703a62a1e0ca8aa81 (patch)
tree6e8af70bb6d516a38d02bfca2331fef19676adde /lib
parenta7e7bca29aa7270e84e930fd2cdf173bc875413d (diff)
downloadchef-service-resource-improvements.tar.gz
[CHEF-3604] why run assertions should pass on custom service commandsservice-resource-improvements
Diffstat (limited to 'lib')
-rw-r--r--lib/chef/provider/service.rb4
-rw-r--r--lib/chef/provider/service/init.rb4
2 files changed, 7 insertions, 1 deletions
diff --git a/lib/chef/provider/service.rb b/lib/chef/provider/service.rb
index 27af1ac970..fbf269dbec 100644
--- a/lib/chef/provider/service.rb
+++ b/lib/chef/provider/service.rb
@@ -163,6 +163,10 @@ class Chef
end
end
+ def custom_command_for_action?(action)
+ !!@new_resource.send("#{action}_command".to_sym) rescue false
+ end
+
end
end
end
diff --git a/lib/chef/provider/service/init.rb b/lib/chef/provider/service/init.rb
index 2dd03679c5..09f47e866f 100644
--- a/lib/chef/provider/service/init.rb
+++ b/lib/chef/provider/service/init.rb
@@ -37,7 +37,9 @@ class Chef
# do not call super here, inherit only shared_requirements
shared_resource_requirements
requirements.assert(:start, :stop, :restart, :reload) do |a|
- a.assertion { ::File.exist?(default_init_command) }
+ a.assertion do
+ custom_command_for_action?(action) || ::File.exist?(default_init_command)
+ end
a.failure_message(Chef::Exceptions::Service, "#{default_init_command} does not exist!")
a.whyrun("Init script '#{default_init_command}' doesn't exist, assuming a prior action would have created it.") do
# blindly assume that the service exists but is stopped in why run mode: