From 8539314a7a98b74916bd1c12426275f624bd040c Mon Sep 17 00:00:00 2001 From: Duncan Martin Walker Date: Thu, 28 May 2020 14:00:56 +0100 Subject: [PATCH] Prevent duplicate initial_master_nodes Elasticsearch fails to start on first run when duplicate entries in the cluster.initial_master_nodes variable are present, as they are all required during the initial bootstrapping. It is currently possible for duplicates to be present in this when nodes are forced to be master-eligible using elasticsearch_node_master: true due to the master node setting algorithm within data-node-variables. This commit ensures that all values within the Ansible master_nodes variable are unique, whilst keeping the total count of master nodes the same, preventing Elasticsearch from crashing during initial cluster discovery. Change-Id: I3763b22ea47c9b5b0f534793ccc6a887f96dc649 --- .../roles/elastic_data_hosts/vars/data-node-variables.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/elk_metrics_7x/roles/elastic_data_hosts/vars/data-node-variables.yml b/elk_metrics_7x/roles/elastic_data_hosts/vars/data-node-variables.yml index b8958476..cf10240b 100644 --- a/elk_metrics_7x/roles/elastic_data_hosts/vars/data-node-variables.yml +++ b/elk_metrics_7x/roles/elastic_data_hosts/vars/data-node-variables.yml @@ -64,19 +64,19 @@ master_nodes: |- {% set nodes = [] %} {% for node in groups['elastic'] %} {% if (nodes | length) <= (elastic_master_node_count | int) %} - {% if (hostvars[node]['elasticsearch_node_master'] is defined) and (hostvars[node]['elasticsearch_node_master'] | bool) %} + {% if (hostvars[node]['elasticsearch_node_master'] is defined) and (hostvars[node]['elasticsearch_node_master'] | bool) and (node not in nodes) %} {% set _ = nodes.append(node) %} {% endif %} {% endif %} {% endfor %} {% for node in groups['elastic'] %} {% if (nodes | length) <= (elastic_master_node_count | int) %} - {% if (node in _master_nodes) %} + {% if (node in _master_nodes) and (node not in nodes) %} {% set _ = nodes.append(node) %} {% endif %} {% endif %} {% endfor %} - {{ nodes }} + {{ nodes | unique }} master_node_count: "{{ master_nodes | length }}" coordination_nodes: |-