From 75f4f224fbe305d36c223c2fb03e285a49c1d3a7 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Fri, 24 Jul 2015 18:30:24 +0100 Subject: [PATCH] Configure elasticsearch servers Make sure each server has a unique cluster name and is only listening on localhost. --- cookbooks/elasticsearch/recipes/default.rb | 10 ++++++++-- .../templates/default/elasticsearch.yml.erb | 4 ++++ roles/foundation.rb | 5 +++++ roles/logstash.rb | 5 +++++ roles/wiki.rb | 5 +++++ 5 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 cookbooks/elasticsearch/templates/default/elasticsearch.yml.erb diff --git a/cookbooks/elasticsearch/recipes/default.rb b/cookbooks/elasticsearch/recipes/default.rb index aaabe4c74..4c00b5e3c 100644 --- a/cookbooks/elasticsearch/recipes/default.rb +++ b/cookbooks/elasticsearch/recipes/default.rb @@ -18,8 +18,14 @@ # package "openjdk-7-jre-headless" -package "elasticsearch" do - action :install +package "elasticsearch" + +template "/etc/elasticsearch/elasticsearch.yml" do + source "elasticsearch.yml.erb" + user "root" + group "root" + mode 0644 + notifies :restart, "service[elasticsearch]" end service "elasticsearch" do diff --git a/cookbooks/elasticsearch/templates/default/elasticsearch.yml.erb b/cookbooks/elasticsearch/templates/default/elasticsearch.yml.erb new file mode 100644 index 000000000..9f5c95bc9 --- /dev/null +++ b/cookbooks/elasticsearch/templates/default/elasticsearch.yml.erb @@ -0,0 +1,4 @@ +# DO NOT EDIT - This file is being maintained by Chef + +cluster.name: <%= node[:elasticsearch][:cluster][:name] %> +network.host: 127.0.0.1 diff --git a/roles/foundation.rb b/roles/foundation.rb index 031611775..b19ebfc3c 100644 --- a/roles/foundation.rb +++ b/roles/foundation.rb @@ -10,6 +10,11 @@ default_attributes( :apt => { :sources => ["passenger"] }, + :elasticsearch => { + :cluster => { + :name => "foundation" + } + }, :memcached => { :memory_limit => 400, :chunk_growth_factor => 1.05, diff --git a/roles/logstash.rb b/roles/logstash.rb index dabe91379..0c3d9ce10 100644 --- a/roles/logstash.rb +++ b/roles/logstash.rb @@ -4,6 +4,11 @@ description "Role applied to all logstash servers" default_attributes( :apt => { :sources => ["logstash"] + }, + :elasticsearch => { + :cluster => { + :name => "logstash" + } } ) diff --git a/roles/wiki.rb b/roles/wiki.rb index 4357ee17a..cb533575f 100644 --- a/roles/wiki.rb +++ b/roles/wiki.rb @@ -7,6 +7,11 @@ default_attributes( :wiki => { :status => :role } } }, + :elasticsearch => { + :cluster => { + :name => "wiki" + } + }, :exim => { :trusted_users => ["www-data"], :aliases => { -- 2.39.5