Class: Chef::Provider::Service::Systemd
- Inherits:
-
Simple
show all
- Defined in:
- lib/chef/provider/service/systemd.rb
Instance Attribute Summary
#current_resource, #new_resource, #run_context
Instance Method Summary
collapse
Methods inherited from Simple
#ps_cmd
#action_disable, #action_enable, #action_reload, #action_restart, #action_start, #action_stop, #initialize
#chdir_or_tmpdir, #handle_command_failures, #not_if, #only_if, #output_of_command, #run_command, #run_command_with_systems_locale
#popen4
#popen4
#action_nothing, build_from_file, #cookbook_name, #initialize, #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
Instance Method Details
#disable_service ⇒ Object
91
92
93
|
# File 'lib/chef/provider/service/systemd.rb', line 91
def disable_service
run_command_with_systems_locale(:command => "/bin/systemctl disable #{@new_resource.service_name}")
end
|
#enable_service ⇒ Object
87
88
89
|
# File 'lib/chef/provider/service/systemd.rb', line 87
def enable_service
run_command_with_systems_locale(:command => "/bin/systemctl enable #{@new_resource.service_name}")
end
|
#is_active? ⇒ Boolean
95
96
97
|
# File 'lib/chef/provider/service/systemd.rb', line 95
def is_active?
run_command_with_systems_locale({:command => "/bin/systemctl is-active #{@new_resource.service_name}", :ignore_failure => true}) == 0
end
|
#is_enabled? ⇒ Boolean
99
100
101
|
# File 'lib/chef/provider/service/systemd.rb', line 99
def is_enabled?
run_command_with_systems_locale({:command => "/bin/systemctl is-enabled #{@new_resource.service_name}", :ignore_failure => true}) == 0
end
|
#load_current_resource ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/chef/provider/service/systemd.rb', line 24
def load_current_resource
@current_resource = Chef::Resource::Service.new(@new_resource.name)
@current_resource.service_name(@new_resource.service_name)
if @new_resource.status_command
Chef::Log.debug("#{@new_resource} you have specified a status command, running..")
begin
if run_command_with_systems_locale(:command => @new_resource.status_command) == 0
@current_resource.running(true)
end
rescue Chef::Exceptions::Exec
@current_resource.running(false)
nil
end
else
@current_resource.running(is_active?)
end
@current_resource.enabled(is_enabled?)
@current_resource
end
|
#reload_service ⇒ Object
79
80
81
82
83
84
85
|
# File 'lib/chef/provider/service/systemd.rb', line 79
def reload_service
if @new_resource.reload_command
super
else
run_command_with_systems_locale(:command => "/bin/systemctl reload #{@new_resource.service_name}")
end
end
|
#restart_service ⇒ Object
71
72
73
74
75
76
77
|
# File 'lib/chef/provider/service/systemd.rb', line 71
def restart_service
if @new_resource.restart_command
super
else
run_command_with_systems_locale(:command => "/bin/systemctl restart #{@new_resource.service_name}")
end
end
|
#start_service ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/chef/provider/service/systemd.rb', line 47
def start_service
if @current_resource.running
Chef::Log.debug("#{@new_resource} already running, not starting")
else
if @new_resource.start_command
super
else
run_command_with_systems_locale(:command => "/bin/systemctl start #{@new_resource.service_name}")
end
end
end
|
#stop_service ⇒ Object
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/chef/provider/service/systemd.rb', line 59
def stop_service
unless @current_resource.running
Chef::Log.debug("#{@new_resource} not running, not stopping")
else
if @new_resource.stop_command
super
else
run_command_with_systems_locale(:command => "/bin/systemctl stop #{@new_resource.service_name}")
end
end
end
|