mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2025-12-06 17:22:49 +01:00
changes for script to auth to elastic
This commit is contained in:
@@ -2,6 +2,8 @@
|
|||||||
{% if sls in allowed_states %}
|
{% if sls in allowed_states %}
|
||||||
|
|
||||||
{% set role = grains.id.split('_') | last %}
|
{% set role = grains.id.split('_') | last %}
|
||||||
|
{% set ELASTICUSER = salt['pillar.get']('elasticsearch:auth:user', '' ) %}
|
||||||
|
{% set ELASTICPASS = salt['pillar.get']('elasticsearch:auth:pass', '' ) %}
|
||||||
|
|
||||||
# Remove variables.txt from /tmp - This is temp
|
# Remove variables.txt from /tmp - This is temp
|
||||||
rmvariablesfile:
|
rmvariablesfile:
|
||||||
@@ -178,6 +180,13 @@ utilsyncscripts:
|
|||||||
- file_mode: 755
|
- file_mode: 755
|
||||||
- template: jinja
|
- template: jinja
|
||||||
- source: salt://common/tools/sbin
|
- source: salt://common/tools/sbin
|
||||||
|
- defaults:
|
||||||
|
ELASTICCURL: "curl"
|
||||||
|
{% if salt['pillar.get']('elasticsearch:auth_enabled', False) %}
|
||||||
|
- context:
|
||||||
|
ELASTICCURL: "curl --user {{ELASTICUSER}}:{{ELASTICPASS}}"
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
{% if role in ['eval', 'standalone', 'sensor', 'heavynode'] %}
|
{% if role in ['eval', 'standalone', 'sensor', 'heavynode'] %}
|
||||||
# Add sensor cleanup
|
# Add sensor cleanup
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ done
|
|||||||
if [ $SKIP -ne 1 ]; then
|
if [ $SKIP -ne 1 ]; then
|
||||||
# List indices
|
# List indices
|
||||||
echo
|
echo
|
||||||
curl -k -L https://{{ NODEIP }}:9200/_cat/indices?v
|
{{ ELASTICCURL }} -k -L https://{{ NODEIP }}:9200/_cat/indices?v
|
||||||
echo
|
echo
|
||||||
# Inform user we are about to delete all data
|
# Inform user we are about to delete all data
|
||||||
echo
|
echo
|
||||||
@@ -89,10 +89,10 @@ fi
|
|||||||
# Delete data
|
# Delete data
|
||||||
echo "Deleting data..."
|
echo "Deleting data..."
|
||||||
|
|
||||||
INDXS=$(curl -s -XGET -k -L https://{{ NODEIP }}:9200/_cat/indices?v | egrep 'logstash|elastalert|so-' | awk '{ print $3 }')
|
INDXS=$({{ ELASTICCURL }} -s -XGET -k -L https://{{ NODEIP }}:9200/_cat/indices?v | egrep 'logstash|elastalert|so-' | awk '{ print $3 }')
|
||||||
for INDX in ${INDXS}
|
for INDX in ${INDXS}
|
||||||
do
|
do
|
||||||
curl -XDELETE -k -L https://"{{ NODEIP }}:9200/${INDX}" > /dev/null 2>&1
|
{{ ELASTICCURL }} -XDELETE -k -L https://"{{ NODEIP }}:9200/${INDX}" > /dev/null 2>&1
|
||||||
done
|
done
|
||||||
|
|
||||||
#Start Logstash/Filebeat
|
#Start Logstash/Filebeat
|
||||||
|
|||||||
@@ -18,4 +18,4 @@
|
|||||||
|
|
||||||
. /usr/sbin/so-common
|
. /usr/sbin/so-common
|
||||||
|
|
||||||
curl -s -k -L https://{{ NODEIP }}:9200/_cat/indices?pretty
|
{{ ELASTICCURL }} -s -k -L https://{{ NODEIP }}:9200/_cat/indices?pretty
|
||||||
|
|||||||
@@ -21,5 +21,5 @@ THEHIVEESPORT=9400
|
|||||||
|
|
||||||
echo "Removing read only attributes for indices..."
|
echo "Removing read only attributes for indices..."
|
||||||
echo
|
echo
|
||||||
curl -s -k -XPUT -H "Content-Type: application/json" -L https://$IP:9200/_all/_settings -d '{"index.blocks.read_only_allow_delete": null}' 2>&1 | if grep -q ack; then echo "Index settings updated..."; else echo "There was any issue updating the read-only attribute. Please ensure Elasticsearch is running.";fi;
|
{{ ELASTICCURL }} -s -k -XPUT -H "Content-Type: application/json" -L https://$IP:9200/_all/_settings -d '{"index.blocks.read_only_allow_delete": null}' 2>&1 | if grep -q ack; then echo "Index settings updated..."; else echo "There was any issue updating the read-only attribute. Please ensure Elasticsearch is running.";fi;
|
||||||
curl -XPUT -H "Content-Type: application/json" -L http://$IP:9400/_all/_settings -d '{"index.blocks.read_only_allow_delete": null}' 2>&1 | if grep -q ack; then echo "Index settings updated..."; else echo "There was any issue updating the read-only attribute. Please ensure Elasticsearch is running.";fi;
|
{{ ELASTICCURL }} -XPUT -H "Content-Type: application/json" -L http://$IP:9400/_all/_settings -d '{"index.blocks.read_only_allow_delete": null}' 2>&1 | if grep -q ack; then echo "Index settings updated..."; else echo "There was any issue updating the read-only attribute. Please ensure Elasticsearch is running.";fi;
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
. /usr/sbin/so-common
|
. /usr/sbin/so-common
|
||||||
|
|
||||||
if [ "$1" == "" ]; then
|
if [ "$1" == "" ]; then
|
||||||
curl -s -k -L https://{{ NODEIP }}:9200/_nodes/stats | jq .nodes | jq ".[] | .ingest.pipelines"
|
{{ ELASTICCURL }} -s -k -L https://{{ NODEIP }}:9200/_nodes/stats | jq .nodes | jq ".[] | .ingest.pipelines"
|
||||||
else
|
else
|
||||||
curl -s -k -L https://{{ NODEIP }}:9200/_nodes/stats | jq .nodes | jq ".[] | .ingest.pipelines.\"$1\""
|
{{ ELASTICCURL }} -s -k -L https://{{ NODEIP }}:9200/_nodes/stats | jq .nodes | jq ".[] | .ingest.pipelines.\"$1\""
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
. /usr/sbin/so-common
|
. /usr/sbin/so-common
|
||||||
|
|
||||||
if [ "$1" == "" ]; then
|
if [ "$1" == "" ]; then
|
||||||
curl -s -k -L https://{{ NODEIP }}:9200/_ingest/pipeline/* | jq .
|
{{ ELASTICCURL }} -s -k -L https://{{ NODEIP }}:9200/_ingest/pipeline/* | jq .
|
||||||
else
|
else
|
||||||
curl -s -k -L https://{{ NODEIP }}:9200/_ingest/pipeline/$1 | jq .
|
{{ ELASTICCURL }} -s -k -L https://{{ NODEIP }}:9200/_ingest/pipeline/$1 | jq .
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
{%- set NODEIP = salt['pillar.get']('elasticsearch:mainip', '') -%}
|
{%- set NODEIP = salt['pillar.get']('elasticsearch:mainip', '') -%}
|
||||||
. /usr/sbin/so-common
|
. /usr/sbin/so-common
|
||||||
if [ "$1" == "" ]; then
|
if [ "$1" == "" ]; then
|
||||||
curl -s -k -L https://{{ NODEIP }}:9200/_ingest/pipeline/* | jq 'keys'
|
{{ ELASTICCURL }} -s -k -L https://{{ NODEIP }}:9200/_ingest/pipeline/* | jq 'keys'
|
||||||
else
|
else
|
||||||
curl -s -k -L https://{{ NODEIP }}:9200/_ingest/pipeline/$1 | jq
|
{{ ELASTICCURL }} -s -k -L https://{{ NODEIP }}:9200/_ingest/pipeline/$1 | jq
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -18,4 +18,4 @@
|
|||||||
|
|
||||||
. /usr/sbin/so-common
|
. /usr/sbin/so-common
|
||||||
|
|
||||||
curl -s -k -L https://{{ NODEIP }}:9200/_cat/shards?pretty
|
{{ ELASTICCURL }} -s -k -L https://{{ NODEIP }}:9200/_cat/shards?pretty
|
||||||
|
|||||||
@@ -18,4 +18,4 @@
|
|||||||
|
|
||||||
. /usr/sbin/so-common
|
. /usr/sbin/so-common
|
||||||
|
|
||||||
curl -s -k -L -XDELETE https://{{ NODEIP }}:9200/_template/$1
|
{{ ELASTICCURL }} -s -k -L -XDELETE https://{{ NODEIP }}:9200/_template/$1
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
. /usr/sbin/so-common
|
. /usr/sbin/so-common
|
||||||
|
|
||||||
if [ "$1" == "" ]; then
|
if [ "$1" == "" ]; then
|
||||||
curl -s -k -L https://{{ NODEIP }}:9200/_template/* | jq .
|
{{ ELASTICCURL }} -s -k -L https://{{ NODEIP }}:9200/_template/* | jq .
|
||||||
else
|
else
|
||||||
curl -s -k -L https://{{ NODEIP }}:9200/_template/$1 | jq .
|
{{ ELASTICCURL }} -s -k -L https://{{ NODEIP }}:9200/_template/$1 | jq .
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
{%- set NODEIP = salt['pillar.get']('elasticsearch:mainip', '') -%}
|
{%- set NODEIP = salt['pillar.get']('elasticsearch:mainip', '') -%}
|
||||||
. /usr/sbin/so-common
|
. /usr/sbin/so-common
|
||||||
if [ "$1" == "" ]; then
|
if [ "$1" == "" ]; then
|
||||||
curl -s -k -L https://{{ NODEIP }}:9200/_template/* | jq 'keys'
|
{{ ELASTICCURL }} -s -k -L https://{{ NODEIP }}:9200/_template/* | jq 'keys'
|
||||||
else
|
else
|
||||||
curl -s -k -L https://{{ NODEIP }}:9200/_template/$1 | jq
|
{{ ELASTICCURL }} -s -k -L https://{{ NODEIP }}:9200/_template/$1 | jq
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -15,4 +15,4 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
curl -X GET -k -L "https://localhost:9200/_cat/indices?v&s=index"
|
{{ ELASTICCURL }} -X GET -k -L "https://localhost:9200/_cat/indices?v&s=index"
|
||||||
|
|||||||
@@ -326,7 +326,7 @@ rc1_to_rc2() {
|
|||||||
local NAME=$(echo $p | awk '{print $1}')
|
local NAME=$(echo $p | awk '{print $1}')
|
||||||
local IP=$(echo $p | awk '{print $2}')
|
local IP=$(echo $p | awk '{print $2}')
|
||||||
echo "Removing the old cross cluster config for $NAME"
|
echo "Removing the old cross cluster config for $NAME"
|
||||||
curl -XPUT -H 'Content-Type: application/json' http://localhost:9200/_cluster/settings -d '{"persistent":{"cluster":{"remote":{"'$NAME'":{"skip_unavailable":null,"seeds":null}}}}}'
|
{{ ELASTICCURL }} -XPUT -H 'Content-Type: application/json' http://localhost:9200/_cluster/settings -d '{"persistent":{"cluster":{"remote":{"'$NAME'":{"skip_unavailable":null,"seeds":null}}}}}'
|
||||||
done </tmp/nodes.txt
|
done </tmp/nodes.txt
|
||||||
# Add the nodes back using hostname
|
# Add the nodes back using hostname
|
||||||
while read p; do
|
while read p; do
|
||||||
@@ -334,7 +334,7 @@ rc1_to_rc2() {
|
|||||||
local EHOSTNAME=$(echo $p | awk -F"_" '{print $1}')
|
local EHOSTNAME=$(echo $p | awk -F"_" '{print $1}')
|
||||||
local IP=$(echo $p | awk '{print $2}')
|
local IP=$(echo $p | awk '{print $2}')
|
||||||
echo "Adding the new cross cluster config for $NAME"
|
echo "Adding the new cross cluster config for $NAME"
|
||||||
curl -XPUT http://localhost:9200/_cluster/settings -H'Content-Type: application/json' -d '{"persistent": {"search": {"remote": {"'$NAME'": {"skip_unavailable": "true", "seeds": ["'$EHOSTNAME':9300"]}}}}}'
|
{{ ELASTICCURL }} -XPUT http://localhost:9200/_cluster/settings -H'Content-Type: application/json' -d '{"persistent": {"search": {"remote": {"'$NAME'": {"skip_unavailable": "true", "seeds": ["'$EHOSTNAME':9300"]}}}}}'
|
||||||
done </tmp/nodes.txt
|
done </tmp/nodes.txt
|
||||||
|
|
||||||
INSTALLEDVERSION=rc.2
|
INSTALLEDVERSION=rc.2
|
||||||
|
|||||||
@@ -89,6 +89,9 @@ firewall:
|
|||||||
- 514
|
- 514
|
||||||
udp:
|
udp:
|
||||||
- 514
|
- 514
|
||||||
|
vault:
|
||||||
|
tcp:
|
||||||
|
- 8200
|
||||||
wazuh_agent:
|
wazuh_agent:
|
||||||
tcp:
|
tcp:
|
||||||
- 1514
|
- 1514
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ echo -n "Waiting for ElasticSearch..."
|
|||||||
COUNT=0
|
COUNT=0
|
||||||
ELASTICSEARCH_CONNECTED="no"
|
ELASTICSEARCH_CONNECTED="no"
|
||||||
while [[ "$COUNT" -le 30 ]]; do
|
while [[ "$COUNT" -le 30 ]]; do
|
||||||
curl -k --output /dev/null --silent --head --fail -L https://{{ ES }}:9200
|
{{ ELASTICCURL }} -k --output /dev/null --silent --head --fail -L https://{{ ES }}:9200
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
ELASTICSEARCH_CONNECTED="yes"
|
ELASTICSEARCH_CONNECTED="yes"
|
||||||
echo "connected!"
|
echo "connected!"
|
||||||
@@ -28,7 +28,7 @@ if [ "$ELASTICSEARCH_CONNECTED" == "no" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Applying cross cluster search config..."
|
echo "Applying cross cluster search config..."
|
||||||
curl -s -k -XPUT -L https://{{ ES }}:9200/_cluster/settings \
|
{{ ELASTICCURL }} -s -k -XPUT -L https://{{ ES }}:9200/_cluster/settings \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
-d "{\"persistent\": {\"search\": {\"remote\": {\"{{ MANAGER }}\": {\"seeds\": [\"127.0.0.1:9300\"]}}}}}"
|
-d "{\"persistent\": {\"search\": {\"remote\": {\"{{ MANAGER }}\": {\"seeds\": [\"127.0.0.1:9300\"]}}}}}"
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ echo "Applying cross cluster search config..."
|
|||||||
{%- if TRUECLUSTER is sameas false %}
|
{%- if TRUECLUSTER is sameas false %}
|
||||||
{%- if salt['pillar.get']('nodestab', {}) %}
|
{%- if salt['pillar.get']('nodestab', {}) %}
|
||||||
{%- for SN, SNDATA in salt['pillar.get']('nodestab', {}).items() %}
|
{%- for SN, SNDATA in salt['pillar.get']('nodestab', {}).items() %}
|
||||||
curl -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"]}}}}}'
|
{{ ELASTICCURL }} -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 %}
|
{%- endfor %}
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ echo -n "Waiting for ElasticSearch..."
|
|||||||
COUNT=0
|
COUNT=0
|
||||||
ELASTICSEARCH_CONNECTED="no"
|
ELASTICSEARCH_CONNECTED="no"
|
||||||
while [[ "$COUNT" -le 30 ]]; do
|
while [[ "$COUNT" -le 30 ]]; do
|
||||||
curl -k --output /dev/null --silent --head --fail -L https://{{ ES }}:9200
|
{{ ELASTICCURL }} -k --output /dev/null --silent --head --fail -L https://{{ ES }}:9200
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
ELASTICSEARCH_CONNECTED="yes"
|
ELASTICSEARCH_CONNECTED="yes"
|
||||||
echo "connected!"
|
echo "connected!"
|
||||||
@@ -26,6 +26,6 @@ if [ "$ELASTICSEARCH_CONNECTED" == "no" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Applying cross cluster search config..."
|
echo "Applying cross cluster search config..."
|
||||||
curl -s -k -XPUT -L https://{{ ES }}:9200/_cluster/settings \
|
{{ ELASTICCURL }} -s -k -XPUT -L https://{{ ES }}:9200/_cluster/settings \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
-d "{\"persistent\": {\"search\": {\"remote\": {\"{{ grains.host }}\": {\"seeds\": [\"127.0.0.1:9300\"]}}}}}"
|
-d "{\"persistent\": {\"search\": {\"remote\": {\"{{ grains.host }}\": {\"seeds\": [\"127.0.0.1:9300\"]}}}}}"
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
{% from 'allowed_states.map.jinja' import allowed_states %}
|
{% from 'allowed_states.map.jinja' import allowed_states %}
|
||||||
|
|
||||||
{% if sls in allowed_states %}
|
{% if sls in allowed_states %}
|
||||||
|
{% set ELASTICUSER = salt['pillar.get']('elasticsearch:auth:user', '' ) %}
|
||||||
|
{% set ELASTICPASS = salt['pillar.get']('elasticsearch:auth:pass', '' ) %}
|
||||||
|
|
||||||
# This state is for checking things
|
# This state is for checking things
|
||||||
{% if grains['role'] in ['so-manager', 'so-managersearch', 'so-standalone'] %}
|
{% if grains['role'] in ['so-manager', 'so-managersearch', 'so-standalone'] %}
|
||||||
# Make sure Cross Cluster is good. Will need some logic once we have hot/warm
|
# Make sure Cross Cluster is good. Will need some logic once we have hot/warm
|
||||||
crossclusterson:
|
crossclusterson:
|
||||||
cmd.script:
|
cmd.script:
|
||||||
@@ -11,9 +14,15 @@ crossclusterson:
|
|||||||
- runas: socore
|
- runas: socore
|
||||||
- source: salt://utility/bin/crossthestreams
|
- source: salt://utility/bin/crossthestreams
|
||||||
- template: jinja
|
- template: jinja
|
||||||
|
- defaults:
|
||||||
|
ELASTICCURL: "curl"
|
||||||
|
{% if salt['pillar.get']('elasticsearch:auth_enabled', False) %}
|
||||||
|
- context:
|
||||||
|
ELASTICCURL: "curl --user {{ELASTICUSER}}:{{ELASTICPASS}}"
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if grains['role'] in ['so-eval', 'so-import'] %}
|
{% if grains['role'] in ['so-eval', 'so-import'] %}
|
||||||
fixsearch:
|
fixsearch:
|
||||||
cmd.script:
|
cmd.script:
|
||||||
- shell: /bin/bash
|
- shell: /bin/bash
|
||||||
@@ -21,7 +30,13 @@ fixsearch:
|
|||||||
- runas: socore
|
- runas: socore
|
||||||
- source: salt://utility/bin/eval
|
- source: salt://utility/bin/eval
|
||||||
- template: jinja
|
- template: jinja
|
||||||
{% endif %}
|
- defaults:
|
||||||
|
ELASTICCURL: "curl"
|
||||||
|
{% if salt['pillar.get']('elasticsearch:auth_enabled', False) %}
|
||||||
|
- context:
|
||||||
|
ELASTICCURL: "curl --user {{ELASTICUSER}}:{{ELASTICPASS}}"
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user