From df46716a9b9a7cc25a4a64e007c1c28191ad0b2e Mon Sep 17 00:00:00 2001
From: Peter Dragos <15849936+dragospe@users.noreply.github.com>
Date: Mon, 14 Dec 2020 18:05:36 -0500
Subject: [PATCH] add localfile labels to agent ossec.conf template
This change enables generating a stanza such as
```
/var/log/myapp/log.json
json
```
from the `wazuh_agent_config` snippet:
```
- format: json
location: /var/log/myapp/log.json
label:
- key: "@source"
value: "myapp"
- key: "agent.type"
value: "webserver"
```
---
.../var-ossec-etc-ossec-agent.conf.j2 | 20 +++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/roles/wazuh/ansible-wazuh-agent/templates/var-ossec-etc-ossec-agent.conf.j2 b/roles/wazuh/ansible-wazuh-agent/templates/var-ossec-etc-ossec-agent.conf.j2
index 22f94856..9cd8d1f2 100644
--- a/roles/wazuh/ansible-wazuh-agent/templates/var-ossec-etc-ossec-agent.conf.j2
+++ b/roles/wazuh/ansible-wazuh-agent/templates/var-ossec-etc-ossec-agent.conf.j2
@@ -353,6 +353,11 @@
{% endif %}
{% else %}
{{ localfile.location }}
+ {% if localfile.format == 'json' %}
+ {% for label in localfile.label %}
+
+ {% endfor %}
+ {% endif %}
{% endif %}
{% endfor %}
@@ -371,6 +376,11 @@
{% endif %}
{% else %}
{{ localfile.location }}
+ {% if localfile.format == 'json' %}
+ {% for label in localfile.label %}
+
+ {% endfor %}
+ {% endif %}
{% endif %}
{% endfor %}
@@ -389,6 +399,11 @@
{% endif %}
{% else %}
{{ localfile.location }}
+ {% if localfile.format == 'json' %}
+ {% for label in localfile.label %}
+
+ {% endfor %}
+ {% endif %}
{% endif %}
{% endfor %}
@@ -404,6 +419,11 @@
{{ localfile.query}}
{% else %}
{{ localfile.location }}
+ {% if localfile.format == 'json' %}
+ {% for label in localfile.label %}
+
+ {% endfor %}
+ {% endif %}
{% endif %}
{% endfor %}