From ca23f9a98723db2ba9afceb320a225f4ed8c1585 Mon Sep 17 00:00:00 2001 From: Kevin Carter Date: Thu, 2 Aug 2018 15:41:12 -0500 Subject: [PATCH] Update index retention policy to ensure its an int The current variable, when there's only one host will result in 'false' instead of 0, which is a jinja-ism however due to java-ism's "false" is evaluated to 5 and that makes the index retention policy very wrong. Change-Id: I2668e17c1cf15fe47842ff349ffa4f71c70257e5 Signed-off-by: Kevin Carter --- elk_metrics_6x/common_task_data_node_hosts.yml | 2 +- elk_metrics_6x/createElasticIndexes.yml | 2 +- elk_metrics_6x/templates/_include_setup_template.yml.j2 | 6 +++--- elk_metrics_6x/templates/curator-actions.yml.j2 | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/elk_metrics_6x/common_task_data_node_hosts.yml b/elk_metrics_6x/common_task_data_node_hosts.yml index 186453c7..98f87508 100644 --- a/elk_metrics_6x/common_task_data_node_hosts.yml +++ b/elk_metrics_6x/common_task_data_node_hosts.yml @@ -112,7 +112,7 @@ # ingest nodes. - name: Set data nodes set_fact: - elasticsearch_number_of_replicas: "{{ ((data_nodes | length) > 1) | ternary(((data_nodes | length) > 2 | ternary(2, 1)), 0) }}" + elasticsearch_number_of_replicas: "{{ ((data_nodes | length) > 2) | ternary('2', ((data_nodes | length) > 1) | ternary('1', '0')) }}" elasticsearch_data_hosts: |- {% set nodes = elasticsearch_data_node_details %} {% if inventory_hostname in data_nodes %} diff --git a/elk_metrics_6x/createElasticIndexes.yml b/elk_metrics_6x/createElasticIndexes.yml index bfe8f40b..b05f3ac8 100644 --- a/elk_metrics_6x/createElasticIndexes.yml +++ b/elk_metrics_6x/createElasticIndexes.yml @@ -44,4 +44,4 @@ indices.queries.cache.size: "5%" - name: "_all/_settings" index_options: - index.number_of_replicas: "{{ elasticsearch_number_of_replicas }}" + index.number_of_replicas: "{{ elasticsearch_number_of_replicas | int }}" diff --git a/elk_metrics_6x/templates/_include_setup_template.yml.j2 b/elk_metrics_6x/templates/_include_setup_template.yml.j2 index 93bd7e74..04611b1f 100644 --- a/elk_metrics_6x/templates/_include_setup_template.yml.j2 +++ b/elk_metrics_6x/templates/_include_setup_template.yml.j2 @@ -3,7 +3,7 @@ # These settings can be adjusted to load your own template or overwrite existing ones. # Set to false to disable template loading. -setup.template.enabled: false +setup.template.enabled: {{ inventory_hostname == data_nodes[0] }} # Template name. By default the template name is "{{ beat_name }}-%{[beat.version]}" # The template name and pattern has to be set in case the elasticsearch index pattern is modified. @@ -18,7 +18,7 @@ setup.template.pattern: "{{ beat_name }}-%{[beat.version]}-*" setup.template.fields: "${path.config}/fields.yml" # Overwrite existing template -setup.template.overwrite: false +setup.template.overwrite: {{ inventory_hostname == data_nodes[0] }} {% set shards = ((data_nodes | length) * 3) | int %} @@ -35,7 +35,7 @@ setup.template.settings: number_of_routing_shards: {{ (shards | int) * 2 }} # The default number of replicas will be based on the number of data nodes # within the environment with a limit of 2 replicas. - number_of_replicas: {{ elasticsearch_number_of_replicas }} + number_of_replicas: {{ elasticsearch_number_of_replicas | int }} # A dictionary of settings for the _source field. For more details, please check # https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-source-field.html diff --git a/elk_metrics_6x/templates/curator-actions.yml.j2 b/elk_metrics_6x/templates/curator-actions.yml.j2 index 2628bdd2..a3c9b229 100644 --- a/elk_metrics_6x/templates/curator-actions.yml.j2 +++ b/elk_metrics_6x/templates/curator-actions.yml.j2 @@ -68,7 +68,7 @@ "exclude_nodes": (groups['kibana'] | map('extract', hostvars, 'ansible_host') | list) }, "number_of_shards": 1, - "number_of_replicas": elasticsearch_number_of_replicas, + "number_of_replicas": (elasticsearch_number_of_replicas | int), "shrink_suffix": '-shrink', "copy_aliases": true, "delete_after": true,