Expose Elasticsearch discovery nodes

It is currently the case that the discovery information for
elasticsearch nodes is generated using the elasticsearch node and
kibana node groups internally. This means that one cannot connect to
a remote cluster that is not managed by the same ansible inventory. This
commit exposes the configuration to allow this to occur, permitting
the elasticsearch discovery nodes to be optionally defined with further
information. The associated internal variables have been renamed from
zen_nodes as zen is used within Elasticsearch for discovery only
internally, and the associated elasticsearch config file setting has
been renamed to 'discovery.seed_hosts'.

Change-Id: I76532c185e991eddcb1111fc58e7120a52c0120c
This commit is contained in:
Duncan Martin Walker 2020-02-19 18:52:32 +00:00
parent 4851e29e9c
commit b14224c030
4 changed files with 10 additions and 5 deletions

View File

@ -34,3 +34,6 @@ elastic_data_interface: "{{ ansible_default_ipv4['alias'] }}"
## Elasticsearch index template settings
# Set the default max number of fields used in a query
# elastic_max_docvalue_fields_search: "100"
# The set of nodes used for elasticsearch discovery
# elasticsearch_discovery_seed_hosts: "{{ (elastic_hosts | union(groups['kibana'])) | map('extract', hostvars, 'ansible_host') | list }}"

View File

@ -91,9 +91,10 @@ coordination_nodes: |-
| map('regex_replace', '(.*)' ,'\1:' ~ elastic_port) | list))
}}
zen_nodes: >-
_elasticsearch_discovery_seed_hosts: >-
{{
(groups['elastic'] | union(groups['kibana'])) | map('extract', hostvars, 'ansible_host') | list | shuffle(seed=inventory_hostname)
elasticsearch_discovery_seed_hosts
| default((groups['elastic'] | union(groups['kibana'])) | map('extract', hostvars, 'ansible_host') | list)
}}
elasticserch_interface_speed: |-

View File

@ -82,7 +82,8 @@ http.port: {{ elastic_port }}
# Pass an initial list of hosts to perform discovery when this node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
discovery.seed_hosts: {{ zen_nodes | to_json }}
discovery.seed_hosts: {{ _elasticsearch_discovery_seed_hosts | shuffle(seed=inventory_hostname) | to_json }}
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#

View File

@ -42,9 +42,9 @@
debug:
msg: "Coordination nodes: {{ coordination_nodes }}"
- name: "Report Zen nodes"
- name: "Report Elasticsearch discovery nodes"
debug:
msg: "Zen nodes: {{ zen_nodes }}"
msg: "Elasticsearch discovery nodes: {{ _elasticsearch_discovery_seed_hosts }}"
delegate_to: elastic[0]
run_once: true