Setting node.master and node.data in Chef recipe


(Stephen Goodall) #1

Hi,
Does anyone know if it is possible to set the node.master and node.data values in a recipe?
The resource configuration (https://github.com/elastic/cookbook-elasticsearch/blob/master/libraries/resource_configure.rb) says this:
# Refer to ES documentation on how to configure these to a
# specific node role/type instead of using the defaults
#
# 'node.data' => ?,
# 'node.master' => ?, # Refer to ES documentation on how to configure these to a
# specific node role/type instead of using the defaults
# # Refer to ES documentation on how to configure these to a
# specific node role/type instead of using the defaults
#
# 'node.data' => ?,
# 'node.master' => ?,
# 'node.data' => ?,
# 'node.master' => ?,

But I couldn't see anything in the docs about using chef to set these, I was hoping i could set it in the JSON attributes so I can pass a different value in depending on the node type I am starting up.

I made a new cookbook which uses the official cookbook and it runs this recipe:
#
# Cookbook Name:: elastic
# Recipe:: default
#
# Copyright (c) 2016 The Authors, All Rights Reserved.
elasticsearch_user 'elasticsearch'

elasticsearch_install 'elasticsearch' do
type :package
end

elasticsearch_configure 'elasticsearch' do
configuration ({
'cluster.name' => 'ES_CLUSTER'
})
end

elasticsearch_service 'elasticsearch' do
service_actions [:enable, :start]
end

elasticsearch_plugin 'cloud-aws' do
action :install
notifies :restart, 'elasticsearch_service[elasticsearch]', :delayed
end

elasticsearch_plugin 'elasticsearch-HQ' do
url 'royrusso/elasticsearch-HQ'
action :install
notifies :restart, 'elasticsearch_service[elasticsearch]', :delayed
end

elasticsearch_plugin 'elasticsearch-gui' do
url 'jettro/elasticsearch-gui'
action :install
notifies :restart, 'elasticsearch_service[elasticsearch]', :delayed
end

elasticsearch_plugin 'kopf' do
url 'lmenezes/elasticsearch-kopf'
action :install
notifies :restart, 'elasticsearch_service[elasticsearch]', :delayed
end

I'm guessing that I can't just specify a nodemaster and nodedata in the JSON and change the config part to this?

elasticsearch_configure 'elasticsearch' do
configuration ({
'cluster.name' => 'ES_CLUSTER'
'node.master' => node[:elasticsearch][:nodemaster]
'node.data' => node[:elasticsearch][:nodedata]
})
end

(Stephen Goodall) #2

I figured this out, in case it helps anyone else.....you can set the values in the recipe:

elasticsearch_configure 'elasticsearch' do configuration ({ 'node.master' => 'false', 'node.data' => 'false' }) end

Thanks to the elastic team for writing the cookbook, feels a lot easier to use than other "non-official" ones I've used in the past


(system) #3