From 59edfb9b32f7aab4eaaf783d8cbfff86afc6e8dd Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Thu, 12 Nov 2020 15:33:27 +0200 Subject: [PATCH] Fix regex_replace mapping With current mapping we result in elasticsearch_data_node_details being 172.29.236.126:9200:9200 instead of 172.29.236.126:9200 which means that map is applied twice to the same item Changing regexp helps to resolve it. It looks like related to what [1] have seen Also we don't need to transform to list when doing another map, as working with generator object is more resource efficient. [1] https://gist.github.com/halberom/9bfe009c9a3df5d64c7bb505a7700430#gistcomment-2706901 Change-Id: I22b6735ad211e60b61d74cea34c7987d74bc8596 --- .../elastic_data_hosts/vars/data-node-variables.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 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 cf10240b..807a7ade 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 @@ -87,8 +87,8 @@ coordination_nodes: |- {% endif %} {{ (elasticsearch_coordination_node_socket_addresses - | default((c_nodes | map('extract', hostvars, 'ansible_host') | list) - | map('regex_replace', '(.*)' ,'\1:' ~ elastic_port) | list)) + | default((c_nodes | map('extract', hostvars, 'ansible_host')) + | map('regex_replace', '^(.*)$' ,'\1:' ~ elastic_port) | list)) }} _elasticsearch_discovery_seed_hosts: >- @@ -138,8 +138,8 @@ elasticsearch_interface_speed: |- elasticsearch_data_node_details: >- {{ elasticsearch_data_node_socket_addresses - | default((data_nodes | map('extract', hostvars, 'ansible_host') | list) - | map('regex_replace', '(.*)' ,'\1:' ~ elastic_port) | list) + | default((data_nodes | map('extract', hostvars, 'ansible_host')) + | map('regex_replace', '^(.*)$' ,'\1:' ~ elastic_port) | list) }} # IP addresses for the logstash data nodes @@ -148,8 +148,8 @@ elasticsearch_data_node_details: >- logstash_data_node_details: >- {{ logstash_data_node_socket_addresses - | default((groups['logstash'] | map('extract', hostvars, 'ansible_host') | list) - | map('regex_replace', '(.*)' ,'\1:' ~ logstash_beat_input_port) | list) + | default((groups['logstash'] | map('extract', hostvars, 'ansible_host')) + | map('regex_replace', '^(.*)$' ,'\1:' ~ logstash_beat_input_port) | list) }}