Class: Chef::Provider::Service::Systemd
- Inherits:
-
Simple
- Object
- Chef::Provider
- Chef::Provider::Service
- Simple
- Chef::Provider::Service::Systemd
- Defined in:
- lib/chef/provider/service/systemd.rb
Constant Summary
Constants included from Mixin::ShellOut
Mixin::ShellOut::DEPRECATED_OPTIONS
Instance Attribute Summary
Attributes inherited from Chef::Provider
#current_resource, #new_resource, #run_context
Instance Method Summary collapse
- #disable_service ⇒ Object
- #enable_service ⇒ Object
- #is_active? ⇒ Boolean
- #is_enabled? ⇒ Boolean
- #load_current_resource ⇒ Object
- #reload_service ⇒ Object
- #restart_service ⇒ Object
- #start_service ⇒ Object
- #stop_service ⇒ Object
Methods included from Mixin::ShellOut
#run_command_compatible_options, #shell_out, #shell_out!
Methods inherited from Chef::Provider::Service
#action_disable, #action_enable, #action_reload, #action_restart, #action_start, #action_stop, #initialize
Methods included from Mixin::Command
#chdir_or_tmpdir, #handle_command_failures, #output_of_command, #run_command, #run_command_with_systems_locale
Methods included from Mixin::Command::Windows
Methods included from Mixin::Command::Unix
Methods inherited from Chef::Provider
#action_nothing, build_from_file, #cookbook_name, #initialize, #node, #resource_collection
Methods included from Mixin::ConvertToClassName
#convert_to_class_name, #convert_to_snake_case, #filename_to_qualified_string, #snake_case_basename
Methods included from Mixin::EnforceOwnershipAndPermissions
#enforce_ownership_and_permissions
Methods included from Mixin::RecipeDefinitionDSLCore
Methods included from Mixin::Language
#data_bag, #data_bag_item, #platform?, #platform_family?, #search, #value_for_platform, #value_for_platform_family
Constructor Details
This class inherits a constructor from Chef::Provider::Service
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Chef::Mixin::RecipeDefinitionDSLCore
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 |