forked from choria-legacy/mcollective-service-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
puppetservice.rb
46 lines (40 loc) · 1.01 KB
/
puppetservice.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
module MCollective
module Util
module Service
class PuppetService<Base
def stop
if status == 'stopped'
msg = "Could not stop '%s': Service is already stopped" % @service
else
service_provider.stop
end
{:status => properties, :msg => msg}
end
def start
if status == 'running'
msg = "Could not start '%s': Service is already running" % @service
else
service_provider.start
end
{:status => properties, :msg => msg}
end
def restart
service_provider.restart
properties
end
def status
service_provider.status.to_s
end
private
def service_provider
require 'puppet'
@svc ||= Puppet::Type.type(:service).new({:name => @service}.merge(@options)).provider
end
def properties
sleep 0.5
status
end
end
end
end
end