sync in background

This commit is contained in:
Jason Ertel
2022-09-27 09:24:34 -04:00
parent 8e175b2d3f
commit 556ddc2ee4
2 changed files with 10 additions and 6 deletions

View File

@@ -370,9 +370,9 @@ function syncElastic() {
mv "${rolesTmpFile}" "${elasticRolesFile}"
if [[ -z "$SKIP_STATE_APPLY" ]]; then
echo "Elastic state will be re-applied to affected minions. This may take several minutes..."
echo "Elastic state will be re-applied to affected minions. This will run in the background and may take several minutes to complete."
echo "Applying elastic state to elastic minions at $(date)" >> /opt/so/log/soc/sync.log 2>&1
salt -C 'G@role:so-standalone or G@role:so-eval or G@role:so-import or G@role:so-manager or G@role:so-managersearch or G@role:so-searchnode or G@role:so-heavynode' state.apply elasticsearch queue=True >> /opt/so/log/soc/sync.log 2>&1
salt --async -C 'G@role:so-standalone or G@role:so-eval or G@role:so-import or G@role:so-manager or G@role:so-managersearch or G@role:so-searchnode or G@role:so-heavynode' state.apply elasticsearch queue=True >> /opt/so/log/soc/sync.log 2>&1
fi
else
echo "Newly generated users/roles files are incomplete; aborting."

View File

@@ -120,17 +120,21 @@ function manage_user() {
function manage_salt() {
request=$1
op=$(echo "$request" | jq -r .operation)
minion=$(echo "$request" | jq -r .minion)
if [[ -s $minion ]]; then
minion=$(cat /etc/salt/minion | grep "id:" | awk '{print $2}')
fi
case "$op" in
state)
log "Performing '$op' for '$state'"
log "Performing '$op' for '$state' on minion '$minion'"
state=$(echo "$request" | jq -r .state)
response=$(salt '*' state.apply "$state" queue=True)
response=$(salt --async $minion state.apply "$state" queue=True)
exit_code=$?
;;
highstate)
log "Performing '$op'"
response=$(salt '*' state.highstate queue=True)
log "Performing '$op' on minion '$minion'"
response=$(salt --async $minion state.highstate queue=True)
exit_code=$?
;;
*)