From ae86c99531a2677ab96c3597003d1ffee04d8082 Mon Sep 17 00:00:00 2001 From: fcaffieri Date: Fri, 27 Dec 2024 12:56:50 -0300 Subject: [PATCH 01/21] Add implementation of errors handling in workflow --- ...est_installation_assistant_distributed.yml | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) diff --git a/.github/workflows/Test_installation_assistant_distributed.yml b/.github/workflows/Test_installation_assistant_distributed.yml index 9dd4e2b..71b40c5 100644 --- a/.github/workflows/Test_installation_assistant_distributed.yml +++ b/.github/workflows/Test_installation_assistant_distributed.yml @@ -209,7 +209,10 @@ jobs: cat $inventory_common >> $inventory_file - name: Execute provision playbook + id: provision_instance + if: success() && steps.allocator_instance.outcome == 'success' run: | + set +e INSTALL_DEPS=true INSTALL_PYTHON=true INSTALL_PIP_DEPS=true @@ -224,34 +227,54 @@ jobs: -e "install_python=$INSTALL_PYTHON" \ -e "install_pip_deps=$INSTALL_PIP_DEPS" \ "${{ inputs.VERBOSITY }}" + EXIT_CODE=$? + echo "provision_instance=$EXIT_CODE" >> $GITHUB_OUTPUT - name: Execute certificates generation playbook + id: generate_certificates + if: success() && steps.provision_instance.outcome == 'success' run: | + set +e ANSIBLE_STDOUT_CALLBACK=$ANSIBLE_CALLBACK ansible-playbook .github/workflows/ansible-playbooks/distributed_generate_certificates.yml \ -i $ALLOCATOR_PATH/inventory \ -e "resources_path=$RESOURCES_PATH" \ "${{ inputs.VERBOSITY }}" + EXIT_CODE=$? + echo "generate_certificates=$EXIT_CODE" >> $GITHUB_OUTPUT - name: Copy certificates to nodes + id: copy_certificates + if: success() && steps.generate_certificates.outcome == 'success' run: | + set +e ANSIBLE_STDOUT_CALLBACK=$ANSIBLE_CALLBACK ansible-playbook .github/workflows/ansible-playbooks/distributed_copy_certificates.yml \ -i $ALLOCATOR_PATH/inventory \ -l indexers \ -e "tmp_path=$TMP_PATH" \ -e "resources_path=$RESOURCES_PATH" \ "${{ inputs.VERBOSITY }}" + EXIT_CODE=$? + echo "copy_certificates=$EXIT_CODE" >> $GITHUB_OUTPUT - name: Execute indexer installation playbook + id: install_indexer + if: success() && steps.copy_certificates.outcome == 'success' run: | + set +e ANSIBLE_STDOUT_CALLBACK=$ANSIBLE_CALLBACK ansible-playbook .github/workflows/ansible-playbooks/distributed_install_indexer.yml \ -i $ALLOCATOR_PATH/inventory \ -l indexers \ -e "tmp_path=$TMP_PATH" \ -e "pkg_repository=$PKG_REPOSITORY" \ "${{ inputs.VERBOSITY }}" + EXIT_CODE=$? + echo "install_indexer=$EXIT_CODE" >> $GITHUB_OUTPUT - name: Execute indexer cluster start playbook + id: start_indexer + if: success() && steps.install_indexer.outcome == 'success' run: | + set +e INDEXER_ADMIN_PASSWORD="admin" ANSIBLE_STDOUT_CALLBACK=$ANSIBLE_CALLBACK ansible-playbook .github/workflows/ansible-playbooks/distributed_start_indexer_cluster.yml \ -i $ALLOCATOR_PATH/inventory \ @@ -259,33 +282,50 @@ jobs: -e "tmp_path=$TMP_PATH" \ -e "pkg_repository=$PKG_REPOSITORY" \ "${{ inputs.VERBOSITY }}" + EXIT_CODE=$? + echo "start_indexer=$EXIT_CODE" >> $GITHUB_OUTPUT - name: Execute server installation playbook + id: install_server + if: success() && steps.start_indexer.outcome == 'success' run: | + set +e ANSIBLE_STDOUT_CALLBACK=$ANSIBLE_CALLBACK ansible-playbook .github/workflows/ansible-playbooks/distributed_install_wazuh.yml \ -i $ALLOCATOR_PATH/inventory \ -l managers \ -e "tmp_path=$TMP_PATH" \ -e "pkg_repository=$PKG_REPOSITORY" \ "${{ inputs.VERBOSITY }}" + EXIT_CODE=$? + echo "install_server=$EXIT_CODE" >> $GITHUB_OUTPUT - name: Execute dashboard installation playbook + id: install_dashboard + if: success() && steps.install_server.outcome == 'success' run: | + set +e ANSIBLE_STDOUT_CALLBACK=$ANSIBLE_CALLBACK ansible-playbook .github/workflows/ansible-playbooks/distributed_install_dashboard.yml \ -i $ALLOCATOR_PATH/inventory \ -l dashboards \ -e "tmp_path=$TMP_PATH" \ -e "pkg_repository=$PKG_REPOSITORY" \ "${{ inputs.VERBOSITY }}" + EXIT_CODE=$? + echo "install_dashboard=$EXIT_CODE" >> $GITHUB_OUTPUT - name: Execute Python test playbook + id: execute_test + if: success() && steps.install_dashboard.outcome == 'success' run: | + set +e ANSIBLE_STDOUT_CALLBACK=$ANSIBLE_CALLBACK ansible-playbook .github/workflows/ansible-playbooks/distributed_tests.yml \ -i $ALLOCATOR_PATH/inventory \ -l managers \ -e "tmp_path=$TMP_PATH" \ -e "test_name=$TEST_NAME" \ "${{ inputs.VERBOSITY }}" + EXIT_CODE=$? + echo "execute_test=$EXIT_CODE" >> $GITHUB_OUTPUT - name: Compress Allocator VM directory id: compress_allocator_files @@ -321,3 +361,58 @@ jobs: # Wait for all deletion tasks to complete wait + - name: Set final workflow status + if: always() + shell: bash + run: | + PROVISION_INSTANCE="${{ steps.provision_instance.outputs.provision_instance }}" + GENERATE_CERTIFICATES="${{ steps.generate_certificatesinstall.outputs.generate_certificates }}" + COPY_CERTIFICATES="${{ steps.copy_certificates.outputs.copy_certificates }}" + INSTALL_INDEXER="${{ steps.install_indexer.outputs.install_indexer }}" + START_INDEXER="${{ steps.start_indexer.outputs.start_indexer }}" + INSTALL_SERVER="${{ steps.install_server.outputs.install_server }}" + INSTALL_DASHBOARD="${{ steps.install_dashboard-install.outputs.install_dashboard }}" + EXECUTE_TEST="${{ steps.execute_test.outputs.execute_test }}" + + if [ "$PROVISION_INSTANCE" != "0" ] ; then + echo "::error :: Failed provisioning instances" + exit 1 + fi + + if [ "$GENERATE_CERTIFICATES" != "0" ] ; then + echo "::error :: Failed generating certificates" + exit 1 + fi + + if [ "$COPY_CERTIFICATES" != "0" ] ; then + echo "::error :: Failed copy certificates" + exit 1 + fi + + if [ "$INSTALL_INDEXER" != "0" ] ; then + echo "::error :: Failed installing Wazuh indexer" + exit 1 + fi + + if [ "$START_INDEXER" != "0" ] ; then + echo "::error :: Failed starting Wazuh indexer" + exit 1 + fi + + if [ "$INSTALL_SERVER" != "0" ] ; then + echo "::error :: Failed installing Wazuh server" + exit 1 + fi + + if [ "$INSTALL_DASHBOARD" != "0" ] ; then + echo "::error :: Failed installing Wazuh dashboard" + exit 1 + fi + + if [ "$EXECUTE_TEST" != "0" ]; then + echo "::warning ::Installation had issues but tests passed" + exit 0 + fi + + echo "All steps completed successfully" + exit 0 From 006771cb2919af2015dca110c126f0045bce4e25 Mon Sep 17 00:00:00 2001 From: fcaffieri Date: Fri, 27 Dec 2024 13:08:52 -0300 Subject: [PATCH 02/21] Add validation to fail if error found --- ...est_installation_assistant_distributed.yml | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.github/workflows/Test_installation_assistant_distributed.yml b/.github/workflows/Test_installation_assistant_distributed.yml index 71b40c5..6a62e01 100644 --- a/.github/workflows/Test_installation_assistant_distributed.yml +++ b/.github/workflows/Test_installation_assistant_distributed.yml @@ -229,6 +229,9 @@ jobs: "${{ inputs.VERBOSITY }}" EXIT_CODE=$? echo "provision_instance=$EXIT_CODE" >> $GITHUB_OUTPUT + if [ $EXIT_CODE != 0 ]; then + exit 1 + fi - name: Execute certificates generation playbook id: generate_certificates @@ -241,6 +244,9 @@ jobs: "${{ inputs.VERBOSITY }}" EXIT_CODE=$? echo "generate_certificates=$EXIT_CODE" >> $GITHUB_OUTPUT + if [ $EXIT_CODE != 0 ]; then + exit 1 + fi - name: Copy certificates to nodes id: copy_certificates @@ -255,6 +261,9 @@ jobs: "${{ inputs.VERBOSITY }}" EXIT_CODE=$? echo "copy_certificates=$EXIT_CODE" >> $GITHUB_OUTPUT + if [ $EXIT_CODE != 0 ]; then + exit 1 + fi - name: Execute indexer installation playbook id: install_indexer @@ -269,6 +278,9 @@ jobs: "${{ inputs.VERBOSITY }}" EXIT_CODE=$? echo "install_indexer=$EXIT_CODE" >> $GITHUB_OUTPUT + if [ $EXIT_CODE != 0 ]; then + exit 1 + fi - name: Execute indexer cluster start playbook id: start_indexer @@ -284,6 +296,9 @@ jobs: "${{ inputs.VERBOSITY }}" EXIT_CODE=$? echo "start_indexer=$EXIT_CODE" >> $GITHUB_OUTPUT + if [ $EXIT_CODE != 0 ]; then + exit 1 + fi - name: Execute server installation playbook id: install_server @@ -298,6 +313,9 @@ jobs: "${{ inputs.VERBOSITY }}" EXIT_CODE=$? echo "install_server=$EXIT_CODE" >> $GITHUB_OUTPUT + if [ $EXIT_CODE != 0 ]; then + exit 1 + fi - name: Execute dashboard installation playbook id: install_dashboard @@ -312,6 +330,9 @@ jobs: "${{ inputs.VERBOSITY }}" EXIT_CODE=$? echo "install_dashboard=$EXIT_CODE" >> $GITHUB_OUTPUT + if [ $EXIT_CODE != 0 ]; then + exit 1 + fi - name: Execute Python test playbook id: execute_test From 41408e9cbc88584622e7f5c7558a55f69b69c6e7 Mon Sep 17 00:00:00 2001 From: fcaffieri Date: Fri, 27 Dec 2024 13:21:43 -0300 Subject: [PATCH 03/21] Fix genera_certificates variable in status --- .github/workflows/Test_installation_assistant_distributed.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/Test_installation_assistant_distributed.yml b/.github/workflows/Test_installation_assistant_distributed.yml index 6a62e01..6855c8d 100644 --- a/.github/workflows/Test_installation_assistant_distributed.yml +++ b/.github/workflows/Test_installation_assistant_distributed.yml @@ -387,12 +387,12 @@ jobs: shell: bash run: | PROVISION_INSTANCE="${{ steps.provision_instance.outputs.provision_instance }}" - GENERATE_CERTIFICATES="${{ steps.generate_certificatesinstall.outputs.generate_certificates }}" + GENERATE_CERTIFICATES="${{ steps.generate_certificates.outputs.generate_certificates }}" COPY_CERTIFICATES="${{ steps.copy_certificates.outputs.copy_certificates }}" INSTALL_INDEXER="${{ steps.install_indexer.outputs.install_indexer }}" START_INDEXER="${{ steps.start_indexer.outputs.start_indexer }}" INSTALL_SERVER="${{ steps.install_server.outputs.install_server }}" - INSTALL_DASHBOARD="${{ steps.install_dashboard-install.outputs.install_dashboard }}" + INSTALL_DASHBOARD="${{ steps.install_dashboard.outputs.install_dashboard }}" EXECUTE_TEST="${{ steps.execute_test.outputs.execute_test }}" if [ "$PROVISION_INSTANCE" != "0" ] ; then From 830d47f111e085980877efb64e5072e6374a69ce Mon Sep 17 00:00:00 2001 From: fcaffieri Date: Fri, 27 Dec 2024 13:29:07 -0300 Subject: [PATCH 04/21] Change version to test --- install_functions/installVariables.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install_functions/installVariables.sh b/install_functions/installVariables.sh index dfef882..f22f93e 100644 --- a/install_functions/installVariables.sh +++ b/install_functions/installVariables.sh @@ -7,8 +7,8 @@ # Foundation. ## Package vars -readonly wazuh_major="5.0" -readonly wazuh_version="5.0.0" +readonly wazuh_major="4.9" +readonly wazuh_version="4.9.2" readonly filebeat_version="7.10.2" readonly wazuh_install_vesion="0.1" source_branch="v${wazuh_version}" From b95556c51316dba84beac5e601272080c171922b Mon Sep 17 00:00:00 2001 From: fcaffieri Date: Fri, 27 Dec 2024 13:36:06 -0300 Subject: [PATCH 05/21] Add parameter to install dependencies into indexer test --- .../workflows/ansible-playbooks/distributed_install_indexer.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ansible-playbooks/distributed_install_indexer.yml b/.github/workflows/ansible-playbooks/distributed_install_indexer.yml index c5736da..f8258dc 100644 --- a/.github/workflows/ansible-playbooks/distributed_install_indexer.yml +++ b/.github/workflows/ansible-playbooks/distributed_install_indexer.yml @@ -9,6 +9,6 @@ tasks: - name: Install Wazuh indexer - command: "bash {{ tmp_path }}/wazuh-install.sh -wi {{ inventory_hostname }} -v -d {{ pkg_repository }}" + command: "bash {{ tmp_path }}/wazuh-install.sh -wi {{ inventory_hostname }} -v -d {{ pkg_repository }} -id" register: indexer From ea20baa091e4369e3bd37cece43bde532fa458fa Mon Sep 17 00:00:00 2001 From: fcaffieri Date: Fri, 27 Dec 2024 13:48:28 -0300 Subject: [PATCH 06/21] Add parameter to install dependencies into server and dashboard test --- .../ansible-playbooks/distributed_install_dashboard.yml | 2 +- .../ansible-playbooks/distributed_install_wazuh.yml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ansible-playbooks/distributed_install_dashboard.yml b/.github/workflows/ansible-playbooks/distributed_install_dashboard.yml index fb04278..a974752 100644 --- a/.github/workflows/ansible-playbooks/distributed_install_dashboard.yml +++ b/.github/workflows/ansible-playbooks/distributed_install_dashboard.yml @@ -9,7 +9,7 @@ tasks: - name: Install Wazuh dashboard - command: "bash wazuh-install.sh -wd {{ inventory_hostname }} -v -d {{ pkg_repository }}" + command: "bash wazuh-install.sh -wd {{ inventory_hostname }} -v -d {{ pkg_repository }} -id" args: chdir: "{{ tmp_path }}" register: dashboard diff --git a/.github/workflows/ansible-playbooks/distributed_install_wazuh.yml b/.github/workflows/ansible-playbooks/distributed_install_wazuh.yml index ac5cfe1..1639bb4 100644 --- a/.github/workflows/ansible-playbooks/distributed_install_wazuh.yml +++ b/.github/workflows/ansible-playbooks/distributed_install_wazuh.yml @@ -11,7 +11,7 @@ tasks: - name: Install Wazuh server on master - command: "bash {{ tmp_path }}/wazuh-install.sh -ws {{ inventory_hostname }} -v -d {{ pkg_repository }}" + command: "bash {{ tmp_path }}/wazuh-install.sh -ws {{ inventory_hostname }} -v -d {{ pkg_repository }} -id" register: wazuh when: hostvars[inventory_hostname].manager_type == 'master' @@ -31,5 +31,5 @@ command: "bash {{ tmp_path }}/wazuh-install.sh -ws {{ inventory_hostname }} -v -d {{ pkg_repository }}" register: wazuh when: hostvars[inventory_hostname].manager_type == 'worker' - - + + From fc99cb16ae035f1a8eece3252887cba660d5272b Mon Sep 17 00:00:00 2001 From: fcaffieri Date: Fri, 27 Dec 2024 13:57:02 -0300 Subject: [PATCH 07/21] Add parameter to install dependencies into server workers test --- .../workflows/ansible-playbooks/distributed_install_wazuh.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ansible-playbooks/distributed_install_wazuh.yml b/.github/workflows/ansible-playbooks/distributed_install_wazuh.yml index 1639bb4..a8af601 100644 --- a/.github/workflows/ansible-playbooks/distributed_install_wazuh.yml +++ b/.github/workflows/ansible-playbooks/distributed_install_wazuh.yml @@ -28,7 +28,7 @@ poll: 5 - name: Install Wazuh server (Workers) - command: "bash {{ tmp_path }}/wazuh-install.sh -ws {{ inventory_hostname }} -v -d {{ pkg_repository }}" + command: "bash {{ tmp_path }}/wazuh-install.sh -ws {{ inventory_hostname }} -v -d {{ pkg_repository }} -id" register: wazuh when: hostvars[inventory_hostname].manager_type == 'worker' From 9e4049564d34da3cbe781223f3aed8c6de557e24 Mon Sep 17 00:00:00 2001 From: fcaffieri Date: Fri, 27 Dec 2024 14:23:51 -0300 Subject: [PATCH 08/21] Force to fail the test --- tests/install/test_installation_assistant.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/install/test_installation_assistant.py b/tests/install/test_installation_assistant.py index 0cdd7df..170d256 100644 --- a/tests/install/test_installation_assistant.py +++ b/tests/install/test_installation_assistant.py @@ -199,7 +199,7 @@ def test_check_indexer_cluster_status_not_yellow(): @pytest.mark.dashboard def test_check_dashboard_status(): - assert get_dashboard_status() == 200 + assert get_dashboard_status() == 201 @pytest.mark.wazuh def test_check_wazuh_api_status(): @@ -214,7 +214,7 @@ def test_check_log_errors(): "ERROR: Could not send message through the cluster after '10' attempts" ] - + with open('/var/ossec/logs/ossec.log', 'r') as f: for line in f.readlines(): if 'ERROR' in line: From 6a1acdf9b438683c752e6e35af0fc195d275a1d1 Mon Sep 17 00:00:00 2001 From: fcaffieri Date: Fri, 27 Dec 2024 15:53:28 -0300 Subject: [PATCH 09/21] Add handler error for aio test --- .../workflows/Test_installation_assistant.yml | 48 +++++++++++++++++++ ...est_installation_assistant_distributed.yml | 4 +- tests/install/test_installation_assistant.py | 2 +- 3 files changed, 51 insertions(+), 3 deletions(-) diff --git a/.github/workflows/Test_installation_assistant.yml b/.github/workflows/Test_installation_assistant.yml index 81e5178..a48c707 100644 --- a/.github/workflows/Test_installation_assistant.yml +++ b/.github/workflows/Test_installation_assistant.yml @@ -155,7 +155,10 @@ jobs: echo "$ansible_host ansible_port=$ansible_port ansible_user=$ansible_user ansible_ssh_private_key_file=$ansible_ssh_private_key_file ansible_ssh_common_args='$ansible_ssh_common_args'" >> $ALLOCATOR_PATH/inventory - name: Execute provision playbook + id: provision_instance + if: success() && steps.allocator_instance.outcome == 'success' run: | + set +e INSTALL_DEPS=true INSTALL_PYTHON=true INSTALL_PIP_DEPS=true @@ -170,9 +173,17 @@ jobs: -e "install_python=$INSTALL_PYTHON" \ -e "install_pip_deps=$INSTALL_PIP_DEPS" \ "${{ inputs.VERBOSITY }}" + EXIT_CODE=$? + echo "provision_instance=$EXIT_CODE" >> $GITHUB_OUTPUT + if [ $EXIT_CODE != 0 ]; then + exit 1 + fi - name: Execute AIO installation playbook + id: install_aio + if: success() && steps.provision_instance.outcome == 'success' run: | + set +e ansible-playbook .github/workflows/ansible-playbooks/aio.yml \ -i $ALLOCATOR_PATH/inventory \ -l all \ @@ -181,8 +192,15 @@ jobs: -e "test_name=$TEST_NAME" \ -e "pkg_repository=$PKG_REPOSITORY" \ "${{ inputs.VERBOSITY }}" + EXIT_CODE=$? + echo "install_aio=$EXIT_CODE" >> $GITHUB_OUTPUT + if [ $EXIT_CODE != 0 ]; then + exit 1 + fi - name: Execute Python test playbook + id: execute_test + if: success() && steps.install_dashboard.outcome == 'success' run: | TEST_NAME="test_installation_assistant" ansible-playbook .github/workflows/ansible-playbooks/aio_tests.yml \ @@ -192,6 +210,11 @@ jobs: -e "logs_path=$LOGS_PATH" \ -e "test_name=$TEST_NAME" \ "${{ inputs.VERBOSITY }}" + EXIT_CODE=$? + echo "execute_test=$EXIT_CODE" >> $GITHUB_OUTPUT + if [ $EXIT_CODE != 0 ]; then + exit 1 + fi - name: Compress Allocator VM directory id: compress_allocator_files @@ -210,3 +233,28 @@ jobs: if: always() && steps.allocator_instance.outcome == 'success' && inputs.DESTROY == true run: python3 wazuh-automation/deployability/modules/allocation/main.py --action delete --track-output $ALLOCATOR_PATH/track.yml + - name: Set final workflow status + if: always() + shell: bash + run: | + PROVISION_INSTANCE="${{ steps.provision_instance.outputs.provision_instance }}" + INSTALL_AIO="${{ steps.install_aio.outputs.install_aio }}" + EXECUTE_TEST="${{ steps.execute_test.outputs.execute_test }}" + + if [ "$PROVISION_INSTANCE" != "0" ] ; then + echo "::error :: Failed provisioning instances" + exit 1 + fi + + if [ "$INSTALL_AIO" != "0" ] ; then + echo "::error :: Failed installing wiht AIO" + exit 1 + fi + + if [ "$EXECUTE_TEST" != "0" ]; then + echo "::warning ::Test completed successfully but some errors detected" + exit 0 + fi + + echo "All test completed successfully" + exit 0 diff --git a/.github/workflows/Test_installation_assistant_distributed.yml b/.github/workflows/Test_installation_assistant_distributed.yml index 6855c8d..cfd389e 100644 --- a/.github/workflows/Test_installation_assistant_distributed.yml +++ b/.github/workflows/Test_installation_assistant_distributed.yml @@ -431,9 +431,9 @@ jobs: fi if [ "$EXECUTE_TEST" != "0" ]; then - echo "::warning ::Installation had issues but tests passed" + echo "::warning ::Test completed successfully but some errors detected" exit 0 fi - echo "All steps completed successfully" + echo "All test completed successfully" exit 0 diff --git a/tests/install/test_installation_assistant.py b/tests/install/test_installation_assistant.py index 170d256..365eed6 100644 --- a/tests/install/test_installation_assistant.py +++ b/tests/install/test_installation_assistant.py @@ -199,7 +199,7 @@ def test_check_indexer_cluster_status_not_yellow(): @pytest.mark.dashboard def test_check_dashboard_status(): - assert get_dashboard_status() == 201 + assert get_dashboard_status() == 200 @pytest.mark.wazuh def test_check_wazuh_api_status(): From 93a98efa875b34a6341e01348537cb71da3b023b Mon Sep 17 00:00:00 2001 From: fcaffieri Date: Fri, 27 Dec 2024 16:23:38 -0300 Subject: [PATCH 10/21] Fix installMain wrong method installCommon_installDependencies --- install_functions/installMain.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install_functions/installMain.sh b/install_functions/installMain.sh index 7b80503..d76882a 100755 --- a/install_functions/installMain.sh +++ b/install_functions/installMain.sh @@ -262,7 +262,7 @@ function main() { fi if [ -z "${uninstall}" ] && [ -z "${offline_install}" ]; then - installCommon_installCheckDependencies + installCommon_installDependencies elif [ -n "${offline_install}" ]; then offline_checkPrerequisites "wia_offline_dependencies" "${wia_offline_dependencies[@]}" fi From f6acf7f5074e23d0f71ca9baa9d9c89a8e63964c Mon Sep 17 00:00:00 2001 From: fcaffieri Date: Fri, 27 Dec 2024 17:06:05 -0300 Subject: [PATCH 11/21] Fix step validation on workflow --- .github/workflows/Test_installation_assistant.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Test_installation_assistant.yml b/.github/workflows/Test_installation_assistant.yml index a48c707..26347c0 100644 --- a/.github/workflows/Test_installation_assistant.yml +++ b/.github/workflows/Test_installation_assistant.yml @@ -200,7 +200,7 @@ jobs: - name: Execute Python test playbook id: execute_test - if: success() && steps.install_dashboard.outcome == 'success' + if: success() && steps.install_aio.outcome == 'success' run: | TEST_NAME="test_installation_assistant" ansible-playbook .github/workflows/ansible-playbooks/aio_tests.yml \ From ef4eced1e1a18bb4d1cc11b635baafc28aeff481 Mon Sep 17 00:00:00 2001 From: fcaffieri Date: Fri, 27 Dec 2024 17:27:10 -0300 Subject: [PATCH 12/21] Fix step validation on workflow --- .github/workflows/Test_installation_assistant.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/Test_installation_assistant.yml b/.github/workflows/Test_installation_assistant.yml index 26347c0..c517dad 100644 --- a/.github/workflows/Test_installation_assistant.yml +++ b/.github/workflows/Test_installation_assistant.yml @@ -193,10 +193,9 @@ jobs: -e "pkg_repository=$PKG_REPOSITORY" \ "${{ inputs.VERBOSITY }}" EXIT_CODE=$? + echo "$EXIT_CODE" echo "install_aio=$EXIT_CODE" >> $GITHUB_OUTPUT - if [ $EXIT_CODE != 0 ]; then - exit 1 - fi + - name: Execute Python test playbook id: execute_test From a749f766be078d7919f2f0a6f69926f87b5f42cc Mon Sep 17 00:00:00 2001 From: fcaffieri Date: Fri, 27 Dec 2024 17:32:22 -0300 Subject: [PATCH 13/21] Fix step validation on workflow --- .github/workflows/Test_installation_assistant.yml | 5 +++-- .github/workflows/ansible-playbooks/aio.yml | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/Test_installation_assistant.yml b/.github/workflows/Test_installation_assistant.yml index c517dad..26347c0 100644 --- a/.github/workflows/Test_installation_assistant.yml +++ b/.github/workflows/Test_installation_assistant.yml @@ -193,9 +193,10 @@ jobs: -e "pkg_repository=$PKG_REPOSITORY" \ "${{ inputs.VERBOSITY }}" EXIT_CODE=$? - echo "$EXIT_CODE" echo "install_aio=$EXIT_CODE" >> $GITHUB_OUTPUT - + if [ $EXIT_CODE != 0 ]; then + exit 1 + fi - name: Execute Python test playbook id: execute_test diff --git a/.github/workflows/ansible-playbooks/aio.yml b/.github/workflows/ansible-playbooks/aio.yml index 4acd184..a4980bc 100644 --- a/.github/workflows/ansible-playbooks/aio.yml +++ b/.github/workflows/ansible-playbooks/aio.yml @@ -9,7 +9,7 @@ tasks: - name: Test assistant AIO install - command: "bash {{ script_name }} -a -v -d {{ pkg_repository }}" + command: "bash {{ script_name }} -a -v -id -d {{ pkg_repository }}" args: chdir: "{{ script_path }}" register: install_results From 51db0647a2fe0d67b5226ae3c5972c0c8f0b8e32 Mon Sep 17 00:00:00 2001 From: fcaffieri Date: Fri, 27 Dec 2024 17:50:00 -0300 Subject: [PATCH 14/21] Force to fail the test --- tests/install/test_installation_assistant.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/install/test_installation_assistant.py b/tests/install/test_installation_assistant.py index 365eed6..170d256 100644 --- a/tests/install/test_installation_assistant.py +++ b/tests/install/test_installation_assistant.py @@ -199,7 +199,7 @@ def test_check_indexer_cluster_status_not_yellow(): @pytest.mark.dashboard def test_check_dashboard_status(): - assert get_dashboard_status() == 200 + assert get_dashboard_status() == 201 @pytest.mark.wazuh def test_check_wazuh_api_status(): From b931d64934f4d1982d1f7bfd21c4fcb19f5b73a6 Mon Sep 17 00:00:00 2001 From: fcaffieri Date: Fri, 27 Dec 2024 18:03:04 -0300 Subject: [PATCH 15/21] Force to fail the test --- .github/workflows/Test_installation_assistant.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/Test_installation_assistant.yml b/.github/workflows/Test_installation_assistant.yml index 26347c0..b5d1134 100644 --- a/.github/workflows/Test_installation_assistant.yml +++ b/.github/workflows/Test_installation_assistant.yml @@ -194,9 +194,6 @@ jobs: "${{ inputs.VERBOSITY }}" EXIT_CODE=$? echo "install_aio=$EXIT_CODE" >> $GITHUB_OUTPUT - if [ $EXIT_CODE != 0 ]; then - exit 1 - fi - name: Execute Python test playbook id: execute_test From 26100445776ea32d81ac99739d7597a01097d87e Mon Sep 17 00:00:00 2001 From: fcaffieri Date: Mon, 30 Dec 2024 10:25:11 -0300 Subject: [PATCH 16/21] Fix not fail playbook test --- .github/workflows/Test_installation_assistant.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/Test_installation_assistant.yml b/.github/workflows/Test_installation_assistant.yml index b5d1134..d9dedfe 100644 --- a/.github/workflows/Test_installation_assistant.yml +++ b/.github/workflows/Test_installation_assistant.yml @@ -194,6 +194,9 @@ jobs: "${{ inputs.VERBOSITY }}" EXIT_CODE=$? echo "install_aio=$EXIT_CODE" >> $GITHUB_OUTPUT + if [ $EXIT_CODE != 0 ]; then + exit 1 + fi - name: Execute Python test playbook id: execute_test @@ -209,9 +212,6 @@ jobs: "${{ inputs.VERBOSITY }}" EXIT_CODE=$? echo "execute_test=$EXIT_CODE" >> $GITHUB_OUTPUT - if [ $EXIT_CODE != 0 ]; then - exit 1 - fi - name: Compress Allocator VM directory id: compress_allocator_files From dc78302c83addd50b2690f0091d1a4388ad8093f Mon Sep 17 00:00:00 2001 From: fcaffieri Date: Mon, 30 Dec 2024 11:37:01 -0300 Subject: [PATCH 17/21] Fix not fail playbook test --- .github/workflows/Test_installation_assistant.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/Test_installation_assistant.yml b/.github/workflows/Test_installation_assistant.yml index d9dedfe..8c69f3e 100644 --- a/.github/workflows/Test_installation_assistant.yml +++ b/.github/workflows/Test_installation_assistant.yml @@ -212,6 +212,9 @@ jobs: "${{ inputs.VERBOSITY }}" EXIT_CODE=$? echo "execute_test=$EXIT_CODE" >> $GITHUB_OUTPUT + if [ $EXIT_CODE != 0 ]; then + exit 0 + fi - name: Compress Allocator VM directory id: compress_allocator_files From bef69fbc3e49df2f7c6c55216689094577d1ccd9 Mon Sep 17 00:00:00 2001 From: fcaffieri Date: Mon, 30 Dec 2024 11:58:39 -0300 Subject: [PATCH 18/21] Fix test step with set +e to avoid failures --- .github/workflows/Test_installation_assistant.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/Test_installation_assistant.yml b/.github/workflows/Test_installation_assistant.yml index 8c69f3e..85b9512 100644 --- a/.github/workflows/Test_installation_assistant.yml +++ b/.github/workflows/Test_installation_assistant.yml @@ -202,6 +202,7 @@ jobs: id: execute_test if: success() && steps.install_aio.outcome == 'success' run: | + set +e TEST_NAME="test_installation_assistant" ansible-playbook .github/workflows/ansible-playbooks/aio_tests.yml \ -i $ALLOCATOR_PATH/inventory \ @@ -212,9 +213,7 @@ jobs: "${{ inputs.VERBOSITY }}" EXIT_CODE=$? echo "execute_test=$EXIT_CODE" >> $GITHUB_OUTPUT - if [ $EXIT_CODE != 0 ]; then - exit 0 - fi + - name: Compress Allocator VM directory id: compress_allocator_files From f82b1f2906128eac2873a041b5f4bcfd4e6cd2c8 Mon Sep 17 00:00:00 2001 From: fcaffieri Date: Mon, 30 Dec 2024 12:28:35 -0300 Subject: [PATCH 19/21] Forced failure for tests is removed --- tests/install/test_installation_assistant.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/install/test_installation_assistant.py b/tests/install/test_installation_assistant.py index 170d256..365eed6 100644 --- a/tests/install/test_installation_assistant.py +++ b/tests/install/test_installation_assistant.py @@ -199,7 +199,7 @@ def test_check_indexer_cluster_status_not_yellow(): @pytest.mark.dashboard def test_check_dashboard_status(): - assert get_dashboard_status() == 201 + assert get_dashboard_status() == 200 @pytest.mark.wazuh def test_check_wazuh_api_status(): From 8e17c543e3ce7937d33c7bfdee0a1081ef629e2e Mon Sep 17 00:00:00 2001 From: fcaffieri Date: Mon, 30 Dec 2024 15:32:24 -0300 Subject: [PATCH 20/21] Set version 5.0 again --- install_functions/installVariables.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install_functions/installVariables.sh b/install_functions/installVariables.sh index f22f93e..dfef882 100644 --- a/install_functions/installVariables.sh +++ b/install_functions/installVariables.sh @@ -7,8 +7,8 @@ # Foundation. ## Package vars -readonly wazuh_major="4.9" -readonly wazuh_version="4.9.2" +readonly wazuh_major="5.0" +readonly wazuh_version="5.0.0" readonly filebeat_version="7.10.2" readonly wazuh_install_vesion="0.1" source_branch="v${wazuh_version}" From 2ce7d53f183576f3ecbe08d82e0aa35916f84df3 Mon Sep 17 00:00:00 2001 From: fcaffieri Date: Mon, 30 Dec 2024 16:57:32 -0300 Subject: [PATCH 21/21] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2105e4f..7dd62e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file. ### Added +- Improve asistant test completion status ([#188](https://github.com/wazuh/wazuh-installation-assistant/pull/188)) - Added available packages check before installation ([#80](https://github.com/wazuh/wazuh-installation-assistant/pull/80)) ### Changed