summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-03-12 03:07:31 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-03-12 03:07:31 +0000
commitf2c821803c7f6df2394990432c0a549ddb6ca73c (patch)
tree616dd3a2f408b1ba55f2d0ccd85faef5528c7c63
parentaed1f1181577b550c19589ab3e4840427cf31869 (diff)
downloadpuppet-f2c821803c7f6df2394990432c0a549ddb6ca73c.tar.gz
puppet-f2c821803c7f6df2394990432c0a549ddb6ca73c.tar.xz
puppet-f2c821803c7f6df2394990432c0a549ddb6ca73c.zip
Fixing #94. When "ensure" is synced, it syncs the "enable" state at the same time.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1014 980ebf18-57e1-0310-9a29-db15c13687c0
-rw-r--r--lib/puppet/type/service.rb7
-rwxr-xr-xlib/puppet/type/service/init.rb51
-rw-r--r--test/types/service.rb33
3 files changed, 40 insertions, 51 deletions
diff --git a/lib/puppet/type/service.rb b/lib/puppet/type/service.rb
index da9f07d35..1db138c0a 100644
--- a/lib/puppet/type/service.rb
+++ b/lib/puppet/type/service.rb
@@ -138,6 +138,13 @@ module Puppet
self.debug "Not running '%s' and shouldn't be running" %
self
end
+
+ if state = @parent.state(:enable)
+ state.retrieve
+ unless state.insync?
+ state.sync
+ end
+ end
end
end
diff --git a/lib/puppet/type/service/init.rb b/lib/puppet/type/service/init.rb
index f8d059031..61c2a2c48 100755
--- a/lib/puppet/type/service/init.rb
+++ b/lib/puppet/type/service/init.rb
@@ -12,43 +12,6 @@ Puppet.type(:service).newsvctype(:init) do
"/etc/init.d"
end
end
-# # Make sure we've got a search path set up. If they don't
-# # specify one, try to determine one.
-# def configchk
-# unless defined? @searchpaths
-# Puppet.notice "Initting search paths"
-# @searchpaths = []
-# end
-# unless @searchpaths.length > 0
-# if init = self.defaultinit
-# self.notice "Adding default init"
-# @searchpaths << init
-# else
-# self.notice "No default init for %s" %
-# Facter["operatingsystem"].value
-#
-# raise Puppet::Error.new(
-# "You must specify a valid search path for service %s" %
-# self.name
-# )
-# end
-# end
-# end
-#
-# # Get the default init path.
-# def defaultinit
-# unless defined? @defaultinit
-# case Facter["operatingsystem"].value
-# when "FreeBSD":
-# @defaultinit = "/etc/rc.d"
-# else
-# @defaultinit = "/etc/init.d"
-# @defaultrc = "/etc/rc%s.d"
-# end
-# end
-#
-# return @defaultinit
-# end
# Mark that our init script supports 'status' commands.
def hasstatus=(value)
@@ -89,20 +52,6 @@ Puppet.type(:service).newsvctype(:init) do
end
end
- # Enable a service, so it's started at boot time. This basically
- # just creates links in the RC directories, which means that, well,
- # we need to know where the rc directories are.
- # FIXME This should probably be a state or something, and
- # it should actually create use Symlink objects...
- # At this point, people should just link objects for enabling,
- # if they're running on a system that doesn't have a tool to
- # manage init script links.
- #def enable
- #end
-
- #def disable
- #end
-
def search(name)
self[:path].each { |path|
fqname = File.join(path,name)
diff --git a/test/types/service.rb b/test/types/service.rb
index a9fd69cfc..c53a4022a 100644
--- a/test/types/service.rb
+++ b/test/types/service.rb
@@ -264,6 +264,39 @@ class TestLocalService < Test::Unit::TestCase
Puppet.type(:component).clear
}
end
+
+ def test_serviceenableandrun
+ mktestsvcs.each do |svc|
+ startenable = nil
+ startensure = nil
+ svc[:check] = [:ensure, :enable]
+ svc.retrieve
+ assert_nothing_raised("Could not get status") {
+ startenable = svc.state(:enable).is
+ startensure = svc.state(:ensure).is
+ }
+
+ svc[:enable] = false
+ svc[:ensure] = :running
+ assert_apply(svc)
+
+ svc.retrieve
+ assert(svc.insync?, "Service did not sync both states")
+
+ svc[:enable] = true
+ svc[:ensure] = :running
+ assert_apply(svc)
+
+ svc.retrieve
+ assert(svc.insync?, "Service did not sync both states")
+
+ svc[:enable] = startenable
+ svc[:ensure] = startensure
+ assert_apply(svc)
+ Puppet.type(:service).clear
+ Puppet.type(:component).clear
+ end
+ end
end
end
end