From be108d20c66694778319f740ffc0d75b9d818af4 Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Mon, 14 Oct 2019 12:02:40 +0200 Subject: [PATCH] elasticsearch: Fix the configuration when version is >= 7. --- .../roles/ELK/elasticsearch/defaults/main.yml | 19 ++++++++++++------- .../roles/ELK/elasticsearch/tasks/plugins.yml | 4 +++- .../templates/elasticsearch.yml.j2 | 7 +++++++ 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/library/roles/ELK/elasticsearch/defaults/main.yml b/library/roles/ELK/elasticsearch/defaults/main.yml index 809f1281..79f7923e 100644 --- a/library/roles/ELK/elasticsearch/defaults/main.yml +++ b/library/roles/ELK/elasticsearch/defaults/main.yml @@ -1,10 +1,13 @@ --- elasticsearch_repo_key: https://packages.elastic.co/GPG-KEY-elasticsearch -elasticsearch_major_version: 2 elasticsearch_repo_version: '{{ elasticsearch_major_version }}.x' -elasticsearch_repo: 'deb http://packages.elastic.co/elasticsearch/{{ elasticsearch_repo_version }}/debian stable main' -#elasticsearch_major_version: 5 -#elasticsearch_repo: 'deb https://artifacts.elastic.co/packages/{{ elasticsearch_repo_version }}/apt stable main' +#elasticsearch_major_version: 2 +#elasticsearch_repo: 'deb http://packages.elastic.co/elasticsearch/{{ elasticsearch_repo_version }}/debian stable main' +elasticsearch_major_version: 5 +elasticsearch_minor_version: 4 +elasticsearch_patch_version: 0 +elasticsearch_version: '{{ elasticsearch_major_version }}.{{ elasticsearch_minor_version }}.{{ elasticsearch_patch_version }}' +elasticsearch_repo: 'deb https://artifacts.elastic.co/packages/{{ elasticsearch_repo_version }}/apt stable main' elasticsearch_packages: - elasticsearch @@ -18,6 +21,8 @@ elasticsearch_bind_ip: 0.0.0.0 elasticsearch_discovery_host_list: '["127.0.0.1", "[::1]"]' elasticsearch_define_majority_of_nodes: True elasticsearch_majority_of_nodes: 1 +elasticsearch_bootstrap_known_masters: + - '{{ ansible_fqdn }}' elasticsearch_real_cluster: False elasticsearch_recover_after_nodes: 3 elasticsearch_max_local_storage_nodes: 1 @@ -30,12 +35,12 @@ elasticsearch_max_open_files: 65536 elasticsearch_disable_bootstrap_syscall_filter: True # bin/plugin for 2.x, bin/elasticsearch-plugin for 5.x -#elasticsearch_plugin_bin: /usr/share/elasticsearch/bin/elasticsearch-plugin -elasticsearch_plugin_bin: /usr/share/elasticsearch/bin/plugin +#elasticsearch_plugin_bin: /usr/share/elasticsearch/bin/plugin #elasticsearch_plugins: # - { name: 'royrusso/elasticsearch-HQ', state: 'present' } +elasticsearch_plugin_bin: /usr/share/elasticsearch/bin/elasticsearch-plugin # elasticsearch 5 not supported yet, so set it to False when installing 5.x -elasticsearch_hq_install: True +elasticsearch_hq_install: False elasticsearch_hq_plugin: - { name: 'royrusso/elasticsearch-HQ', state: 'present' } diff --git a/library/roles/ELK/elasticsearch/tasks/plugins.yml b/library/roles/ELK/elasticsearch/tasks/plugins.yml index b274db5d..bfe64918 100644 --- a/library/roles/ELK/elasticsearch/tasks/plugins.yml +++ b/library/roles/ELK/elasticsearch/tasks/plugins.yml @@ -7,7 +7,9 @@ - name: Install the elasticsearch HQ plugin elasticsearch_plugin: name="{{ item.name }}" state={{ item.state }} plugin_bin={{ elasticsearch_plugin_bin }} url={{ item.url|default(omit) }} version={{ item.version|default(omit) }} with_items: '{{ elasticsearch_hq_plugin | default ([]) }}' - when: elasticsearch_hq_install + when: + - elasticsearch_major_version <= 2 + - elasticsearch_hq_install when: elasticsearch_plugins is defined tags: [ 'elasticsearch', 'es_plugins' ] diff --git a/library/roles/ELK/elasticsearch/templates/elasticsearch.yml.j2 b/library/roles/ELK/elasticsearch/templates/elasticsearch.yml.j2 index 4fe54c08..35444a54 100644 --- a/library/roles/ELK/elasticsearch/templates/elasticsearch.yml.j2 +++ b/library/roles/ELK/elasticsearch/templates/elasticsearch.yml.j2 @@ -21,6 +21,13 @@ cluster.name: {{ elasticsearch_cluster_name }} # Use a descriptive name for the node: # node.name: {{ ansible_fqdn }} + +{% if elasticsearch_major_version >= 7 %} +cluster.initial_master_nodes: +{% for n in elasticsearch_bootstrap_known_masters 5} + - {{ n }} +{% endfor %} +{% endif %} # # Add custom attributes to the node: #