From c92dc580a2b119850b445f289b913f78a525746e Mon Sep 17 00:00:00 2001 From: reyesj2 <94730068+reyesj2@users.noreply.github.com> Date: Fri, 19 Sep 2025 13:17:52 -0500 Subject: [PATCH] centralize MINION_ROLE lookup_role --- salt/common/tools/sbin/so-common | 3 +-- salt/manager/tools/sbin/soup | 7 ++++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/salt/common/tools/sbin/so-common b/salt/common/tools/sbin/so-common index 203b54cd0..365852e63 100755 --- a/salt/common/tools/sbin/so-common +++ b/salt/common/tools/sbin/so-common @@ -441,8 +441,7 @@ lookup_grain() { lookup_role() { id=$(lookup_grain id) - pieces=($(echo $id | tr '_' ' ')) - echo ${pieces[1]} + echo "${id##*_}" } is_feature_enabled() { diff --git a/salt/manager/tools/sbin/soup b/salt/manager/tools/sbin/soup index 81e5b9c18..f324924cb 100755 --- a/salt/manager/tools/sbin/soup +++ b/salt/manager/tools/sbin/soup @@ -611,7 +611,7 @@ post_to_2.4.180() { post_to_2.4.190() { # Only need to update import / eval nodes - if [[ "${MINIONID##*_}" == "import" ]] || [[ "${MINIONID##*_}" == "eval" ]]; then + if [[ "$MINION_ROLE" == "import" ]] || [[ "$MINION_ROLE" == "eval" ]]; then update_import_fleet_output fi @@ -1387,6 +1387,7 @@ main() { fi set_minionid + MINION_ROLE=$(lookup_role) echo "Found that Security Onion $INSTALLEDVERSION is currently installed." echo "" if [[ $is_airgap -eq 0 ]]; then @@ -1429,7 +1430,7 @@ main() { if [ "$is_hotfix" == "true" ]; then echo "Applying $HOTFIXVERSION hotfix" # since we don't run the backup.config_backup state on import we wont snapshot previous version states and pillars - if [[ ! "${MINIONID##*_}" == "import" ]]; then + if [[ ! "$MINION_ROLE" == "import" ]]; then backup_old_states_pillars fi copy_new_files @@ -1492,7 +1493,7 @@ main() { fi # since we don't run the backup.config_backup state on import we wont snapshot previous version states and pillars - if [[ ! "${MINIONID##*_}" == "import" ]]; then + if [[ ! "$MINION_ROLE" == "import" ]]; then echo "" echo "Creating snapshots of default and local Salt states and pillars and saving to /nsm/backup/" backup_old_states_pillars