From 6e052a306363ca78f0f25bb7dfde76ee302c27b4 Mon Sep 17 00:00:00 2001 From: Mike Reeves Date: Mon, 12 Sep 2022 17:17:14 -0400 Subject: [PATCH 1/2] Pull in dev --- salt/utility/bin/crossthestreams | 42 ++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 salt/utility/bin/crossthestreams diff --git a/salt/utility/bin/crossthestreams b/salt/utility/bin/crossthestreams new file mode 100644 index 000000000..38b7ab09c --- /dev/null +++ b/salt/utility/bin/crossthestreams @@ -0,0 +1,42 @@ +#!/bin/bash +{% set ES = salt['pillar.get']('global:managerip', '') %} +{% 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 + curl -K /opt/so/conf/elasticsearch/curl.config -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..." + curl -K /opt/so/conf/elasticsearch/curl.config -s -k -XPUT -L https://{{ ES }}:9200/_cluster/settings \ + -H 'Content-Type: application/json' \ + -d "{\"persistent\": {\"search\": {\"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() %} +curl -K /opt/so/conf/elasticsearch/curl.config -s -k -XPUT -L https://{{ ES }}:9200/_cluster/settings -H'Content-Type: application/json' -d '{"persistent": {"search": {"remote": {"{{ SN }}": {"skip_unavailable": "true", "seeds": ["{{ SN.split('_')|first }}:9300"]}}}}}' + {%- endfor %} + {%- endif %} +{%- endif %} From ec187e9d854eaefd5da3b390871bbb35f15cc4ee Mon Sep 17 00:00:00 2001 From: Mike Reeves Date: Mon, 12 Sep 2022 17:35:42 -0400 Subject: [PATCH 2/2] Pull in dev --- salt/utility/bin/crossthestreams | 42 -------------------------------- 1 file changed, 42 deletions(-) delete mode 100644 salt/utility/bin/crossthestreams diff --git a/salt/utility/bin/crossthestreams b/salt/utility/bin/crossthestreams deleted file mode 100644 index 38b7ab09c..000000000 --- a/salt/utility/bin/crossthestreams +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash -{% set ES = salt['pillar.get']('global:managerip', '') %} -{% 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 - curl -K /opt/so/conf/elasticsearch/curl.config -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..." - curl -K /opt/so/conf/elasticsearch/curl.config -s -k -XPUT -L https://{{ ES }}:9200/_cluster/settings \ - -H 'Content-Type: application/json' \ - -d "{\"persistent\": {\"search\": {\"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() %} -curl -K /opt/so/conf/elasticsearch/curl.config -s -k -XPUT -L https://{{ ES }}:9200/_cluster/settings -H'Content-Type: application/json' -d '{"persistent": {"search": {"remote": {"{{ SN }}": {"skip_unavailable": "true", "seeds": ["{{ SN.split('_')|first }}:9300"]}}}}}' - {%- endfor %} - {%- endif %} -{%- endif %}