1
Puppet::Type.type(:service).provide :upstart, :parent => :init do
2
desc "Ubuntu service manager upstart.
4
This provider manages upstart jobs which have replaced initd.
7
* http://upstart.ubuntu.com/
9
# confine to :ubuntu for now because I haven't tested on other platforms
10
confine :operatingsystem => :ubuntu #[:ubuntu, :fedora, :debian]
12
commands :start => "/sbin/start",
13
:stop => "/sbin/stop",
14
:restart => "/sbin/restart",
15
:status_exec => "/sbin/status",
16
:initctl => "/sbin/initctl"
18
# upstart developer haven't implemented initctl enable/disable yet:
19
# http://www.linuxplanet.com/linuxplanet/tutorials/7033/2/
20
# has_feature :enableable
24
execpipe("#{command(:initctl)} list") { |process|
26
# needs special handling of services such as network-interface:
28
# network-interface (lo) start/running
29
# network-interface (eth0) start/running
30
# network-interface-security start/running
32
if matcher = line.match(/^(network-interface)\s\(([^\)]+)\)/)
33
"#{matcher[1]} INTERFACE=#{matcher[2]}"
37
instances << new(:name => name)
44
[command(:start), @resource[:name]]
48
[command(:stop), @resource[:name]]
52
(@resource[:hasrestart] == :true) && [command(:restart), @resource[:name]]
56
# allows user override of status command
58
ucommand(:status, false)
65
output = status_exec(@resource[:name].split)
66
if (! $?.nil?) && (output =~ /start\//)