[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. puppet-0.24.5-rc3-1456-g2f0b1e5

James Turnbull james at lovedthanlost.net
Tue Oct 27 17:05:01 UTC 2009


The following commit has been merged in the upstream branch:
commit d2d7070fb614840db56ca3672548bf5c58a3e4f0
Author: Brice Figureau <brice-puppet at daysofwonder.com>
Date:   Tue Sep 15 21:18:46 2009 +0200

    Fix #2640 - Daemontools and Runit were not creating the enable symlink
    
    Due to an incorrect tests, those providers weren't enabling themselves
    when starting, thus failing to create the symlink necessary for them
    to run.
    
    Signed-off-by: Brice Figureau <brice-puppet at daysofwonder.com>

diff --git a/lib/puppet/provider/service/daemontools.rb b/lib/puppet/provider/service/daemontools.rb
index f6eb509..2c6c6db 100644
--- a/lib/puppet/provider/service/daemontools.rb
+++ b/lib/puppet/provider/service/daemontools.rb
@@ -2,7 +2,7 @@
 #
 # author Brice Figureau <brice-puppet at daysofwonder.com>
 Puppet::Type.type(:service).provide :daemontools, :parent => :base do
-    desc """Daemontools service management.
+    desc "Daemontools service management.
 
     This provider manages daemons running supervised by D.J.Bernstein daemontools.
     It tries to detect the service directory, with by order of preference:
@@ -37,7 +37,7 @@ Puppet::Type.type(:service).provide :daemontools, :parent => :base do
     If a service has ensure => \"stopped\", it will only down the service, not
     remove the /path/to/service link.
 
-    """
+    "
 
     commands :svc  => "/usr/bin/svc", :svstat => "/usr/bin/svstat"
 
@@ -124,11 +124,6 @@ Puppet::Type.type(:service).provide :daemontools, :parent => :base do
         return :stopped
     end
 
-    def startcmd
-        self.enable if ! FileTest.symlink?(self.service)
-        [command(:svc), "-u", self.service ]
-    end
-
     def setupservice
         begin
             if resource[:manifest]
@@ -144,10 +139,12 @@ Puppet::Type.type(:service).provide :daemontools, :parent => :base do
 
     def enabled?
         case self.status
-        when :running:
+        when :running
+            # obviously if the daemon is running then it is enabled
             return :true
         else
-            return :false
+            # the service is enabled if it is linked
+            return FileTest.symlink?(self.service) ? :true : :false
         end
     end
 
@@ -191,7 +188,7 @@ Puppet::Type.type(:service).provide :daemontools, :parent => :base do
     end
 
     def start
-        enable unless enabled?
+        enable unless enabled? == :true
         svc "-u", self.service
     end
 
diff --git a/lib/puppet/provider/service/runit.rb b/lib/puppet/provider/service/runit.rb
index b2c8900..0182ec7 100644
--- a/lib/puppet/provider/service/runit.rb
+++ b/lib/puppet/provider/service/runit.rb
@@ -2,7 +2,7 @@
 #
 # author Brice Figureau <brice-puppet at daysofwonder.com>
 Puppet::Type.type(:service).provide :runit, :parent => :daemontools do
-    desc """Runit service management.
+    desc "Runit service management.
 
   This provider manages daemons running supervised by Runit.
   It tries to detect the service directory, with by order of preference:
@@ -31,7 +31,7 @@ Puppet::Type.type(:service).provide :runit, :parent => :daemontools do
    * status
 
 
-"""
+"
 
     commands :sv => "/usr/bin/sv"
 
@@ -93,7 +93,7 @@ Puppet::Type.type(:service).provide :runit, :parent => :daemontools do
 
     # relay to the startcmd
     def start
-        enable unless enabled?
+        enable unless enabled? == :true
         ucommand( :start )
     end
 
diff --git a/spec/unit/provider/service/daemontools.rb b/spec/unit/provider/service/daemontools.rb
index 4156afb..a2198bb 100755
--- a/spec/unit/provider/service/daemontools.rb
+++ b/spec/unit/provider/service/daemontools.rb
@@ -65,7 +65,7 @@ describe provider_class do
 
     describe "when starting" do
         it "should use 'svc' to start the service" do
-            @provider.stubs(:enabled?).returns true
+            @provider.stubs(:enabled?).returns :true
             @provider.expects(:svc).with("-u", "/etc/service/myservice")
 
             @provider.start
@@ -74,7 +74,7 @@ describe provider_class do
         it "should enable the service if it is not enabled" do
             @provider.stubs(:svc)
 
-            @provider.expects(:enabled?).returns false
+            @provider.expects(:enabled?).returns :false
             @provider.expects(:enable)
 
             @provider.start
@@ -124,6 +124,23 @@ describe provider_class do
         end
     end
 
+    describe "when checking if the service is enabled?" do
+        it "should return true if it is running" do
+            @provider.stubs(:status).returns(:running)
+
+            @provider.enabled?.should == :true
+        end
+
+        [true, false].each do |t|
+            it "should return #{t} if the symlink exists" do
+                @provider.stubs(:status).returns(:stopped)
+                FileTest.stubs(:symlink?).returns(t)
+
+                @provider.enabled?.should == "#{t}".to_sym
+            end
+        end
+    end
+
     describe "when checking status" do
         it "should call the external command 'svstat /etc/service/myservice'" do
             @provider.expects(:svstat).with(File.join(@servicedir,"myservice"))
diff --git a/spec/unit/provider/service/runit.rb b/spec/unit/provider/service/runit.rb
index 4a7a238..ad0ad67 100755
--- a/spec/unit/provider/service/runit.rb
+++ b/spec/unit/provider/service/runit.rb
@@ -64,13 +64,14 @@ describe provider_class do
             @provider.stubs(:sv)
             @provider.stubs(:ucommand)
 
-            @provider.expects(:enabled?).returns false
+            @provider.expects(:enabled?).returns :false
             @provider.expects(:enable)
 
             @provider.start
         end
 
         it "should execute external command 'sv start /etc/service/myservice'" do
+            @provider.stubs(:enabled?).returns :true
             @provider.expects(:ucommand).with(:start).returns("")
             @provider.start
         end

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list