update feature error logging in so-minion

This commit is contained in:
m0duspwnens
2025-01-16 17:13:36 -05:00
parent 61f5614ac9
commit 2277c792b9

View File

@@ -224,9 +224,9 @@ function acceptminion() {
if [[ "$MINION_ID" == *"_hypervisor" ]]; then if [[ "$MINION_ID" == *"_hypervisor" ]]; then
FEATURES=$(/usr/sbin/so-yaml.py get /opt/so/saltstack/local/pillar/soc/license.sls features) FEATURES=$(/usr/sbin/so-yaml.py get /opt/so/saltstack/local/pillar/soc/license.sls features)
if [[ $? -ne 0 || ! "$FEATURES" =~ "hvn" ]]; then if [[ $? -ne 0 || ! "$FEATURES" =~ "hvn" ]]; then
error_msg="Cannot accept hypervisor minion - hvn feature not enabled in license" error_msg="Hypervisor nodes are a feature supported only for customers with a valid license.\n Contact Security Onion Solutions, LLC via our website at https://securityonionsolutions.com\n for more information about purchasing a license to enable this feature."
log "ERROR" "$error_msg" log "ERROR" "$error_msg"
echo "Error: $error_msg" echo -e "Error: $error_msg"
return 1 return 1
fi fi
fi fi
@@ -844,6 +844,13 @@ function createRECEIVER() {
function createHYPERVISOR() { function createHYPERVISOR() {
log "INFO" "Creating HYPERVISOR configuration for minion $MINION_ID" log "INFO" "Creating HYPERVISOR configuration for minion $MINION_ID"
FEATURES=$(/usr/sbin/so-yaml.py get /opt/so/saltstack/local/pillar/soc/license.sls features)
if [[ $? -ne 0 || ! "$FEATURES" =~ "hvn" ]]; then
error_msg="Hypervisor nodes are a feature supported only for customers with a valid license.\n Contact Security Onion Solutions, LLC via our website at https://securityonionsolutions.com\n for more information about purchasing a license to enable this feature."
log "ERROR" "$error_msg"
echo -e "Error: $error_msg"
return 1
fi
add_telegraf_to_minion || return 1 add_telegraf_to_minion || return 1
} }
@@ -915,6 +922,13 @@ function updateMineAndApplyStates() {
# We don't want a hypervisor node to highstate until the image is downloaded and built. This will be triggered from the setup_hypervisor runner # We don't want a hypervisor node to highstate until the image is downloaded and built. This will be triggered from the setup_hypervisor runner
if [[ "$NODETYPE" == "HYPERVISOR" ]]; then if [[ "$NODETYPE" == "HYPERVISOR" ]]; then
FEATURES=$(/usr/sbin/so-yaml.py get /opt/so/saltstack/local/pillar/soc/license.sls features)
if [[ $? -ne 0 || ! "$FEATURES" =~ "hvn" ]]; then
error_msg="Hypervisor nodes are a feature supported only for customers with a valid license.\n Contact Security Onion Solutions, LLC via our website at https://securityonionsolutions.com\n for more information about purchasing a license to enable this feature."
log "ERROR" "$error_msg"
echo -e "Error: $error_msg"
return 1
fi
log "INFO" "Skipping state application for hypervisor node" log "INFO" "Skipping state application for hypervisor node"
return 0 return 0
fi fi
@@ -999,6 +1013,13 @@ case "$OPERATION" in
"addVM") "addVM")
log "INFO" "Adding VM minion $MINION_ID" log "INFO" "Adding VM minion $MINION_ID"
FEATURES=$(/usr/sbin/so-yaml.py get /opt/so/saltstack/local/pillar/soc/license.sls features)
if [[ $? -ne 0 || ! "$FEATURES" =~ "hvn" ]]; then
error_msg="Hypervisor nodes are a feature supported only for customers with a valid license.\n Contact Security Onion Solutions, LLC via our website at https://securityonionsolutions.com\n for more information about purchasing a license to enable this feature."
log "ERROR" "$error_msg"
echo -e "Error: $error_msg"
exit 1
fi
setupMinionFiles || { setupMinionFiles || {
log "ERROR" "Failed to setup VM minion files for $MINION_ID" log "ERROR" "Failed to setup VM minion files for $MINION_ID"
exit 1 exit 1