Skip to content

Commit c0421a5

Browse files
committed
Update indexer-ism-init.sh (#81)
Updates the script to upload the wazuh-template.json to the indexer. Signed-off-by: Álex Ruiz <[email protected]>
1 parent d05656a commit c0421a5

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

distribution/src/bin/indexer-ism-init.sh

+18-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,24 @@ function generate_rollover_template() {
8484
# Loads the index templates for the rollover policy to the indexer.
8585
#########################################################################
8686
function load_templates() {
87-
# Note: the wazuh-template.json could also be loaded here.
87+
# Load wazuh-template.json, needed for initial indices creation.
88+
local wazuh_template_path="/etc/wazuh-indexer/wazuh-template.json"
89+
echo "Will create 'wazuh' index template"
90+
if [ -f $wazuh_template_path ]; then
91+
cat $wazuh_template_path |
92+
if ! curl -s -k ${C_AUTH} \
93+
-X PUT "${INDEXER_URL}/_template/wazuh" \
94+
-o "${LOG_FILE}" --create-dirs \
95+
-H 'Content-Type: application/json' -d @-; then
96+
echo " ERROR: 'wazuh' template creation failed"
97+
exit 1
98+
else
99+
echo " SUCC: 'wazuh' template created or updated"
100+
fi
101+
else
102+
echo " ERROR: $wazuh_template_path not found"
103+
fi
104+
88105
echo "Will create index templates to configure the alias"
89106
for alias in "${aliases[@]}"; do
90107
generate_rollover_template "${alias}" |

0 commit comments

Comments
 (0)