From 9bc38476f46bcb73c19a618509ec9ba75aa10a78 Mon Sep 17 00:00:00 2001 From: Thomas Widhalm Date: Wed, 1 Feb 2023 17:06:05 +0100 Subject: [PATCH 1/2] Disable discovery on single node clusters fixes #8 --- roles/elasticsearch/templates/elasticsearch.yml.j2 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/roles/elasticsearch/templates/elasticsearch.yml.j2 b/roles/elasticsearch/templates/elasticsearch.yml.j2 index 6005f522..e424735e 100644 --- a/roles/elasticsearch/templates/elasticsearch.yml.j2 +++ b/roles/elasticsearch/templates/elasticsearch.yml.j2 @@ -2,12 +2,14 @@ node.name: "{{ ansible_hostname }}" path.data: {{ elasticsearch_datapath }} path.logs: /var/log/elasticsearch network.host: ["_local_","_site_"] +{% if elastic_release < 8 or groups['elasticsearch'] | length > 1 %} discovery.seed_hosts: [ {% for host in groups['elasticsearch'] %} "{{ hostvars[host].ansible_default_ipv4.address | default(hostvars[host].ansible_all_ipv4_addresses[0]) }}"{% if not loop.last %},{% endif %} {% endfor %} ] cluster.initial_master_nodes: [ {% for host in groups['elasticsearch'] %} "{{ hostvars[host].ansible_hostname }}"{% if not loop.last %},{% endif %} {% endfor %} ] +{% endif %} {% if elastic_temperature is defined %} node.attr.temp: "{{ elastic_temperature }}" {% endif %} From 8346addd97e478558708d682e1569ed94c15d93d Mon Sep 17 00:00:00 2001 From: Thomas Widhalm Date: Wed, 1 Feb 2023 17:59:50 +0100 Subject: [PATCH 2/2] Only remove discovery.seed_hosts --- roles/elasticsearch/templates/elasticsearch.yml.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/elasticsearch/templates/elasticsearch.yml.j2 b/roles/elasticsearch/templates/elasticsearch.yml.j2 index e424735e..dd55dee2 100644 --- a/roles/elasticsearch/templates/elasticsearch.yml.j2 +++ b/roles/elasticsearch/templates/elasticsearch.yml.j2 @@ -6,10 +6,10 @@ network.host: ["_local_","_site_"] discovery.seed_hosts: [ {% for host in groups['elasticsearch'] %} "{{ hostvars[host].ansible_default_ipv4.address | default(hostvars[host].ansible_all_ipv4_addresses[0]) }}"{% if not loop.last %},{% endif %} {% endfor %} ] +{% endif %} cluster.initial_master_nodes: [ {% for host in groups['elasticsearch'] %} "{{ hostvars[host].ansible_hostname }}"{% if not loop.last %},{% endif %} {% endfor %} ] -{% endif %} {% if elastic_temperature is defined %} node.attr.temp: "{{ elastic_temperature }}" {% endif %}