extra_hosts and redis_input for logstash

This commit is contained in:
m0duspwnens
2021-12-14 18:49:30 -05:00
parent 4da017d61c
commit 55b74abcc5
3 changed files with 27 additions and 11 deletions
+16
View File
@@ -0,0 +1,16 @@
{% set role = grains.role %}
{% set EXTRA_HOSTS = [] %}
{% set mainint = salt['pillar.get']('host:mainint') %}
{% set localhostip = salt['grains.get']('ip_interfaces').get(mainint)[0] %}
{% if role in ['so-node'] %}
{% set node_data = salt['pillar.get']('logstash:nodes') %}
{% 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() %}
{% do EXTRA_HOSTS.append({hostname:node_details[hostname].ip}) %}
{% endfor %}
{% endif %}
{% endfor %}
{% else %}
{% do EXTRA_HOSTS.append({grains.host:localhostip}) %}
{% endif %}