Files
securityonion/salt/elasticsearch/config.map.jinja
2022-09-09 15:30:28 -04:00

46 lines
2.2 KiB
Django/Jinja

{% import_yaml 'elasticsearch/defaults.yaml' as ESCONFIG with context %}
{% from 'logstash/map.jinja' import REDIS_NODES with context %}
{% set HIGHLANDER = salt['pillar.get']('global:highlander', False) %}
{% if grains.id.split('_') | last in ['manager','managersearch'] %}
{% if REDIS_NODES | length > 1 %}
{% do ESCONFIG.elasticsearch.config.node.update({'roles': ['master', 'data', 'remote_cluster_client']}) %}
{% if HIGHLANDER %}
{% do ESCONFIG.elasticsearch.config.node.roles.extend(['ml', 'transform']) %}
{% endif %}
{% do ESCONFIG.elasticsearch.config.update({'discovery': {'seed_hosts': [grains.master]}}) %}
{% for SN in REDIS_NODES.keys() %}
{% do ESCONFIG.elasticsearch.config.discovery.seed_hosts.append(SN) %}
{% endfor %}
{% endif %}
{% if grains.id.split('_') | last == 'manager' %}
{% do ESCONFIG.elasticsearch.config.node.attr.update({'box_type': ''}) %}
{% endif %}
{% elif grains.id.split('_') | last not in ['eval', 'standalone', 'import'] %}
{% do ESCONFIG.elasticsearch.config.node.update({'roles': ['data', 'ingest']}) %}
{% if HIGHLANDER %}
{% do ESCONFIG.elasticsearch.config.node.roles.extend(['ml', 'master', 'transform']) %}
{% endif %}
{% do ESCONFIG.elasticsearch.config.node.attr.update({'box_type': 'hot'}) %}
{% do ESCONFIG.elasticsearch.config.update({'discovery': {'seed_hosts': [grains.master]}}) %}
{% endif %}
{% if HIGHLANDER %}
{% do ESCONFIG.elasticsearch.config.xpack.ml.update({'enabled': true}) %}
{% endif %}
{# merge with the elasticsearch pillar #}
{% set ESCONFIG = salt['pillar.get']('elasticsearch:config', default=ESCONFIG.elasticsearch.config, merge=True) %}
{% do ESCONFIG.elasticsearch.config.node.update({'name': grains.host}) %}
{% do ESCONFIG.elasticsearch.config.cluster.update({'name': grains.host}) %}
{% do ESCONFIG.elasticsearch.config.transport.update({'publish_host': grains.host}) %}
{% if salt['pillar.get']('elasticsearch:config:path:repo', False) %}
{% for repo in pillar.elasticsearch.config.path.repo %}
{# remove elasticsearch.config.path.repo value if the directory doesn't exist on the node #}
{% if not salt['file.directory_exists'](repo) %}
{% do ESCONFIG.path.repo.remove(repo) %}
{% endif %}
{% endfor %}
{% endif %}