From 87a395340a991f200e0569284b4922dcb3cf6225 Mon Sep 17 00:00:00 2001 From: miguelfdez99 Date: Mon, 30 May 2022 14:15:56 +0200 Subject: [PATCH 1/2] Added check if indexer nodes are active before installing the dashboard --- .../install_functions/dashboard.sh | 67 ++++++++++++------- 1 file changed, 42 insertions(+), 25 deletions(-) diff --git a/unattended_installer/install_functions/dashboard.sh b/unattended_installer/install_functions/dashboard.sh index dce251e755..08a2ca1d3e 100644 --- a/unattended_installer/install_functions/dashboard.sh +++ b/unattended_installer/install_functions/dashboard.sh @@ -122,33 +122,9 @@ function dashboard_initialize() { if [ -z "${force}" ]; then flag="-e" fi - failed_nodes=() common_logger "${flag}" "Cannot connect to Wazuh dashboard." - - for i in "${!indexer_node_ips[@]}"; do - curl=$(curl -XGET https://${indexer_node_ips[i]}:9200/ -uadmin:${u_pass} -k -s) - exit_code=${PIPESTATUS[0]} - if [[ "${exit_code}" -eq "7" ]]; then - failed_connect=1 - failed_nodes+=("${indexer_node_names[i]}") - fi - if [ "${curl}" == "OpenSearch Security not initialized." ]; then - sec_not_initialized=1 - fi - done - if [ -n "${failed_connect}" ]; then - common_logger "${flag}" "Failed to connect with ${failed_nodes[*]}. Connection refused." - fi - - if [ -n "${sec_not_initialized}" ]; then - common_logger "${flag}" "Wazuh indexer security settings not initialized. Please run the installation assistant using -s|--start-cluster in one of the wazuh indexer nodes." - fi - if [ -z "${force}" ]; then - common_logger "If you want to install Wazuh dashboard without waiting for the Wazuh indexer cluster, use the -fd option" - installCommon_rollBack - exit 1 - else + if [ -n "${force}" ]; then common_logger -nl "--- Summary ---" common_logger -nl "When Wazuh dashboard is able to connect to your Wazuh indexer cluster, you can access the web interface https://${print_ip}\n User: admin\n Password: ${u_pass}" fi @@ -177,6 +153,47 @@ function dashboard_initializeAIO() { function dashboard_install() { + if [ "${#indexer_node_ips[@]}" -gt 0 ]; then + common_logger "Checking if Wazuh indexer nodes are active." + flag="-w" + if [ -z "${force}" ]; then + flag="-e" + fi + failed_nodes=() + for i in "${!indexer_node_ips[@]}"; do + curl=$(curl -XGET https://${indexer_node_ips[i]}:9200/ -uadmin:${u_pass} -k -s) + exit_code=${PIPESTATUS[0]} + if [[ "${exit_code}" -eq "7" ]]; then + failed_connect=1 + failed_nodes+=("${indexer_node_names[i]}") + fi + if [ "${curl}" == "OpenSearch Security not initialized." ]; then + sec_not_initialized=1 + fi + done + if [ -n "${failed_connect}" ]; then + common_logger "${flag}" "Failed to connect with ${failed_nodes[*]}. Connection refused." + if [ -z "${force}" ]; then + common_logger "If you want to install Wazuh dashboard without waiting for the Wazuh indexer cluster, use the -fd option" + installCommon_rollBack + exit 1 + else + common_logger -nl "When Wazuh dashboard is able to connect to your Wazuh indexer cluster, you can access the web interface, credentials will be provided at the end of installation." + fi + fi + + if [ -n "${sec_not_initialized}" ]; then + common_logger "${flag}" "Wazuh indexer security settings not initialized. Please run the installation assistant using -s|--start-cluster in one of the wazuh indexer nodes." + if [ -z "${force}" ]; then + common_logger "If you want to install Wazuh dashboard without waiting for the Wazuh indexer cluster, use the -fd option" + installCommon_rollBack + exit 1 + else + common_logger -nl "When Wazuh dashboard is able to connect to your Wazuh indexer cluster, you can access the web interface, credentials will be provided at the end of installation." + fi + fi + fi + common_logger "Starting Wazuh dashboard installation." if [ "${sys_type}" == "zypper" ]; then eval "zypper -n install wazuh-dashboard=${wazuh_version}-${dashboard_revision_rpm} ${debug}" From 473ac05eb6ee34ebf81a4d9ebaed3961b98a4af5 Mon Sep 17 00:00:00 2001 From: miguelfdez99 Date: Fri, 3 Jun 2022 09:16:04 +0200 Subject: [PATCH 2/2] Update test version --- tests/unattended/install/test_unattended.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unattended/install/test_unattended.py b/tests/unattended/install/test_unattended.py index f2258aa916..a9584be1f7 100644 --- a/tests/unattended/install/test_unattended.py +++ b/tests/unattended/install/test_unattended.py @@ -192,7 +192,7 @@ def test_check_log_errors(): for line in f.readlines(): if 'ERROR' in line: found_error = True - if get_wazuh_version() == 'v4.3.1': + if get_wazuh_version() == 'v4.3.2': if 'ERROR: Cluster error detected' in line or 'agent-upgrade: ERROR: (8123): There has been an error executing the request in the tasks manager.' in line: found_error = False else: @@ -216,7 +216,7 @@ def test_check_cluster_log_errors(): for line in f.readlines(): if 'ERROR' in line: found_error = True - if get_wazuh_version() == 'v4.3.1': + if get_wazuh_version() == 'v4.3.2': if 'Could not connect to master' in line or 'Worker node is not connected to master' in line or 'Connection reset by peer' in line: found_error = False else: