fix loadbalance logic and whitespace for filebeat.yml

This commit is contained in:
m0duspwnens
2021-12-15 16:21:08 -05:00
parent cf2f4bad09
commit 522bc1d2b8

View File

@@ -322,24 +322,27 @@ output.logstash:
# The Logstash hosts # The Logstash hosts
hosts: hosts:
{%- if grains.role in ['so-sensor', 'so-fleet', 'so-node'] %} {%- if grains.role in ['so-sensor', 'so-fleet', 'so-node'] -%}
{%- set LOADBALANCE = ['false'] %} {% set LOGSTASH = namespace() -%}
{%- set node_data = salt['pillar.get']('logstash:nodes') %} {% set LOGSTASH.count = 0 -%}
{%- for node_type, node_details in node_data.items() | sort %} {% set LOGSTASH.loadbalance = false -%}
{%- if node_type in ['manager', 'managersearch', 'standalone', 'receiver' ] %} {% set node_data = salt['pillar.get']('logstash:nodes') -%}
{%- for hostname in node_data[node_type].keys() %} {% for node_type, node_details in node_data.items() | sort -%}
{% if node_type in ['manager', 'managersearch', 'standalone', 'receiver' ] -%}
{% for hostname in node_data[node_type].keys() -%}
{% set LOGSTASH.count = LOGSTASH.count + 1 %}
- "{{ hostname }}:5644" #{{ node_details[hostname].ip }} - "{{ hostname }}:5644" #{{ node_details[hostname].ip }}
{%- endfor %} {%- endfor -%}
{%- endif %} {% endif -%}
{%- if loop.index == 2 %} {% if LOGSTASH.count > 1 -%}
{%- do LOADBALANCE.insert(0, 'true') %} {% set LOGSTASH.loadbalance = true -%}
{%- endif %} {% endif -%}
{%- endfor %} {% endfor %}
loadbalance: {{ LOADBALANCE[0] }}
{%- else %}
- "{{ grains.host }}:5644"
{%- endif %}
loadbalance: {{ LOGSTASH.loadbalance | lower }}
{% else -%}
- "{{ grains.host }}:5644"
{% endif %}
# Number of workers per Logstash host. # Number of workers per Logstash host.
worker: {{ FBLSWORKERS }} worker: {{ FBLSWORKERS }}