diff options
author | Richard Manyanza <rm@dsc.co.tz> | 2014-10-21 20:33:11 +0300 |
---|---|---|
committer | Richard Manyanza <rm@dsc.co.tz> | 2014-10-21 20:33:11 +0300 |
commit | fefdbed5586c5021b0d7458e91b1e15cd5126385 (patch) | |
tree | 158509797cd13150df8d389415be7d29c6541a19 /lib | |
parent | c38f704f5fff50c5e5254add9593cbd83b06a8a2 (diff) | |
download | chef-fefdbed5586c5021b0d7458e91b1e15cd5126385.tar.gz |
Ensure why-run of a FreeBSD service missing init script does not fail
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/provider/service/freebsd.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/chef/provider/service/freebsd.rb b/lib/chef/provider/service/freebsd.rb index 08d58232e1..4cc8c5b8d9 100644 --- a/lib/chef/provider/service/freebsd.rb +++ b/lib/chef/provider/service/freebsd.rb @@ -58,6 +58,11 @@ class Chef requirements.assert(:start, :enable, :reload, :restart) do |a| a.assertion { init_command } a.failure_message Chef::Exceptions::Service, "#{new_resource}: unable to locate the rc.d script" + a.whyrun("Assuming rc.d script will be installed by a previous action.") do + # Assuming the missing rc.d script is for a user-installed rather than system + # service, fallback on the expected rc.d script path. + init_command = "/usr/local/etc/rc.d/#{new_resource.service_name}" + end end requirements.assert(:all_actions) do |a| @@ -131,6 +136,10 @@ class Chef # For example: to enable the service mysql-server with the init command /usr/local/etc/rc.d/mysql-server, you need # to set mysql_enable="YES" in /etc/rc.conf$ if init_command + if !::File.exists?(init_command) && whyrun_mode? + return new_resource.service_name + end + ::File.open(init_command) do |rcscript| rcscript.each_line do |line| if line =~ /^name="?(\w+)"?/ |