From ad91d5773e6e186f1f45d2c01ee82b83fe58c4c0 Mon Sep 17 00:00:00 2001 From: Kevin Carter Date: Wed, 19 Dec 2018 10:32:28 -0600 Subject: [PATCH] Extend auto change detection This change makes it possible for a deployer to modify the set of indexes and weights assosiated with them. If modified, the local facts will be automatically updated. Change-Id: Iaea1f22d8aad2abdd02801dd9acad5f969b78d0e Signed-off-by: Kevin Carter --- elk_metrics_6x/createElasticIndexes.yml | 6 +++--- elk_metrics_6x/roles/elastic_retention/tasks/main.yml | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/elk_metrics_6x/createElasticIndexes.yml b/elk_metrics_6x/createElasticIndexes.yml index c06b4703..d9030587 100644 --- a/elk_metrics_6x/createElasticIndexes.yml +++ b/elk_metrics_6x/createElasticIndexes.yml @@ -16,7 +16,8 @@ become: true vars: - elastic_refresh_interval: "{{ (elasticsearch_number_of_replicas | int) * 5 }}" + _elastic_refresh_interval: "{{ (elasticsearch_number_of_replicas | int) * 5 }}" + elastic_refresh_interval: "{{ (_elastic_refresh_interval > 0) | ternary(30, _elastic_refresh_interval) }}" vars_files: - vars/variables.yml @@ -47,7 +48,7 @@ mapping: total_fields: limit: "10000" - refresh_interval: "5s" + refresh_interval: "{{ elastic_refresh_interval }}" - name: "_all/_settings?preserve_existing=true" index_options: index.queries.cache.enabled: "true" @@ -64,7 +65,6 @@ method: HEAD failed_when: false register: check_basicIndexTemplate - register: check_basicIndexTemplate until: check_basicIndexTemplate is success retries: 3 delay: 30 diff --git a/elk_metrics_6x/roles/elastic_retention/tasks/main.yml b/elk_metrics_6x/roles/elastic_retention/tasks/main.yml index 9e096773..e80e8db3 100644 --- a/elk_metrics_6x/roles/elastic_retention/tasks/main.yml +++ b/elk_metrics_6x/roles/elastic_retention/tasks/main.yml @@ -67,12 +67,12 @@ option: "cluster_nodes" value: "{{ groups['elastic-logstash'] | length }}" - - name: Set retention policy fact + - name: Set retention policy keys fact ini_file: dest: "/etc/ansible/facts.d/elastic.fact" section: "retention" option: "elastic_beat_retention_policy_keys" - value: "{{ elastic_beat_retention_policy_hosts.keys() | list }}" + value: "{{ elastic_beat_retention_policy_hosts.keys() | list | sort }}" - name: Set size fact ini_file: @@ -99,4 +99,6 @@ when: - (ansible_local['elastic']['retention']['cluster_nodes'] is undefined) or ((groups['elastic-logstash'] | length) != (ansible_local['elastic']['retention']['cluster_nodes'] | int)) or + ((ansible_local['elastic']['retention']['elastic_beat_retention_policy_keys'] is defined) and + ((ansible_local['elastic']['retention']['elastic_beat_retention_policy_keys'] | from_yaml) != (elastic_beat_retention_policy_hosts.keys() | list | sort))) or (elastic_retention_refresh | bool)