mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2025-12-06 01:02:46 +01:00
43 lines
1.7 KiB
Bash
43 lines
1.7 KiB
Bash
#!/bin/bash
|
|
{% set ES = salt['pillar.get']('manager:mainip', '') %}
|
|
{% set MANAGER = salt['grains.get']('master') %}
|
|
{% set TRUECLUSTER = salt['pillar.get']('elasticsearch:true_cluster', False) %}
|
|
|
|
# Wait for ElasticSearch to come up, so that we can query for version infromation
|
|
echo -n "Waiting for ElasticSearch..."
|
|
COUNT=0
|
|
ELASTICSEARCH_CONNECTED="no"
|
|
while [[ "$COUNT" -le 30 ]]; do
|
|
{{ ELASTICCURL }} -k --output /dev/null --silent --head --fail -L https://{{ ES }}:9200
|
|
if [ $? -eq 0 ]; then
|
|
ELASTICSEARCH_CONNECTED="yes"
|
|
echo "connected!"
|
|
break
|
|
else
|
|
((COUNT+=1))
|
|
sleep 1
|
|
echo -n "."
|
|
fi
|
|
done
|
|
if [ "$ELASTICSEARCH_CONNECTED" == "no" ]; then
|
|
echo
|
|
echo -e "Connection attempt timed out. Unable to connect to ElasticSearch. \nPlease try: \n -checking log(s) in /var/log/elasticsearch/\n -running 'docker ps' \n -running 'sudo so-elastic-restart'"
|
|
echo
|
|
|
|
exit
|
|
fi
|
|
|
|
echo "Applying cross cluster search config..."
|
|
{{ ELASTICCURL }} -s -k -XPUT -L https://{{ ES }}:9200/_cluster/settings \
|
|
-H 'Content-Type: application/json' \
|
|
-d "{\"persistent\": {\"cluster\": {\"remote\": {\"{{ MANAGER }}\": {\"seeds\": [\"127.0.0.1:9300\"]}}}}}"
|
|
|
|
# Add all the search nodes to cross cluster searching.
|
|
{%- if TRUECLUSTER is sameas false %}
|
|
{%- if salt['pillar.get']('nodestab', {}) %}
|
|
{%- for SN, SNDATA in salt['pillar.get']('nodestab', {}).items() %}
|
|
{{ ELASTICCURL }} -s -k -XPUT -L https://{{ ES }}:9200/_cluster/settings -H'Content-Type: application/json' -d '{"persistent": {"cluster": {"remote": {"{{ SN }}": {"skip_unavailable": "true", "seeds": ["{{ SN.split('_')|first }}:9300"]}}}}}'
|
|
{%- endfor %}
|
|
{%- endif %}
|
|
{%- endif %}
|