Skip to content

Commit

Permalink
Allow the user to override the service actions
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
martinb3 committed Sep 15, 2015
1 parent 15598a5 commit 792f340
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 4 additions & 2 deletions libraries/provider_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions libraries/resource_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 792f340

Please sign in to comment.