Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a post-install validation for Wazuh manager and Filebeat in the WIA #3059

Merged
merged 7 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions unattended_installer/install_functions/filebeat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@
# License (version 2) as published by the FSF - Free Software
# Foundation.

function filebeat_checkService() {
common_logger "Checking Filebeat connection"

if filebeat test output | grep -q -i -w "ERROR"; then
common_logger -e "Filebeat connection Error."
eval "filebeat test output x ${debug}"
installCommon_rollBack
exit 1
else
common_logger "Filebeat connection successful"
fi
}

function filebeat_configure(){

common_logger -d "Configuring Filebeat."
Expand Down
4 changes: 4 additions & 0 deletions unattended_installer/install_functions/installMain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -368,10 +368,12 @@ function main() {
manager_startCluster
fi
installCommon_startService "wazuh-manager"
manager_checkService
filebeat_install
filebeat_configure
installCommon_changePasswords
installCommon_startService "filebeat"
filebeat_checkService
installCommon_removeWIADependencies
fi

Expand All @@ -388,9 +390,11 @@ function main() {
manager_install
manager_configure
installCommon_startService "wazuh-manager"
manager_checkService
filebeat_install
filebeat_configure
installCommon_startService "filebeat"
filebeat_checkService
common_logger "--- Wazuh dashboard ---"
dashboard_install
dashboard_configure
Expand Down
15 changes: 15 additions & 0 deletions unattended_installer/install_functions/manager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,21 @@ function manager_startCluster() {

}

function manager_checkService() {
common_logger "Checking Wazuh API connection"
eval "TOKEN=$(curl -k -s -X POST -u "wazuh-wui:wazuh-wui" https://127.0.0.1:55000/security/user/authenticate/run_as?raw=true -d '{"user_name":"wzread"}' -H "content-type:application/json")"
wm_error=$(curl -k -s -X GET "https://127.0.0.1:55000/agents/outdated?pretty=true" -H "Authorization: Bearer ${TOKEN}")

if [[ ${wm_error,,} = '"error": 0' ]]; then
common_logger "Wazuh API connection successful"
else
common_logger -e "Wazuh API connection Error. $wm_error"
eval "/var/ossec/bin/wazuh-control status ${debug}"
installCommon_rollBack
exit 1
fi
}

function manager_configure(){

common_logger -d "Configuring Wazuh manager."
Expand Down