Class: Chef::Provider::Service
- Inherits:
-
Chef::Provider
show all
- Includes:
- Mixin::Command
- Defined in:
- lib/chef/provider/service.rb,
lib/chef/provider/service/init.rb,
lib/chef/provider/service/debian.rb,
lib/chef/provider/service/redhat.rb,
lib/chef/provider/service/simple.rb,
lib/chef/provider/service/freebsd.rb,
lib/chef/provider/service/insserv.rb,
lib/chef/provider/service/solaris.rb,
lib/chef/provider/service/upstart.rb,
lib/chef/provider/service/invokercd.rb
Defined Under Namespace
Classes: Arch, Debian, Freebsd, Gentoo, Init, Insserv, Invokercd, Redhat, Simple, Solaris, Systemd, Upstart, Windows
Instance Attribute Summary
#current_resource, #new_resource, #run_context
Instance Method Summary
collapse
#chdir_or_tmpdir, #handle_command_failures, #output_of_command, #run_command, #run_command_with_systems_locale
#popen4
#popen4
#action_nothing, build_from_file, #cookbook_name, #load_current_resource, #node, #resource_collection
#convert_to_class_name, #convert_to_snake_case, #filename_to_qualified_string, #snake_case_basename
#method_missing
#data_bag, #data_bag_item, #platform?, #search, #value_for_platform
Constructor Details
#initialize(new_resource, run_context) ⇒ Service
Returns a new instance of Service.
28
29
30
31
|
# File 'lib/chef/provider/service.rb', line 28
def initialize(new_resource, run_context)
super
@enabled = nil
end
|
Instance Method Details
#action_disable ⇒ Object
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/chef/provider/service.rb', line 44
def action_disable
if @current_resource.enabled
if disable_service
@new_resource.updated_by_last_action(true)
Chef::Log.info("#{@new_resource} disabled")
end
else
Chef::Log.debug("#{@new_resource} already disabled - nothing to do")
end
end
|
#action_enable ⇒ Object
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/chef/provider/service.rb', line 33
def action_enable
if @current_resource.enabled
Chef::Log.debug("#{@new_resource} already enabled - nothing to do")
else
if enable_service
@new_resource.updated_by_last_action(true)
Chef::Log.info("#{@new_resource} enabled")
end
end
end
|
#action_reload ⇒ Object
84
85
86
87
88
89
90
91
92
93
94
|
# File 'lib/chef/provider/service.rb', line 84
def action_reload
unless (@new_resource.supports[:reload] || @new_resource.reload_command)
raise Chef::Exceptions::UnsupportedAction, "#{self.to_s} does not support :reload"
end
if @current_resource.running
if reload_service
@new_resource.updated_by_last_action(true)
Chef::Log.info("#{@new_resource} reloaded")
end
end
end
|
#action_restart ⇒ Object
77
78
79
80
81
82
|
# File 'lib/chef/provider/service.rb', line 77
def action_restart
if restart_service
@new_resource.updated_by_last_action(true)
Chef::Log.info("#{@new_resource} restarted")
end
end
|
#action_start ⇒ Object
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/chef/provider/service.rb', line 55
def action_start
unless @current_resource.running
if start_service
@new_resource.updated_by_last_action(true)
Chef::Log.info("#{@new_resource} started")
end
else
Chef::Log.debug("#{@new_resource} already running - nothing to do")
end
end
|
#action_stop ⇒ Object
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/chef/provider/service.rb', line 66
def action_stop
if @current_resource.running
if stop_service
@new_resource.updated_by_last_action(true)
Chef::Log.info("#{@new_resource} stopped")
end
else
Chef::Log.debug("#{@new_resource} already stopped - nothing to do")
end
end
|
#disable_service ⇒ Object
100
101
102
|
# File 'lib/chef/provider/service.rb', line 100
def disable_service
raise Chef::Exceptions::UnsupportedAction, "#{self.to_s} does not support :disable"
end
|
#enable_service ⇒ Object
96
97
98
|
# File 'lib/chef/provider/service.rb', line 96
def enable_service
raise Chef::Exceptions::UnsupportedAction, "#{self.to_s} does not support :enable"
end
|
#reload_service ⇒ Object
116
117
118
|
# File 'lib/chef/provider/service.rb', line 116
def reload_service
raise Chef::Exceptions::UnsupportedAction, "#{self.to_s} does not support :restart"
end
|
#restart_service ⇒ Object
112
113
114
|
# File 'lib/chef/provider/service.rb', line 112
def restart_service
raise Chef::Exceptions::UnsupportedAction, "#{self.to_s} does not support :restart"
end
|
#start_service ⇒ Object
104
105
106
|
# File 'lib/chef/provider/service.rb', line 104
def start_service
raise Chef::Exceptions::UnsupportedAction, "#{self.to_s} does not support :start"
end
|