chef/cookbooks/elasticsearch/libraries/resource_service.rb
Greg Karékinian a32f34b408 Vendor the external cookbooks
Knife-Zero doesn't include Berkshelf support, so vendoring everything in
the repo is convenient again
2019-10-13 19:17:42 +02:00

29 lines
1.1 KiB
Ruby

# Chef Resource for declaring a service for Elasticsearch
class ElasticsearchCookbook::ServiceResource < Chef::Resource::LWRPBase
resource_name :elasticsearch_service
provides :elasticsearch_service
actions(
:configure, :remove, # our custom actions
:enable, :disable, :start, :stop, :restart, :status # passthrough to service resource
)
default_action :configure
# this is what helps the various resources find each other
attribute(:instance_name, kind_of: String, default: nil)
attribute(:service_name, kind_of: String, name_attribute: true)
attribute(:args, kind_of: String, default: '-d')
# service actions
attribute(:service_actions, kind_of: [Symbol, String, Array], default: [:enable, :start].freeze)
# allow overridable init script
attribute(:init_source, kind_of: String, default: 'initscript.erb')
attribute(:init_cookbook, kind_of: String, default: 'elasticsearch')
# allow overridable systemd unit
attribute(:systemd_source, kind_of: String, default: 'systemd_unit.erb')
attribute(:systemd_cookbook, kind_of: String, default: 'elasticsearch')
end