-
Notifications
You must be signed in to change notification settings - Fork 283
/
service.rb
39 lines (33 loc) · 1.03 KB
/
service.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
def sensu_path
"/opt/sensu"
end
def load_current_resource
@sensu_svc = run_context.resource_collection.lookup("service[#{new_resource.service}]") rescue nil
@sensu_svc ||= service new_resource.service do
supports :status => true, :restart => true
retries 3
retry_delay 5
action :nothing
subscribes :restart, resources("ruby_block[sensu_service_trigger]"), :delayed
end
end
action :enable do
@sensu_svc.run_action(:enable)
new_resource.updated_by_last_action(@sensu_svc.updated_by_last_action?)
end
action :disable do
@sensu_svc.run_action(:disable)
new_resource.updated_by_last_action(@sensu_svc.updated_by_last_action?)
end
action :start do
@sensu_svc.run_action(:start)
new_resource.updated_by_last_action(@sensu_svc.updated_by_last_action?)
end
action :stop do
@sensu_svc.run_action(:stop)
new_resource.updated_by_last_action(@sensu_svc.updated_by_last_action?)
end
action :restart do
@sensu_svc.run_action(:restart)
new_resource.updated_by_last_action(@sensu_svc.updated_by_last_action?)
end