From 2fb9400fe71726de0fd77a4c99b0986a567a394a Mon Sep 17 00:00:00 2001
From: "bernhard.fluehmann@realstuff.ch" <bernhard.fluehmann@realstuff.ch>
Date: Mon, 8 Feb 2021 21:44:01 +0100
Subject: [PATCH] node.roles in readme and added deprecation warning

---
 README.md                          | 35 +++++++++++++++++++++---------
 tasks/elasticsearch-parameters.yml | 13 +++++++++++
 2 files changed, 38 insertions(+), 10 deletions(-)

diff --git a/README.md b/README.md
index 48fbad48..39c71cfe 100644
--- a/README.md
+++ b/README.md
@@ -181,8 +181,11 @@ The following illustrates applying configuration parameters to an Elasticsearch
       discovery.seed_hosts: "localhost:9301"
       http.port: 9201
       transport.port: 9301
-      node.data: false
-      node.master: true
+      node.roles:
+        - master
+        - ingest
+        - ml
+        - remote_cluster_client
       bootstrap.memory_lock: true
     es_heap_size: 1g
     es_api_port: 9201
@@ -218,8 +221,11 @@ A more complex example:
       discovery.seed_hosts: "localhost:9301"
       http.port: 9201
       transport.port: 9301
-      node.data: false
-      node.master: true
+      node.roles:
+        - master
+        - ingest
+        - ml
+        - remote_cluster_client
       bootstrap.memory_lock: true
     es_heap_size: 1g
     es_start_service: false
@@ -254,8 +260,11 @@ An example of a three server deployment is shown below.  The first server holds
       cluster.initial_master_nodes: "elastic02"
       discovery.seed_hosts: "elastic02:9300"
       http.port: 9200
-      node.data: false
-      node.master: true
+      node.roles:
+        - master
+        - ingest
+        - ml
+        - remote_cluster_client
       bootstrap.memory_lock: false
     es_plugins:
      - plugin: ingest-attachment
@@ -271,8 +280,11 @@ An example of a three server deployment is shown below.  The first server holds
       cluster.initial_master_nodes: "elastic02"
       discovery.seed_hosts: "elastic02:9300"
       http.port: 9200
-      node.data: true
-      node.master: false
+      node.roles:
+        - data
+        - ingest
+        - ml
+        - remote_cluster_client
       bootstrap.memory_lock: false
     es_plugins:
       - plugin: ingest-attachment
@@ -285,8 +297,11 @@ An example of a three server deployment is shown below.  The first server holds
       cluster.name: "test-cluster"
       discovery.seed_hosts: "elastic02:9300"
       http.port: 9200
-      node.data: true
-      node.master: false
+      node.roles:
+        - data
+        - ingest
+        - ml
+        - remote_cluster_client
       bootstrap.memory_lock: false
     es_plugins:
       - plugin: ingest-attachment
diff --git a/tasks/elasticsearch-parameters.yml b/tasks/elasticsearch-parameters.yml
index c73d7ae8..0418b136 100644
--- a/tasks/elasticsearch-parameters.yml
+++ b/tasks/elasticsearch-parameters.yml
@@ -50,3 +50,16 @@
 
 - name: set fact use_system_d
   set_fact: use_system_d={{ (ansible_distribution == 'Debian' and ansible_distribution_version is version('8', '>=')) or (ansible_distribution in ['RedHat','CentOS'] and ansible_distribution_version is version('7', '>=')) or (ansible_distribution == 'Ubuntu' and ansible_distribution_version is version('15', '>=')) or (ansible_distribution == 'Amazon' and ansible_distribution_version is version('2', '>=')) }}
+
+- name: Warn about deprecated  node role settings
+  debug:
+    msg: "WARNING: You are using deprecated node role settings. Use node.roles instead"
+  when:
+  - es_version is version('7.9.0', '>=')
+  - ( es_config['node.master'] is defined or
+      es_config['node.voting_only'] is defined or
+      es_config['node.data'] is defined or
+      es_config['node.ingest'] is defined or
+      es_config['node.ml'] is defined or
+      es_config['node.transform'] is defined or
+      es_config['node.remote_cluster_client'] is defined )