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
This commit is contained in:
Dmitriy Rabotyagov 2020-11-12 15:33:27 +02:00
parent b05893ae39
commit 59edfb9b32

View File

@ -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)
}}