I'm attempting to automate the usage of index templates in Elasticsearch, so I've started creating the files in the "[ES_CONFIG_DIR]/templates/" directory (http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html#config) with the proper format (sample file: http://pastebin.com/waKCBGgW). My Chef cookbook performs the following steps:
1.Create the JSON template file in the "[ES_CONFIG_DIR]/templates/tpl_misc.json" directory 2.Restart the elasticsearch service
The block of chef code to complete this is:
Related Attributes:
default['elasticsearch']['index_templates'] = [
"tpl_misc"
]
Relate Recipe Code:
directory "#{node['elasticsearch']['path']['conf']}/templates" do
owner 'elasticsearch'
group 'elasticsearch'
mode '0755'
action :create
end
node['elasticsearch']['index_templates'].each do |tpl|
template "#{node['elasticsearch']['path']['conf']}/templates/#{tpl}.json" do
source "#{tpl}.erb"
owner 'elasticsearch'
group 'elasticsearch'
mode '0644'
notifies :restart, 'service[elasticsearch]'
end
end
I can confirm the template files are being created where they should (in /usr/local/etc/elasticsearch/templates) although when I check to see exists in ES (curl -iL http://localhost:9200/_template/tpl_misc) and i always get a 404. Does anyone have any advice on what my issue might be?
I appreciate the help!