Created
May 16, 2015 17:11
-
-
Save sonots/0b601f610b04d2c27cdd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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