Issue #22973 has been updated by Josh Cooper.

Keywords set to windows

----------------------------------------
Bug #22973: service does not implement custom start / stop commands on windows
https://projects.puppetlabs.com/issues/22973#change-101237

* Author: Kees van Vloten
* Status: Accepted
* Priority: Normal
* Assignee: 
* Category: service
* Target version: 
* Affected Puppet version: 2.7.22
* Keywords: windows
* Branch: 
----------------------------------------
The provider for service does not have support for explicit start and stop 
commands, however the documentation does not mention that limitation.

Example (taken from the mcollective module):
<pre><code>
  service { $mc_service_name:
    ensure    => running,
    enable    => true,
    hasstatus => true,
    start     => $mc_service_start,
    stop      => $mc_service_stop,
  }
</code></pre>
Windows will still run the default command, which is:

* C:\Windows\System32\net.exe $mc_service_name start
* C:\Windows\System32\net.exe $mc_service_name stop

In stead of the specified start and stop commands.


The fix could be a simple as this:
<pre><code>
--- lib\puppet\provider\service\windows-orig.rb 2013-06-17 17:23:16 +0200
+++ lib\puppet\provider\service\windows.rb      2013-10-25 11:57:42 +0200
@@ -73,13 +73,21 @@
       end
     end
 
-    net(:start, @resource[:name])
+    if @resource[:start]
+      system(@resource[:start])
+    else
+      net(:start, @resource[:name])
+       end
   rescue Puppet::ExecutionFailure => detail
     raise Puppet::Error.new("Cannot start #{@resource[:name]}, error was: 
#{detail}" )
   end
 
   def stop
-    net(:stop, @resource[:name])
+    if @resource[:stop]
+      system(@resource[:stop])
+    else
+      net(:stop, @resource[:name])
+       end
   rescue Puppet::ExecutionFailure => detail
     raise Puppet::Error.new("Cannot stop #{@resource[:name]}, error was: 
#{detail}" )
   end
</code></pre>


-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-bugs.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to