[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 0.25.5-639-g8f94f35

test branch puppet-dev at googlegroups.com
Wed Jul 14 10:32:59 UTC 2010


The following commit has been merged in the upstream branch:
commit 5f72eb9820717df5e85f749ff647d35388f443d7
Author: Anselm Strauss <anselm at beastie.ttyv0.net>
Date:   Tue Feb 2 11:03:43 2010 +0100

    Re-included old BSD service provider, made new one default for FreeBSD

diff --git a/lib/puppet/provider/service/bsd.rb b/lib/puppet/provider/service/bsd.rb
new file mode 100644
index 0000000..fed6559
--- /dev/null
+++ b/lib/puppet/provider/service/bsd.rb
@@ -0,0 +1,54 @@
+# Manage FreeBSD services.
+Puppet::Type.type(:service).provide :bsd, :parent => :init do
+    desc "FreeBSD's (and probably NetBSD?) form of ``init``-style service management.
+
+    Uses ``rc.conf.d`` for service enabling and disabling.
+
+"
+
+    confine :operatingsystem => [:freebsd, :netbsd, :openbsd]
+
+    @@rcconf_dir = '/etc/rc.conf.d'
+
+    def self.defpath
+        superclass.defpath
+    end
+
+    # remove service file from rc.conf.d to disable it
+    def disable
+        rcfile = File.join(@@rcconf_dir, @model[:name])
+        if File.exists?(rcfile)
+            File.delete(rcfile)
+        end
+    end
+
+    # if the service file exists in rc.conf.d then it's already enabled
+    def enabled?
+        rcfile = File.join(@@rcconf_dir, @model[:name])
+        if File.exists?(rcfile)
+            return :true
+        end
+
+        return :false
+    end
+
+    # enable service by creating a service file under rc.conf.d with the
+    # proper contents
+    def enable
+        if not File.exists?(@@rcconf_dir)
+            Dir.mkdir(@@rcconf_dir)
+        end
+        rcfile = File.join(@@rcconf_dir, @model[:name])
+        open(rcfile, 'w') { |f| f << "%s_enable=\"YES\"\n" % @model[:name] }
+    end
+
+    # Override stop/start commands to use one<cmd>'s and the avoid race condition
+    # where provider trys to stop/start the service before it is enabled
+    def startcmd
+        [self.initscript, :onestart]
+    end
+
+    def stopcmd
+        [self.initscript, :onestop]
+    end
+end
diff --git a/lib/puppet/provider/service/freebsd.rb b/lib/puppet/provider/service/freebsd.rb
index e124b20..a98f8f8 100644
--- a/lib/puppet/provider/service/freebsd.rb
+++ b/lib/puppet/provider/service/freebsd.rb
@@ -1,8 +1,9 @@
-Puppet::Type.type(:service).provide :freebsd2, :parent => :init do
+Puppet::Type.type(:service).provide :freebsd, :parent => :init do
 
   desc "Provider for FreeBSD. Makes use of rcvar argument of init scripts and parses/edits rc files."
 
   confine :operatingsystem => [:freebsd]
+  defaultfor :operatingsystem => [:freebsd]
 
   @@rcconf = '/etc/rc.conf'
   @@rcconf_local = '/etc/rc.conf.local'

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list