lib/poise_service/solaris/provider.rb in poise-service-solaris-0.1.3 vs lib/poise_service/solaris/provider.rb in poise-service-solaris-0.1.5

- old
+ new

@@ -17,10 +17,12 @@ # @since 1.0.0 class SolarisService < Base include Chef::Mixin::ShellOut provides(:solaris_service) + # proritize this provider on solaris + Chef::Platform::ProviderPriorityMap.instance.priority(:poise_service, [self]) def self.provides_auto?(node, _) node['platform_family'] == 'solaris2' end @@ -40,41 +42,41 @@ def create_service Chef::Log.debug("Creating solaris service #{new_resource.service_name}") template manifest_file do source 'manifest.xml.erb' - cookbook 'poise-service-solaris' #poise needs cookbook name for template + cookbook 'poise-service-solaris' # poise needs cookbook name for template verify 'svccfg validate %{file}' variables( name: new_resource.service_name, command: new_resource.command, user: new_resource.user, environment: new_resource.environment, directory: new_resource.directory ) - notifies :run, 'execute[load service manifest]', :immediately end execute 'load service manifest' do - action :nothing # we synchrously disable and enable instead of # calling restart to avoid timing problem command 'svcadm disable -s manifest-import && svcadm enable -s manifest-import' + # svcs <service_name> returns 0 if service exists + not_if "svcs #{new_resource.service_name}" end end def destroy_service Chef::Log.debug("Destroying solaris service #{new_resource.service_name}") file manifest_file do action :delete - notifies :run, 'execute[load service manifest]', :immediately end execute 'load service manifest' do - action :nothing # we synchrously disable and enable instead of # calling restart to avoid timing problem command 'svcadm disable -s manifest-import && svcadm enable -s manifest-import' + # svcs <service_name> returns 0 if service exists + only_if "svcs #{new_resource.service_name}" end end def service_provider super.tap do |r|