jamtur01 / puppet

James Turnbull's Puppet remote

This URL has Read+Write access

puppet / lib / puppet / provider / service / redhat.rb
b2a3db94 » jamtur01 2008-04-24 Fixed #1196 - added /sbin/s... 1 # Manage Red Hat services. Start/stop uses /sbin/service and enable/disable uses chkconfig
2
12452ee9 » luke 2006-08-13 Merging r1468 from the impl... 3 Puppet::Type.type(:service).provide :redhat, :parent => :init do
6d5a1295 » jamtur01 2008-12-13 Documentation fixes 4 desc "Red Hat's (and probably many others) form of ``init``-style service management:
5
6 Uses ``chkconfig`` for service enabling and disabling.
7
8 "
12452ee9 » luke 2006-08-13 Merging r1468 from the impl... 9
b2a3db94 » jamtur01 2008-04-24 Fixed #1196 - added /sbin/s... 10 commands :chkconfig => "/sbin/chkconfig", :service => "/sbin/service"
11
2218611f » jamtur01 2009-02-12 Updated up2date and service... 12 defaultfor :operatingsystem => [:redhat, :fedora, :suse, :centos, :sles, :oel, :ovm]
12452ee9 » luke 2006-08-13 Merging r1468 from the impl... 13
8be0d33b » lutter 2006-12-14 Fix service.list, in partic... 14 def self.defpath
15 superclass.defpath
16 end
17
2dffbee3 » luke 2006-02-24 Adding redhat service type,... 18 # Remove the symlinks
19 def disable
fd8e0807 » luke 2006-06-13 Fixing #173. At this point... 20 begin
1d23013a » luke 2007-05-09 Fixing #605 -- providers no... 21 output = chkconfig(@resource[:name], :off)
fd8e0807 » luke 2006-06-13 Fixing #173. At this point... 22 rescue Puppet::ExecutionFailure
2dffbee3 » luke 2006-02-24 Adding redhat service type,... 23 raise Puppet::Error, "Could not disable %s: %s" %
24 [self.name, output]
25 end
26 end
27
28 def enabled?
fd8e0807 » luke 2006-06-13 Fixing #173. At this point... 29 begin
1d23013a » luke 2007-05-09 Fixing #605 -- providers no... 30 output = chkconfig(@resource[:name])
fd8e0807 » luke 2006-06-13 Fixing #173. At this point... 31 rescue Puppet::ExecutionFailure
2dffbee3 » luke 2006-02-24 Adding redhat service type,... 32 return :false
33 end
fd8e0807 » luke 2006-06-13 Fixing #173. At this point... 34
2cb2e030 » luke 2006-09-02 Applying patch from #251, a... 35 # If it's disabled on SuSE, then it will print output showing "off"
36 # at the end
37 if output =~ /.* off$/
38 return :false
39 end
40
fd8e0807 » luke 2006-06-13 Fixing #173. At this point... 41 return :true
2dffbee3 » luke 2006-02-24 Adding redhat service type,... 42 end
43
44 # Don't support them specifying runlevels; always use the runlevels
45 # in the init scripts.
46 def enable
fd8e0807 » luke 2006-06-13 Fixing #173. At this point... 47 begin
83ef1b0c » jamtur01 2008-05-15 Fix for #1219 48 output = chkconfig(@resource[:name], :on)
65298225 » luke 2006-12-28 I have not yet finished tes... 49 rescue Puppet::ExecutionFailure => detail
2dffbee3 » luke 2006-02-24 Adding redhat service type,... 50 raise Puppet::Error, "Could not enable %s: %s" %
65298225 » luke 2006-12-28 I have not yet finished tes... 51 [self.name, detail]
2dffbee3 » luke 2006-02-24 Adding redhat service type,... 52 end
53 end
b2a3db94 » jamtur01 2008-04-24 Fixed #1196 - added /sbin/s... 54
55 def restart
de6aec6e » jamtur01 2008-07-16 Fix Ticket 1426 - services ... 56 if @resource[:hasrestart] == :true
b2a3db94 » jamtur01 2008-04-24 Fixed #1196 - added /sbin/s... 57 service(@resource[:name], "restart")
58 else
de6aec6e » jamtur01 2008-07-16 Fix Ticket 1426 - services ... 59 super
60 end
61 end
62
63 def status
64 if @resource[:hasstatus] == :true
bfcd6263 » jamtur01 2008-07-21 Fixes #1445 and #1426 65 begin
66 service(@resource[:name], "status")
67 return :running
68 rescue
69 return :stopped
70 end
de6aec6e » jamtur01 2008-07-16 Fix Ticket 1426 - services ... 71 else
72 super
b2a3db94 » jamtur01 2008-04-24 Fixed #1196 - added /sbin/s... 73 end
74 end
75
67fc394d » jamtur01 2009-03-06 Fixed #2026 - Red Hat ignor... 76 def startcmd
77 [command(:service), @resource[:name], "start"]
b2a3db94 » jamtur01 2008-04-24 Fixed #1196 - added /sbin/s... 78 end
79
67fc394d » jamtur01 2009-03-06 Fixed #2026 - Red Hat ignor... 80 def stopcmd
81 [command(:service), @resource[:name], "stop"]
b2a3db94 » jamtur01 2008-04-24 Fixed #1196 - added /sbin/s... 82 end
83
2dffbee3 » luke 2006-02-24 Adding redhat service type,... 84 end
12452ee9 » luke 2006-08-13 Merging r1468 from the impl... 85