mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2025-12-06 17:22:49 +01:00
update mine and highstate minion when added
This commit is contained in:
@@ -407,11 +407,9 @@ function update_logstash_outputs() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function updateMine() {
|
function updateMine() {
|
||||||
salt "$MINION_ID" mine.send network.ip_addrs interface="$MNIC"
|
retry 10 2 "salt '$MINION_ID' mine.update" True
|
||||||
}
|
|
||||||
function apply_ES_state() {
|
|
||||||
salt-call state.apply elasticsearch concurrent=True
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function createEVAL() {
|
function createEVAL() {
|
||||||
is_pcaplimit=true
|
is_pcaplimit=true
|
||||||
add_elasticsearch_to_minion
|
add_elasticsearch_to_minion
|
||||||
@@ -547,8 +545,6 @@ function createSEARCHNODE() {
|
|||||||
add_elasticsearch_to_minion
|
add_elasticsearch_to_minion
|
||||||
add_logstash_to_minion
|
add_logstash_to_minion
|
||||||
add_telegraf_to_minion
|
add_telegraf_to_minion
|
||||||
updateMine
|
|
||||||
apply_ES_state
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function createRECEIVER() {
|
function createRECEIVER() {
|
||||||
@@ -563,6 +559,19 @@ function createDESKTOP() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function testConnection() {
|
function testConnection() {
|
||||||
|
# the minion should be trying to auth every 10 seconds so 15 seconds should be more than enough time to see this in the log
|
||||||
|
# this retry was put in because it is possible that a minion is attempted to be pinged before it has authenticated and connected to the Salt master
|
||||||
|
# causing the first ping to fail and typically wouldn't be successful until the second ping
|
||||||
|
# this check may pass without the minion being authenticated if it was previously connected and the line exists in the log
|
||||||
|
retry 15 1 "grep 'Authentication accepted from $MINION_ID' /opt/so/log/salt/master"
|
||||||
|
local retauth=$?
|
||||||
|
if [[ $retauth != 0 ]]; then
|
||||||
|
echo "The Minion did not authenticate with the Salt master in the allotted time"
|
||||||
|
echo "Deleting the key"
|
||||||
|
deleteminion
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
retry 15 3 "salt '$MINION_ID' test.ping" True
|
retry 15 3 "salt '$MINION_ID' test.ping" True
|
||||||
local ret=$?
|
local ret=$?
|
||||||
if [[ $ret != 0 ]]; then
|
if [[ $ret != 0 ]]; then
|
||||||
@@ -582,9 +591,9 @@ if [[ "$OPERATION" = 'delete' ]]; then
|
|||||||
deleteminion
|
deleteminion
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$OPERATION" = 'add' || "$OPERATION" = 'setup' ]]; then
|
if [[ "$OPERATION" == 'add' || "$OPERATION" == 'setup' ]]; then
|
||||||
# Skip this if its setup
|
# Skip this if its setup
|
||||||
if [ $OPERATION != 'setup' ]; then
|
if [[ $OPERATION == 'add' ]]; then
|
||||||
# Accept the salt key
|
# Accept the salt key
|
||||||
acceptminion
|
acceptminion
|
||||||
# Test to see if the minion was accepted
|
# Test to see if the minion was accepted
|
||||||
@@ -605,8 +614,18 @@ if [[ "$OPERATION" = 'add' || "$OPERATION" = 'setup' ]]; then
|
|||||||
else
|
else
|
||||||
add_sensoroni_to_minion
|
add_sensoroni_to_minion
|
||||||
fi
|
fi
|
||||||
|
|
||||||
create$NODETYPE
|
create$NODETYPE
|
||||||
echo "Minion file created for $MINION_ID"
|
echo "Minion file created for $MINION_ID"
|
||||||
|
|
||||||
|
if [[ "$OPERATION" == 'add' ]]; then
|
||||||
|
# tell the minion to populate the mine with data from mine_functions which is populated during setup
|
||||||
|
# this only needs to happen on non managers since they handle this during setup
|
||||||
|
# and they need to wait for ca creation to update the mine
|
||||||
|
updateMine
|
||||||
|
# run this async so the cli doesn't wait for a return
|
||||||
|
salt "$MINION_ID" state.highstate --async
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$OPERATION" = 'test' ]]; then
|
if [[ "$OPERATION" = 'test' ]]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user