From a42a9f1e79991c6f4495b4df1336c9ef70423dfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lex=20Ruiz?= Date: Mon, 18 Dec 2023 19:07:10 +0100 Subject: [PATCH] Update `indexer-ism-init.sh` (#81) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updates the script to upload the wazuh-template.json to the indexer. Signed-off-by: Álex Ruiz --- distribution/src/bin/indexer-ism-init.sh | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/distribution/src/bin/indexer-ism-init.sh b/distribution/src/bin/indexer-ism-init.sh index 3f2edc541a4ad..4217979624bc7 100644 --- a/distribution/src/bin/indexer-ism-init.sh +++ b/distribution/src/bin/indexer-ism-init.sh @@ -84,7 +84,24 @@ function generate_rollover_template() { # Loads the index templates for the rollover policy to the indexer. ######################################################################### function load_templates() { - # Note: the wazuh-template.json could also be loaded here. + # Load wazuh-template.json, needed for initial indices creation. + local wazuh_template_path="/etc/wazuh-indexer/wazuh-template.json" + echo "Will create 'wazuh' index template" + if [ -f $wazuh_template_path ]; then + cat $wazuh_template_path | + if ! curl -s -k ${C_AUTH} \ + -X PUT "${INDEXER_URL}/_template/wazuh" \ + -o "${LOG_FILE}" --create-dirs \ + -H 'Content-Type: application/json' -d @-; then + echo " ERROR: 'wazuh' template creation failed" + exit 1 + else + echo " SUCC: 'wazuh' template created or updated" + fi + else + echo " ERROR: $wazuh_template_path not found" + fi + echo "Will create index templates to configure the alias" for alias in "${aliases[@]}"; do generate_rollover_template "${alias}" |