mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2025-12-06 09:12:45 +01:00
add wait_for_salt_minion to so-common
This commit is contained in:
@@ -152,15 +152,18 @@ check_salt_master_status() {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# this is only intended to be used to check the status of the minion
|
||||||
check_salt_minion_status() {
|
check_salt_minion_status() {
|
||||||
local timeout="${1:-5}"
|
local minion="$1"
|
||||||
echo "Checking if the salt minion will respond to jobs" >> "$setup_log" 2>&1
|
local timeout="${2:-5}"
|
||||||
salt "$MINION_ID" test.ping -t $timeout > /dev/null 2>&1
|
local logfile="${3:-'/dev/stdout'}"
|
||||||
|
echo "Checking if the salt minion will respond to jobs" >> "$logfile" 2>&1
|
||||||
|
salt "$minion" test.ping -t $timeout > /dev/null 2>&1
|
||||||
local status=$?
|
local status=$?
|
||||||
if [ $status -gt 0 ]; then
|
if [ $status -gt 0 ]; then
|
||||||
echo " Minion did not respond" >> "$setup_log" 2>&1
|
echo " Minion did not respond" >> "$logfile" 2>&1
|
||||||
else
|
else
|
||||||
echo " Received job response from salt minion" >> "$setup_log" 2>&1
|
echo " Received job response from salt minion" >> "$logfile" 2>&1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return $status
|
return $status
|
||||||
@@ -440,6 +443,24 @@ run_check_net_err() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wait_for_salt_minion() {
|
||||||
|
local minion="$1"
|
||||||
|
local timeout="${2:-5}"
|
||||||
|
local logfile="${3:-'/dev/stdout'}"
|
||||||
|
retry 60 5 "journalctl -u salt-minion.service | grep 'Minion is ready to receive requests'" >> "$logfile" 2>&1 || fail
|
||||||
|
local attempt=0
|
||||||
|
# each attempts would take about 15 seconds
|
||||||
|
local maxAttempts=20
|
||||||
|
until check_salt_minion_status "$minion" "$timeout" "$logfile"; do
|
||||||
|
attempt=$((attempt+1))
|
||||||
|
if [[ $attempt -gt $maxAttempts ]]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
sleep 10
|
||||||
|
done
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
salt_minion_count() {
|
salt_minion_count() {
|
||||||
local MINIONDIR="/opt/so/saltstack/local/pillar/minions"
|
local MINIONDIR="/opt/so/saltstack/local/pillar/minions"
|
||||||
MINIONCOUNT=$(ls -la $MINIONDIR/*.sls | grep -v adv_ | wc -l)
|
MINIONCOUNT=$(ls -la $MINIONDIR/*.sls | grep -v adv_ | wc -l)
|
||||||
|
|||||||
Reference in New Issue
Block a user