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

43 lines
1,007 B
Django/Jinja

#!/bin/bash
{{ ansible_managed | comment }}
set -eu
OPENSEARCH_BIN_PATH=/usr/share/opensearch/bin
OPENSEARCH_PLUGIN_PATH=/usr/share/opensearch/plugins
OPENSEARCH_SERVICE=opensearch.service
PLUGINS=(
{% for plugin in opensearch_plugins %}
{% if not loop.last %}
{{ plugin }}
{% else %}
{{ plugin }})
{% endif %}
{% endfor %}
ACTION="${1:-help}"
case "$ACTION" in
purge)
for plugin in "${PLUGINS[@]}"; do
if [ -d "$OPENSEARCH_PLUGIN_PATH/$plugin" ]; then
$OPENSEARCH_BIN_PATH/opensearch-plugin remove $plugin
fi
done
systemctl restart $OPENSEARCH_SERVICE
;;
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