Skip to content

Instantly share code, notes, and snippets.

@sonots
Created May 16, 2015 17:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sonots/0b601f610b04d2c27cdd to your computer and use it in GitHub Desktop.
Save sonots/0b601f610b04d2c27cdd to your computer and use it in GitHub Desktop.
diff --git a/lib/itamae/resource/service.rb b/lib/itamae/resource/service.rb
index 367280b..bec2d2a 100644
--- a/lib/itamae/resource/service.rb
+++ b/lib/itamae/resource/service.rb
@@ -5,6 +5,7 @@ module Itamae
class Service < Base
define_attribute :action, default: :nothing
define_attribute :name, type: String, default_name: true
+ define_attribute :provider, type: String, default: 'init'
def pre_action
case @current_action
@@ -20,36 +21,36 @@ module Itamae
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)
+ current.running = run_specinfra(:"check_service_is_running_under_#{provider}", attributes.name)
+ current.enabled = run_specinfra(:"check_service_is_enabled_under_#{provider}", attributes.name)
end
def action_start(options)
unless current.running
- run_specinfra(:start_service, attributes.name)
+ run_specinfra(:"start_service_under_#{provider}", attributes.name)
end
end
def action_stop(options)
if current.running
- run_specinfra(:stop_service, attributes.name)
+ run_specinfra(:"stop_service_under_#{provider}", attributes.name)
end
end
def action_restart(options)
- run_specinfra(:restart_service, attributes.name)
+ run_specinfra(:"restart_service_under_#{provider}", attributes.name)
end
def action_reload(options)
- run_specinfra(:reload_service, attributes.name)
+ run_specinfra(:"reload_service_under_#{provider}", attributes.name)
end
def action_enable(options)
- run_specinfra(:enable_service, attributes.name)
+ run_specinfra(:"enable_service_under_#{provider}", attributes.name)
end
def action_disable(options)
- run_specinfra(:disable_service, attributes.name)
+ run_specinfra(:"disable_service_under_#{provider}", attributes.name)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment