I have multiple elasticsearch locations, each is a different cluster, but
all managed by a tribe leader.
I am trying to create just one elasticsearch.yml template that can look at
my inventory and determine of the host is part of the
elasticsearch-tribe-member group or a tribe-leader, then determine which
cluster it's part of.
My inventory follows this pattern:
[elasticsearch-tribe-leader]
FQDN
[elasticsearch-tribe-leader:vars]
location=geo location
[ny-elasticsearch-servers]
FQDN
FQDN
FQDN
[ny-elasticsearch-servers:vars]
location=ny
cluster_name=ny-servers
[ch-elasticsearch-servers]
FQDN
FQDN
FQDN
[ch-elasticsearch-servers:vars]
location=ch
cluster_name=ch-servers
[bz-elasticsearch-servers]
FQDN
FQDN
FQDN
[bz-elasticsearch-servers:vars]
location=bz
cluster_name=bz-servers
[elasticsearch-servers:children]
elasticsearch-tribe-leader
ny-elasticsearch-servers
ch-elasticsearch-servers
bz-elasticsearch-servers
[elasticsearch-tribe-member:children]
ny-elasticsearch-servers
ch-elasticsearch-servers
bz-elasticsearch-servers
This is where I am at right now.
I was hoping to say; if host is in the elasticsearch-tribe-member group,
assign the subgroup name to some variable and then iterate through those
cluster nodes. So each ny cluster node will be expanded and used in the zen
unicast hosts section.
cluster.name: {{ cluster_name }}
node.name: {{ ansible_fqdn }}
# Some logic to determine if tribe leader
{% if host in groups['elasticsearch-tribe-leader'] %}
tribe:
# loop cluster groups
{% for cluster in groups['elasticsearch-tribe-member'] %}
{{ cluster.cluster_name }}:
cluster.name: {{ cluster.cluster_name }}
discovery.zen.ping.multicase.enabled: false
# loop for each IP
discovery.zen.ping.unicast.hosts: [{% for node in cluster %}"{{
node.ipaddr('address') }}{% if not loop.last %}",{% endif %}{% endfor %}"]
{% endfor %}
{% endif %}
# If elasticsearch-tribe-member
{% if host in groups['elasticsearch-tribe-member'] %}
discovery.zen.ping.unicast.hosts: [{% for node in
groups['elasticsearch-tribe-member'] %}"{{ node.ipaddr('address') }}{% if
not loop.last %}",{% endif %}{% endfor %}"]
{% endif %}
http.cors.allow-origin: "/.*/"
http.cors.enabled: true
path.logs: /var/log/elasticsearch
path.data: /data//elasticsearch/data
node.rack: {{ node_rack }}
bootstrap.mlockall: true
node.master: {% if host in groups['elasticsearch-tribe-leader'] %} false {%
else %} true {% endif %}
node.data: {% if host in groups['elasticsearch-tribe-leader'] %} false {%
else %} true {% endif %}
Has anyone seen an example like this? Any recommendations on how to do
this. I know I could have multiple static elasticsearch.yml files for each
location/cluster but I was trying to avoid that.
Thanks
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/a2587e2d-1b82-4f76-83d5-e3f548da2841%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.