Class: Itamae::Resource::Service
- Inherits:
-
Base
- Object
- Base
- Itamae::Resource::Service
show all
- Defined in:
- lib/itamae/resource/service.rb
Instance Attribute Summary
Attributes inherited from Base
#attributes, #current_attributes, #notifications, #recipe, #resource_name, #subscriptions, #updated
Instance Method Summary
collapse
Methods inherited from Base
#action_nothing, define_attribute, #do_not_run_because_of_not_if?, #do_not_run_because_of_only_if?, inherited, #resource_type, #run
Constructor Details
#initialize(*args) ⇒ Service
Returns a new instance of Service.
10
11
12
13
|
# File 'lib/itamae/resource/service.rb', line 10
def initialize(*args)
super
@under = attributes.provider ? "_under_#{attributes.provider}" : ""
end
|
Instance Method Details
#action_disable(options) ⇒ Object
61
62
63
64
65
|
# File 'lib/itamae/resource/service.rb', line 61
def action_disable(options)
if current.enabled
run_specinfra(:"disable_service#{@under}", attributes.name)
end
end
|
#action_enable(options) ⇒ Object
55
56
57
58
59
|
# File 'lib/itamae/resource/service.rb', line 55
def action_enable(options)
unless current.enabled
run_specinfra(:"enable_service#{@under}", attributes.name)
end
end
|
#action_reload(options) ⇒ Object
49
50
51
52
53
|
# File 'lib/itamae/resource/service.rb', line 49
def action_reload(options)
if current.running
run_specinfra(:"reload_service#{@under}", attributes.name)
end
end
|
#action_restart(options) ⇒ Object
45
46
47
|
# File 'lib/itamae/resource/service.rb', line 45
def action_restart(options)
run_specinfra(:"restart_service#{@under}", attributes.name)
end
|
#action_start(options) ⇒ Object
33
34
35
36
37
|
# File 'lib/itamae/resource/service.rb', line 33
def action_start(options)
unless current.running
run_specinfra(:"start_service#{@under}", attributes.name)
end
end
|
#action_stop(options) ⇒ Object
39
40
41
42
43
|
# File 'lib/itamae/resource/service.rb', line 39
def action_stop(options)
if current.running
run_specinfra(:"stop_service#{@under}", attributes.name)
end
end
|
#pre_action ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/itamae/resource/service.rb', line 15
def pre_action
case @current_action
when :start, :restart
attributes.running = true
when :stop
attributes.running = false
when :enable
attributes.enabled = true
when :disable
attributes.enabled = false
end
end
|
#set_current_attributes ⇒ Object
28
29
30
31
|
# File 'lib/itamae/resource/service.rb', line 28
def set_current_attributes
current.running = run_specinfra(:"check_service_is_running#{@under}", attributes.name)
current.enabled = run_specinfra(:"check_service_is_enabled#{@under}", attributes.name)
end
|