[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, experimental, updated. debian/2.6.8-1-844-g7ec39d5

Nick Lewis nick at puppetlabs.com
Tue May 10 08:01:08 UTC 2011


The following commit has been merged in the experimental branch:
commit 2b772f761e151c3c2be41e1688e9af9a22d73dd0
Author: Nan Liu <nan at puppetlabs.com>
Date:   Thu Sep 16 23:13:31 2010 -0700

    (#3747) Implement upstart provider

diff --git a/lib/puppet/provider/service/upstart.rb b/lib/puppet/provider/service/upstart.rb
new file mode 100755
index 0000000..915de4c
--- /dev/null
+++ b/lib/puppet/provider/service/upstart.rb
@@ -0,0 +1,76 @@
+Puppet::Type.type(:service).provide :upstart, :parent => :init do
+  desc "Ubuntu service manager upstart.
+
+  This provider manages upstart jobs which have replaced initd.
+
+  See:
+   * http://upstart.ubuntu.com/
+  "
+  # Note: I did not set default for Ubuntu
+  # defaultfor :operatingsystem => :ubuntu
+
+  # confine to :ubuntu for now because I haven't tested on other platforms
+  confine :operatingsystem => :ubuntu #[:ubuntu, :fedora, :debian]
+
+  commands :start   => "/sbin/start",
+           :stop    => "/sbin/stop",
+           :restart => "/sbin/restart",
+           :status_exec  => "/sbin/status",
+           :initctl => "/sbin/initctl"
+
+  # upstart developer haven't implemented initctl enable/disable yet:
+  # http://www.linuxplanet.com/linuxplanet/tutorials/7033/2/
+  # has_feature :enableable
+
+  def self.instances
+    instances = []
+    execpipe("#{command(:initctl)} list") { |process|
+      process.each { |line|
+        # needs special handling of services such as network-interface:
+        # initctl list:
+        # network-interface (lo) start/running
+        # network-interface (eth0) start/running
+        # network-interface-security start/running
+        name = \
+          if matcher = line.match(/^(network-interface)\s\(([^\)]+)\)/)
+            "#{matcher[1]} INTERFACE=#{matcher[2]}"
+          else
+            line.split.first
+          end
+        instances << new(:name => name) #, :path => "/etc/init/#{name}.conf")
+      }
+    }
+    instances
+  end
+
+  def startcmd
+    [command(:start), @resource[:name]]
+  end
+
+  def stopcmd
+    [command(:stop), @resource[:name]]
+  end
+
+  def restartcmd
+    (@resource[:hasrestart] == :true) && [command(:restart), @resource[:name]]
+  end
+
+  def status
+    # allows user override of status command
+    if @resource[:status]
+      ucommand(:status, false)
+      if $?.exitstatus == 0
+        return :running
+      else
+        return :stopped
+      end
+    else
+      output = status_exec(@resource[:name].split)
+      if (! $?.nil?) && (output =~ /start\//)
+        return :running
+      else
+        return :stopped
+      end
+    end
+  end
+end

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list