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.
8
9
10
11
|
# File 'lib/itamae/resource/service.rb', line 8
def initialize(*args)
super
@under = attributes.provider ? "_under_#{attributes.provider}" : ""
end
|
Instance Method Details
#action_disable(options) ⇒ Object
59
60
61
62
63
|
# File 'lib/itamae/resource/service.rb', line 59
def action_disable(options)
if current.enabled
run_specinfra(:"disable_service#{@under}", attributes.name)
end
end
|
#action_enable(options) ⇒ Object
53
54
55
56
57
|
# File 'lib/itamae/resource/service.rb', line 53
def action_enable(options)
unless current.enabled
run_specinfra(:"enable_service#{@under}", attributes.name)
end
end
|
#action_reload(options) ⇒ Object
47
48
49
50
51
|
# File 'lib/itamae/resource/service.rb', line 47
def action_reload(options)
if current.running
run_specinfra(:"reload_service#{@under}", attributes.name)
end
end
|
#action_restart(options) ⇒ Object
43
44
45
|
# File 'lib/itamae/resource/service.rb', line 43
def action_restart(options)
run_specinfra(:"restart_service#{@under}", attributes.name)
end
|
#action_start(options) ⇒ Object
31
32
33
34
35
|
# File 'lib/itamae/resource/service.rb', line 31
def action_start(options)
unless current.running
run_specinfra(:"start_service#{@under}", attributes.name)
end
end
|
#action_stop(options) ⇒ Object
37
38
39
40
41
|
# File 'lib/itamae/resource/service.rb', line 37
def action_stop(options)
if current.running
run_specinfra(:"stop_service#{@under}", attributes.name)
end
end
|
#pre_action ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/itamae/resource/service.rb', line 13
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
26
27
28
29
|
# File 'lib/itamae/resource/service.rb', line 26
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
|