diff --git a/setup/so-functions b/setup/so-functions index 3cd665076..a7afdbaa3 100755 --- a/setup/so-functions +++ b/setup/so-functions @@ -1701,6 +1701,24 @@ remove_package() { fi } +ensure_pyyaml() { + title "Ensuring python3-pyyaml is installed" + if rpm -q python3-pyyaml >/dev/null 2>&1; then + info "python3-pyyaml already installed" + return 0 + fi + info "python3-pyyaml not found, attempting to install" + set -o pipefail + dnf -y install python3-pyyaml 2>&1 | tee -a "$setup_log" + local result=$? + set +o pipefail + if [[ $result -ne 0 ]] || ! rpm -q python3-pyyaml >/dev/null 2>&1; then + error "Failed to install python3-pyyaml (exit=$result)" + fail_setup + fi + info "python3-pyyaml installed successfully" +} + # When updating the salt version, also update the version in securityonion-builds/images/iso-task/Dockerfile and salt/salt/master.defaults.yaml and salt/salt/minion.defaults.yaml # CAUTION! SALT VERSION UDDATES - READ BELOW # When updating the salt version, also update the version in: diff --git a/setup/so-setup b/setup/so-setup index 7875b9c99..6c77e781c 100755 --- a/setup/so-setup +++ b/setup/so-setup @@ -66,6 +66,9 @@ set_timezone # Let's see what OS we are dealing with here detect_os +# Ensure python3-pyyaml is available before any code that may need so-yaml/PyYAML +ensure_pyyaml + # Check to see if this is the setup type of "desktop". is_desktop=