From a75e986836dca9b49c617fb134c3b184c1e1f1bf Mon Sep 17 00:00:00 2001 From: Doug Burks Date: Tue, 13 Oct 2020 12:18:27 -0400 Subject: [PATCH] Update so-elastic-clear --- salt/common/tools/sbin/so-elastic-clear | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/salt/common/tools/sbin/so-elastic-clear b/salt/common/tools/sbin/so-elastic-clear index 01f3a567c..432e61c2b 100755 --- a/salt/common/tools/sbin/so-elastic-clear +++ b/salt/common/tools/sbin/so-elastic-clear @@ -50,7 +50,11 @@ done if [ $SKIP -ne 1 ]; then # List indices echo + {% if grains['role'] in ['so-node','so-heavynode'] %} + curl -k https://{{ NODEIP }}:9200/_cat/indices?v + {% else %} curl {{ NODEIP }}:9200/_cat/indices?v + {% endif %} echo # Inform user we are about to delete all data echo @@ -89,10 +93,18 @@ fi # Delete data echo "Deleting data..." +{% if grains['role'] in ['so-node','so-heavynode'] %} +INDXS=$(curl -s -XGET -k https://{{ NODEIP }}:9200/_cat/indices?v | egrep 'logstash|elastalert|so-' | awk '{ print $3 }') +{% else %} INDXS=$(curl -s -XGET {{ NODEIP }}:9200/_cat/indices?v | egrep 'logstash|elastalert|so-' | awk '{ print $3 }') +{% endif %} for INDX in ${INDXS} do + {% if grains['role'] in ['so-node','so-heavynode'] %} + curl -XDELETE -k https://"{{ NODEIP }}:9200/${INDX}" > /dev/null 2>&1 + {% else %} curl -XDELETE "{{ NODEIP }}:9200/${INDX}" > /dev/null 2>&1 + {% endif %} done #Start Logstash/Filebeat