From 792f340334a9efa9f4873cbedb855a056642d696 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Tue, 15 Sep 2015 14:40:55 -0500 Subject: [PATCH] Allow the user to override the service actions Allows the user to specify their own array of service actions, e.g. ```ruby elasticsearch_service 'elasticsearch' do service_actions [ :enable, :start ] end ``` Closes #357. --- libraries/provider_service.rb | 6 ++++-- libraries/resource_service.rb | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/libraries/provider_service.rb b/libraries/provider_service.rb index c2133ce2e..2d52a0277 100644 --- a/libraries/provider_service.rb +++ b/libraries/provider_service.rb @@ -69,8 +69,10 @@ class Provider::ElasticsearchService < Chef::Provider::LWRPBase supports :status => true, :restart => true action :nothing end - svc_r.run_action(:enable) - new_resource.updated_by_last_action(true) if svc_r.updated_by_last_action? + new_resource.service_actions.each do |act| + svc_r.run_action(act) + new_resource.updated_by_last_action(true) if svc_r.updated_by_last_action? + end end end end diff --git a/libraries/resource_service.rb b/libraries/resource_service.rb index 69e51438f..47965826d 100644 --- a/libraries/resource_service.rb +++ b/libraries/resource_service.rb @@ -22,5 +22,8 @@ class Resource::ElasticsearchService < Chef::Resource::LWRPBase # default user limits attribute(:memlock_limit, kind_of: String, default: 'unlimited') attribute(:nofile_limit, kind_of: String, default: '64000') + + # service actions + attribute(:service_actions, kind_of: [Symbol, Array], default: [ :enable ]) end end