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

37 lines
911 B
Django/Jinja

#!/bin/bash
# {{ ansible_managed }}
set -eu
OPENSEARCH_BIN_PATH=/usr/share/opensearch/bin
OPENSEARCH_SERVICE=opensearch.service
ACTION="${1:-help}"
case "$ACTION" in
purge)
PLUGINS=$($OPENSEARCH_BIN_PATH/opensearch-plugin list | grep -v opensearch- || true)
if [[ -z "$PLUGINS" ]]; then
exit 0
else
for plugin in "${PLUGINS[@]}"; do
$OPENSEARCH_BIN_PATH/opensearch-plugin remove $plugin
done
systemctl restart $OPENSEARCH_SERVICE
fi
;;
install)
for plugin in "${PLUGINS[@]}"; do
$OPENSEARCH_BIN_PATH/opensearch-plugin install $plugin --batch
done
systemctl restart $OPENSEARCH_SERVICE
;;
help)
echo "Syntax: $(basename "$0") { purge | install | help }"
echo
;;
*)
"$0" help >&2
exit 1
;;
esac