1
+ # Copyright Security Onion Solutions LLC and/or licensed to Security Onion Solutions LLC under one
2
+ # or more contributor license agreements. Licensed under the Elastic License 2.0 as shown at
3
+ # https://securityonion.net/license; you may not use this file except in compliance with the
4
+ # Elastic License 2.0.
5
+
6
+ {# Managed elasticsearch/soc_elasticsearch.yaml file for adding integration configuration items to UI #}
7
+ {% set managed_integrations = salt[' pillar.get' ](' elasticsearch:managed_integrations' , []) %}
8
+ {% if managed_integrations %}
9
+ {% from ' elasticfleet/integration-defaults.map.jinja' import ADDON_INTEGRATION_DEFAULTS % }
10
+ {% set addon_integration_keys = ADDON_INTEGRATION_DEFAULTS .keys() % }
11
+ {% set matched_integration_names = [] % }
12
+ {% for k in addon_integration_keys % }
13
+ {% for i in managed_integrations % }
14
+ {% if i in k % }
15
+ {% do matched_integration_names.append(k) % }
16
+ {% endif % }
17
+ {% endfor % }
18
+ {% endfor % }
19
+ {% set es_soc_annotations = ' /opt/so/saltstack/default/salt/elasticsearch/soc_elasticsearch.yaml' % }
20
+ {{ es_soc_annotations }}:
21
+ file .serialize:
22
+ - dataset:
23
+ {% set data = salt[' file.read' ](es_soc_annotations) | load_yaml % }
24
+ {% set es = data.get(' elasticsearch' , {}) % }
25
+ {% set index_settings = es.get(' index_settings' , {}) % }
26
+ {% set input = index_settings.get(' so-logs' , {}) % }
27
+ {% for k in matched_integration_names % }
28
+ {% if k not in index_settings % }
29
+ {% set _ = index_settings.update({k: input }) % }
30
+ {% endif % }
31
+ {% endfor % }
32
+ {% for k in addon_integration_keys % }
33
+ {% if k not in matched_integration_names and k in index_settings % }
34
+ {% set _ = index_settings.pop(k) % }
35
+ {% endif % }
36
+ {% endfor % }
37
+ {{ data }}
38
+
39
+ {# Managed elasticsearch/defaults.yaml file for enabling 'Revert to default' via SOC UI for newly added config items #}
40
+ {% set es_defaults = ' /opt/so/saltstack/default/salt/elasticsearch/defaults.yaml' % }
41
+ {{ es_defaults }}:
42
+ file .serialize:
43
+ - dataset:
44
+ {% set data = salt[' file.read' ](es_defaults) | load_yaml % }
45
+ {% set es = data.get(' elasticsearch' , {}) % }
46
+ {% set index_settings = es.get(' index_settings' , {}) % }
47
+ {% for k in matched_integration_names % }
48
+ {% if k not in index_settings % }
49
+ {% set input = ADDON_INTEGRATION_DEFAULTS [k] % }
50
+ {% set _ = index_settings.update({k: input })% }
51
+ {% endif % }
52
+ {% endfor % }
53
+ {% for k in addon_integration_keys % }
54
+ {% if k not in matched_integration_names and k in index_settings % }
55
+ {% set _ = index_settings.pop(k) % }
56
+ {% endif % }
57
+ {% endfor % }
58
+ {{ data }}
59
+ {% endif % }
0 commit comments