summaryrefslogtreecommitdiff
path: root/lib/chef/provider/service.rb
diff options
context:
space:
mode:
authorAJ Christensen <aj@junglist.gen.nz>2008-09-24 19:58:52 +1200
committerAJ Christensen <aj@junglist.gen.nz>2008-10-01 09:34:27 +1300
commit58e06810b1e172192353d1d8218af5411280bfb7 (patch)
tree0a1c8534e707c86a5ee211f9e69c28a63314eeec /lib/chef/provider/service.rb
parenta43c47d226ca13fbd14114d14953b5ed95e894aa (diff)
downloadchef-58e06810b1e172192353d1d8218af5411280bfb7.tar.gz
All of my service resource work so far.
TODO: make it work
Diffstat (limited to 'lib/chef/provider/service.rb')
-rw-r--r--lib/chef/provider/service.rb48
1 files changed, 48 insertions, 0 deletions
diff --git a/lib/chef/provider/service.rb b/lib/chef/provider/service.rb
index 9d1d009b17..79041727eb 100644
--- a/lib/chef/provider/service.rb
+++ b/lib/chef/provider/service.rb
@@ -24,6 +24,54 @@ class Chef
include Chef::Mixin::Command
+ def initialize(node, new_resource)
+ super(node, new_resource)
+ @enabled = nil
+ end
+
+ def action_enable
+ do_service = false
+ if @current_resource.enabled == nil
+ do_service = true
+ elsif @new_resource.enabled != nil
+ if @new_resource.enabled != @current_resource.enabled
+ do_service = true
+ end
+ end
+
+ if do_package
+ status = enable_service(@new_resource.service_name)
+ if status
+ @new_resource.enabled = true
+ Chef::Log.info("Enabled service #{@new_resource} successfully")
+ end
+ end
+ end
+
+ def action_disable
+ if @current_resource.enabled == true
+ disable_service(@new_resource.service_name)
+ @new_resource.enabled = false
+ Chef::Log.info("Disabled service #{@new_resource} succesfully")
+ end
+ end
+
+ def action_start
+ if @current_resource.running == false
+ start_service(@new_resource.service_name)
+ @new_resource.running = true
+ Chef::Log.info("Started service #{@new_resource} succesfully")
+ end
+ end
+
+ def action_stop
+ if @current_resource.running == true
+ start_service(@new_resource.service_name)
+ @new_resource.running = false
+ Chef::Log.info("Stopped service #{@new_resource} succesfully")
+ end
+ end
+
end
end
end