mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2025-12-07 17:52:46 +01:00
Re-establish Elasticsearch cluster (search) settings
This commit is contained in:
@@ -346,6 +346,15 @@ append_so-elasticsearch_so-status.conf:
|
|||||||
- name: /opt/so/conf/so-status/so-status.conf
|
- name: /opt/so/conf/so-status/so-status.conf
|
||||||
- text: so-elasticsearch
|
- text: so-elasticsearch
|
||||||
|
|
||||||
|
so-es-cluster-settings:
|
||||||
|
cmd.run:
|
||||||
|
- name: /usr/sbin/so-elasticsearch-cluster-settings
|
||||||
|
- cwd: /opt/so
|
||||||
|
- template: jinja
|
||||||
|
- require:
|
||||||
|
- docker_container: so-elasticsearch
|
||||||
|
- file: es_sync_scripts
|
||||||
|
|
||||||
so-elasticsearch-templates:
|
so-elasticsearch-templates:
|
||||||
cmd.run:
|
cmd.run:
|
||||||
- name: /usr/sbin/so-elasticsearch-templates-load
|
- name: /usr/sbin/so-elasticsearch-templates-load
|
||||||
|
|||||||
36
salt/elasticsearch/tools/sbin/so-elasticsearch-cluster-settings
Executable file
36
salt/elasticsearch/tools/sbin/so-elasticsearch-cluster-settings
Executable file
@@ -0,0 +1,36 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
{% set ES = salt['pillar.get']('manager:mainip', '') %}
|
||||||
|
{% set MANAGER = salt['grains.get']('master') %}
|
||||||
|
|
||||||
|
ELASTICSEARCH_PORT=9200
|
||||||
|
|
||||||
|
# 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
|
||||||
|
curl -K /opt/so/conf/elasticsearch/curl.config -k --output /dev/null --silent --head --fail -L https://localhost:"$ELASTICSEARCH_PORT"
|
||||||
|
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
|
||||||
|
|
||||||
|
# Check to see if config already exists
|
||||||
|
CLUSTER_SETTINGS=$(so-elasticsearch-query _cluster/settings | jq .persistent.cluster.remote)
|
||||||
|
if [[ ! -z "$CLUSTER_SETTINGS" ]]; then
|
||||||
|
echo "Applying cross cluster search config..."
|
||||||
|
so-elasticsearch-query _cluster/settings -d "{\"persistent\": {\"cluster\": {\"remote\": {\"{{ MANAGER }}\": {\"seeds\": [\"127.0.0.1:9300\"]}}}}}" -XPUT
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user