openstack-ansible-ops/elk_metrics_6x/common_task_data_node_hosts.yml
Kevin Carter fb7aed401b Break out setup and always tag facts
This change breaks out the basic install and setup playbooks into
different playbooks. This is done to ensure an operator can easily rerun
any part of the playbook as they upgrade, change, or modify a setup over
the lifetime of the deployment.

Change-Id: I66c53fcb21880c950ea3fee202e7d2224dfdff3a
Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
2018-06-15 17:24:01 -05:00

85 lines
3.1 KiB
YAML

---
# the master node count takes half the available nodes or sets it's self as 1
- name: Node count fact
set_fact:
storage_node_count: "{{ groups['elastic-logstash'] | length }}"
tags:
- always
- name: Master node pre-count fact
set_fact:
_master_node_count: "{{ ((storage_node_count | int) > 1) | ternary((((storage_node_count | int) // 2) | int), 1) }}"
tags:
- always
# if the master node count is even, add one to it otherwise use the provided value
- name: Master node count fact
set_fact:
master_node_count: "{{ ((_master_node_count | int) % 2 != 0) | ternary((_master_node_count | int), ((_master_node_count | int) + 1)) }}"
tags:
- always
- name: Data nodes fact
set_fact:
data_nodes: "{{ (groups['elastic-logstash'][:master_node_count | int] + groups['elastic-logstash'][master_node_count | int::2]) }}"
master_nodes: "{{ groups['elastic-logstash'][:master_node_count | int] }}"
coordination_nodes: |-
{% set nodes=[] %}
{% for host in groups['kibana'] %}
{% set _ = nodes.insert(loop.index, ((hostvars[host]['ansible_host'] | string) + ":" + (elastic_port | string))) %}
{% endfor %}
{{ nodes }}
zen_nodes: |-
{% set nodes=[] %}
{% for host in (groups['elastic-logstash'] | union(groups['kibana'])) %}
{% set _ = nodes.insert(loop.index, (hostvars[host]['ansible_host'] | string)) %}
{% endfor %}
{{ nodes }}
tags:
- always
- name: Data node count fact
set_fact:
data_node_count: "{{ data_nodes | length }}"
tags:
- always
# if the master node count is even, add one to it otherwise use the provided value
# set the data nodes to be all master and alternate through the remaining nodes
- name: Node enablement
set_fact:
master_node: "{{ (inventory_hostname in master_nodes) | ternary(true, false) }}"
data_node: "{{ (inventory_hostname in data_nodes) | ternary(true, false) }}"
tags:
- always
# Set a data node facts. The data nodes, in the case of elasticsearch are also
# ingest nodes.
- name: Set data nodes
set_fact:
elasticsearch_data_hosts: |-
{% if inventory_hostname in data_nodes %}
{% set data_hosts = ['127.0.0.1:' + (elastic_port | string)] %}
{% else %}
{% set nodes=[] %}
{% for host in data_nodes %}
{% set _ = nodes.insert(loop.index, ((hostvars[host]['ansible_host'] | string) + ":" + (elastic_port | string))) %}
{% endfor %}
{% set data_hosts = nodes | shuffle(seed=inventory_hostname) %}
{% endif %}
{{ data_hosts }}
logstash_data_hosts: |-
{% if inventory_hostname in data_nodes %}
{% set data_hosts = ['127.0.0.1:' + (logstash_beat_input_port | string)] %}
{% else %}
{% set nodes=[] %}
{% for host in data_nodes %}
{% set _ = nodes.insert(loop.index, ((hostvars[host]['ansible_host'] | string) + ":" + (logstash_beat_input_port | string))) %}
{% endfor %}
{% set data_hosts = nodes | shuffle(seed=inventory_hostname) %}
{% endif %}
{{ data_hosts }}
tags:
- always