ansible-role-opensearch/templates/update-opensearch-plugins.j2

55 lines
1.4 KiB
Plaintext
Raw Permalink Normal View History

2023-05-13 09:05:28 +02:00
#!/bin/bash
{{ ansible_managed | comment }}
2023-05-13 08:36:33 +02:00
set -eu
OPENSEARCH_BIN_PATH=/usr/share/opensearch/bin
2023-10-23 12:27:35 +02:00
OPENSEARCH_PLUGIN_PATH=/usr/share/opensearch/plugins
2023-05-13 08:36:33 +02:00
OPENSEARCH_SERVICE=opensearch.service
2023-07-04 22:20:14 +02:00
PLUGINS=(
{% for plugin in opensearch_plugins %}
{% if not loop.last %}
{{ plugin }}
{% else %}
{{ plugin }})
{% endif %}
{% endfor %}
2023-05-13 08:36:33 +02:00
ACTION="${1:-help}"
case "$ACTION" in
purge)
2023-07-04 22:20:14 +02:00
for plugin in "${PLUGINS[@]}"; do
2023-10-23 12:27:35 +02:00
if [ -d "$OPENSEARCH_PLUGIN_PATH/$plugin" ]; then
$OPENSEARCH_BIN_PATH/opensearch-plugin remove $plugin
fi
2023-07-04 22:20:14 +02:00
done
systemctl restart $OPENSEARCH_SERVICE
2023-05-13 08:36:33 +02:00
;;
install)
for plugin in "${PLUGINS[@]}"; do
$OPENSEARCH_BIN_PATH/opensearch-plugin install $plugin --batch
done
systemctl restart $OPENSEARCH_SERVICE
;;
2024-01-21 12:16:59 +01:00
reinstall)
for plugin in "${PLUGINS[@]}"; do
if [ -d "$OPENSEARCH_PLUGIN_PATH/$plugin" ]; then
$OPENSEARCH_BIN_PATH/opensearch-plugin remove $plugin
fi
done
for plugin in "${PLUGINS[@]}"; do
$OPENSEARCH_BIN_PATH/opensearch-plugin install $plugin --batch
done
systemctl restart $OPENSEARCH_SERVICE
;;
2023-05-13 08:36:33 +02:00
help)
2024-01-21 12:16:59 +01:00
echo "Syntax: $(basename "$0") { purge | install | reinstall | help }"
2023-05-13 08:36:33 +02:00
echo
;;
*)
"$0" help >&2
exit 1
;;
esac