Files

Class/Module Index [+]

Quicksearch

Chef::Provider::Service::Systemd

Public Instance Methods

define_resource_requirements() click to toggle source
# File lib/chef/provider/service/systemd.rb, line 50
def define_resource_requirements
  shared_resource_requirements
  requirements.assert(:all_actions) do |a|
    a.assertion { @status_check_success }
    # We won't stop in any case, but in whyrun warn and tell what we're doing.
    a.whyrun ["Failed to determine status of #{@new_resource}, using command #{@new_resource.status_command}.",
      "Assuming service would have been installed and is disabled"]
  end
end
disable_service() click to toggle source
# File lib/chef/provider/service/systemd.rb, line 104
def disable_service
  run_command_with_systems_locale(:command => "/bin/systemctl disable #{@new_resource.service_name}")
end
enable_service() click to toggle source
# File lib/chef/provider/service/systemd.rb, line 100
def enable_service
  run_command_with_systems_locale(:command => "/bin/systemctl enable #{@new_resource.service_name}")
end
is_active?() click to toggle source
# File lib/chef/provider/service/systemd.rb, line 108
def is_active?
  run_command_with_systems_locale({:command => "/bin/systemctl is-active #{@new_resource.service_name}", :ignore_failure => true}) == 0
end
is_enabled?() click to toggle source
# File lib/chef/provider/service/systemd.rb, line 112
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() click to toggle source
# 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)
  @status_check_success = true

  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
      @status_check_success = false
      @current_resource.running(false)
      @current_resource.enabled(false)
      nil
    end
  else
    @current_resource.running(is_active?)
  end

  @current_resource.enabled(is_enabled?)
  @current_resource
end
reload_service() click to toggle source
# File lib/chef/provider/service/systemd.rb, line 92
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() click to toggle source
# File lib/chef/provider/service/systemd.rb, line 84
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() click to toggle source
# File lib/chef/provider/service/systemd.rb, line 60
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() click to toggle source
# File lib/chef/provider/service/systemd.rb, line 72
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

[Validate]

Generated with the Darkfish Rdoc Generator 2.