Sha256: 097162a199289c2b9f102b62bb75eb86f3d962986cbb947f876a04a149699cc8

Contents?: true

Size: 1.3 KB

Versions: 36

Compression:

Stored size: 1.3 KB

Contents

require 'itamae'

module Itamae
  module Resource
    class Service < Base
      define_attribute :action, default: :nothing
      define_attribute :name, type: String, default_name: true

      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

      def set_current_attributes
        current.running = run_specinfra(:check_service_is_running, attributes.name)
        current.enabled = run_specinfra(:check_service_is_enabled, attributes.name)
      end

      def action_start(options)
        run_specinfra(:start_service, attributes.name)
      end

      def action_stop(options)
        run_specinfra(:stop_service, attributes.name)
      end

      def action_restart(options)
        run_specinfra(:restart_service, attributes.name)
      end

      def action_reload(options)
        run_specinfra(:reload_service, attributes.name)
      end

      def action_enable(options)
        run_specinfra(:enable_service, attributes.name)
      end

      def action_disable(options)
        run_specinfra(:disable_service, attributes.name)
      end
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
itamae-1.1.13 lib/itamae/resource/service.rb
itamae-1.1.12 lib/itamae/resource/service.rb
itamae-1.1.11 lib/itamae/resource/service.rb
itamae-1.1.10 lib/itamae/resource/service.rb
itamae-1.1.9 lib/itamae/resource/service.rb
itamae-1.1.8 lib/itamae/resource/service.rb
itamae-1.1.7 lib/itamae/resource/service.rb
itamae-1.1.5 lib/itamae/resource/service.rb
itamae-1.1.4 lib/itamae/resource/service.rb
itamae-1.1.3 lib/itamae/resource/service.rb
itamae-1.1.2 lib/itamae/resource/service.rb
itamae-1.1.1 lib/itamae/resource/service.rb
itamae-1.1.0 lib/itamae/resource/service.rb
itamae-1.0.13 lib/itamae/resource/service.rb
itamae-1.0.12 lib/itamae/resource/service.rb
itamae-1.0.11 lib/itamae/resource/service.rb
itamae-1.0.10 lib/itamae/resource/service.rb
itamae-1.0.9 lib/itamae/resource/service.rb
itamae-1.0.8 lib/itamae/resource/service.rb
itamae-1.0.7 lib/itamae/resource/service.rb