diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-06-13 22:55:14 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-06-13 22:55:14 +0000 |
commit | fd8e080768a3a4e048e8638b60c74afd9d798e98 (patch) | |
tree | 6ba731638110c0ee474b32ecbd153e4d60a9cff8 | |
parent | ef163ba0d0033635745220c7b2d1f209f4e1700e (diff) | |
download | puppet-fd8e080768a3a4e048e8638b60c74afd9d798e98.tar.gz puppet-fd8e080768a3a4e048e8638b60c74afd9d798e98.tar.xz puppet-fd8e080768a3a4e048e8638b60c74afd9d798e98.zip |
Fixing #173. At this point, I am just calling both "--add" and "on", or "--del" and "off". This should probably be broken up into other states, but....
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1265 980ebf18-57e1-0310-9a29-db15c13687c0
-rw-r--r-- | lib/puppet/type/service.rb | 3 | ||||
-rwxr-xr-x | lib/puppet/type/service/redhat.rb | 23 | ||||
-rw-r--r-- | lib/puppet/util.rb | 3 | ||||
-rw-r--r-- | test/types/service.rb | 4 |
4 files changed, 23 insertions, 10 deletions
diff --git a/lib/puppet/type/service.rb b/lib/puppet/type/service.rb index 14656d5d7..658027360 100644 --- a/lib/puppet/type/service.rb +++ b/lib/puppet/type/service.rb @@ -379,6 +379,9 @@ module Puppet mod.module_eval(&block) + # Extend the service type with the util stuff + mod.send(:include, Puppet::Util) + #unless mod.respond_to? :list # Puppet.debug "Service type %s has no list method" % name #end diff --git a/lib/puppet/type/service/redhat.rb b/lib/puppet/type/service/redhat.rb index 2674f5a21..24272cd0b 100755 --- a/lib/puppet/type/service/redhat.rb +++ b/lib/puppet/type/service/redhat.rb @@ -5,29 +5,32 @@ require 'puppet/type/service/init' Puppet.type(:service).newsvctype(:redhat, :init) do # Remove the symlinks def disable - output = %x{chkconfig #{self[:name]} off 2>&1} - - unless $? == 0 + begin + output = util_execute("/sbin/chkconfig #{self[:name]} off 2>&1") + output += util_execute("/sbin/chkconfig --del #{self[:name]} 2>&1") + rescue Puppet::ExecutionFailure raise Puppet::Error, "Could not disable %s: %s" % [self.name, output] end end def enabled? - output = %x{chkconfig #{self[:name]} 2>&1}.chomp - if $? == 0 - return :true - else + begin + output = util_execute("/sbin/chkconfig #{self[:name]} 2>&1").chomp + rescue Puppet::ExecutionFailure return :false end + + return :true end # Don't support them specifying runlevels; always use the runlevels # in the init scripts. def enable - output = %x{chkconfig #{self[:name]} on 2>&1} - - unless $? == 0 + begin + output = util_execute("/sbin/chkconfig --add #{self[:name]} 2>&1") + output += util_execute("/sbin/chkconfig #{self[:name]} on 2>&1") + rescue Puppet::ExecutionFailure raise Puppet::Error, "Could not enable %s: %s" % [self.name, output] end diff --git a/lib/puppet/util.rb b/lib/puppet/util.rb index 770bbc954..aa6b1657c 100644 --- a/lib/puppet/util.rb +++ b/lib/puppet/util.rb @@ -367,6 +367,9 @@ module Util return output end + # Because some modules provide their own version of this method. + alias util_execute execute + module_function :benchmark def memory diff --git a/test/types/service.rb b/test/types/service.rb index 720f38350..3a8ba089a 100644 --- a/test/types/service.rb +++ b/test/types/service.rb @@ -37,6 +37,8 @@ class TestInitService case Facter["operatingsystem"].value.downcase when "solaris": return ["smtp", "xf"] + when "redhat": + return ["sshd"] end end @@ -134,6 +136,8 @@ class TestLocalService < Test::Unit::TestCase return {"hddtemp" => {}} when "centos": return {"cups" => {:hasstatus => true}} + when "redhat": + return {"saslauthd" => {:hasstatus => true}} end Puppet.notice "No test services for %s-%s" % |