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

Added rollBack to several exit points #2882

Merged
merged 2 commits into from
Mar 15, 2024

Conversation

davidcr01
Copy link
Contributor

Related issue
#2785

Description

The aim of this PR is to call the rollback function to several exit points in the Wazuh installation assistant. These rollbacks prevent having Wazuh installed wrongly or incompletely in the system.

Some rollback functions have been called in the Password tool. To avoid performing an undesired rollback, a check has been added to perform the rollback only when the Installation Assistant is being used. In other words, when the rollback function is available.

The research of all the exit points is in: #2785 (comment)

Tests

🟢 Normal rollback in Assistant

The Wazuh manager is installed. The Filebeat installation fails and the Wazuh manager is uninstalled in the removal.

root@ubuntu22:/home/vagrant# bash wazuh-install.sh -g
13/03/2024 18:15:32 INFO: Starting Wazuh installation assistant. Wazuh version: 4.8.0
13/03/2024 18:15:32 INFO: Verbose logging redirected to /var/log/wazuh-install.log
13/03/2024 18:15:38 INFO: Verifying that your system meets the recommended minimum hardware requirements.
13/03/2024 18:15:39 INFO: --- Configuration files ---
13/03/2024 18:15:39 INFO: Generating configuration files.
13/03/2024 18:15:39 INFO: Generating the root certificate.
13/03/2024 18:15:39 INFO: Generating Admin certificates.
13/03/2024 18:15:39 INFO: Generating Wazuh indexer certificates.
13/03/2024 18:15:40 INFO: Generating Filebeat certificates.
13/03/2024 18:15:40 INFO: Generating Wazuh dashboard certificates.
13/03/2024 18:15:40 INFO: Created wazuh-install-files.tar. It contains the Wazuh cluster key, certificates, and passwords necessary for installation.

root@ubuntu22:/home/vagrant# bash wazuh-install.sh -ws wazuh-server -i
13/03/2024 18:17:11 INFO: Starting Wazuh installation assistant. Wazuh version: 4.8.0
13/03/2024 18:17:11 INFO: Verbose logging redirected to /var/log/wazuh-install.log
13/03/2024 18:17:18 WARNING: Hardware and system checks ignored.
13/03/2024 18:17:23 INFO: --- Dependencies ----
13/03/2024 18:17:23 INFO: Installing apt-transport-https.
13/03/2024 18:17:43 INFO: Wazuh development repository added.
13/03/2024 18:17:44 INFO: --- Wazuh server ---
13/03/2024 18:17:44 INFO: Starting the Wazuh manager installation.
13/03/2024 18:21:33 INFO: Wazuh manager installation finished.
13/03/2024 18:21:33 INFO: Wazuh manager vulnerability detection configuration finished.
13/03/2024 18:21:33 INFO: Starting service wazuh-manager.
13/03/2024 18:21:55 INFO: wazuh-manager service started.
13/03/2024 18:21:55 INFO: Starting Filebeat installation.
13/03/2024 18:22:33 INFO: Filebeat installation finished.
13/03/2024 18:22:34 ERROR: No certificates found. Could not initialize Filebeat
13/03/2024 18:22:34 INFO: --- Removing existing Wazuh installation ---
13/03/2024 18:22:34 INFO: Removing Wazuh manager.
13/03/2024 18:22:56 INFO: Wazuh manager removed.
13/03/2024 18:22:56 INFO: Removing Filebeat.
13/03/2024 18:23:00 INFO: Filebeat removed.
13/03/2024 18:23:00 INFO: Installation cleaned. Check the /var/log/wazuh-install.log file to learn more about the issue.
root@ubuntu22:/home/vagrant# 

🟢 Password function rollback using Assistant

Notice that the backup can not be created: ERROR: The backup could not be created, and every component installed is removed using the rollback function.

root@ubuntu22:/home/vagrant# bash wazuh-install.sh -a -i
14/03/2024 12:38:48 INFO: Starting Wazuh installation assistant. Wazuh version: 4.8.0
14/03/2024 12:38:48 INFO: Verbose logging redirected to /var/log/wazuh-install.log
14/03/2024 12:38:56 WARNING: Hardware and system checks ignored.
14/03/2024 12:38:56 INFO: Wazuh web interface port will be 443.
14/03/2024 12:39:09 INFO: Wazuh development repository added.
14/03/2024 12:39:09 INFO: --- Configuration files ---
14/03/2024 12:39:09 INFO: Generating configuration files.
14/03/2024 12:39:10 INFO: Generating the root certificate.
14/03/2024 12:39:10 INFO: Generating Admin certificates.
14/03/2024 12:39:10 INFO: Generating Wazuh indexer certificates.
14/03/2024 12:39:10 INFO: Generating Filebeat certificates.
14/03/2024 12:39:11 INFO: Generating Wazuh dashboard certificates.
14/03/2024 12:39:11 INFO: Created wazuh-install-files.tar. It contains the Wazuh cluster key, certificates, and passwords necessary for installation.
14/03/2024 12:39:12 INFO: --- Wazuh indexer ---
14/03/2024 12:39:12 INFO: Starting Wazuh indexer installation.
14/03/2024 12:40:09 INFO: Wazuh indexer installation finished.
14/03/2024 12:40:09 INFO: Wazuh indexer post-install configuration finished.
14/03/2024 12:40:09 INFO: Starting service wazuh-indexer.
14/03/2024 12:40:37 INFO: wazuh-indexer service started.
14/03/2024 12:40:37 INFO: Initializing Wazuh indexer cluster security settings.
14/03/2024 12:40:51 INFO: Wazuh indexer cluster security configuration initialized.
14/03/2024 12:40:51 INFO: Wazuh indexer cluster initialized.
14/03/2024 12:40:51 INFO: --- Wazuh server ---
14/03/2024 12:40:51 INFO: Starting the Wazuh manager installation.
14/03/2024 12:42:03 INFO: Wazuh manager installation finished.
14/03/2024 12:42:04 INFO: Wazuh manager vulnerability detection configuration finished.
14/03/2024 12:42:04 INFO: Starting service wazuh-manager.
14/03/2024 12:42:26 INFO: wazuh-manager service started.
14/03/2024 12:42:26 INFO: Starting Filebeat installation.
14/03/2024 12:42:53 INFO: Filebeat installation finished.
14/03/2024 12:43:01 INFO: Filebeat post-install configuration finished.
14/03/2024 12:43:01 INFO: Starting service filebeat.
14/03/2024 12:43:04 INFO: filebeat service started.
14/03/2024 12:43:04 INFO: --- Wazuh dashboard ---
14/03/2024 12:43:04 INFO: Starting Wazuh dashboard installation.
14/03/2024 12:44:58 INFO: Wazuh dashboard installation finished.
14/03/2024 12:44:59 INFO: Wazuh dashboard post-install configuration finished.
14/03/2024 12:44:59 INFO: Starting service wazuh-dashboard.
14/03/2024 12:45:01 INFO: wazuh-dashboard service started.
14/03/2024 12:45:06 INFO: Updating the internal users.
14/03/2024 12:45:17 ERROR: The backup could not be created
14/03/2024 12:45:17 INFO: --- Removing existing Wazuh installation ---
14/03/2024 12:45:17 INFO: Removing Wazuh manager.
14/03/2024 12:45:38 INFO: Wazuh manager removed.
14/03/2024 12:45:38 INFO: Removing Wazuh indexer.
14/03/2024 12:45:44 INFO: Wazuh indexer removed.
14/03/2024 12:45:44 INFO: Removing Filebeat.
14/03/2024 12:45:48 INFO: Filebeat removed.
14/03/2024 12:45:48 INFO: Removing Wazuh dashboard.
14/03/2024 12:46:01 INFO: Wazuh dashboard removed.
14/03/2024 12:46:02 INFO: Installation cleaned. Check the /var/log/wazuh-install.log file to learn more about the issue.

🟢 Password function rollback using password tool

The Wazuh indexer is installed and the cluster is initialized.
After changing the passwords and failing, the Wazuh indexer that is installed is not uninstalled, as the Wazuh password tool does not have the rollback function.

root@ubuntu22:/home/vagrant# bash wazuh-install.sh -wi wazuh-indexer -i && bash wazuh-install.sh -s
14/03/2024 12:59:40 INFO: Starting Wazuh installation assistant. Wazuh version: 4.8.0
14/03/2024 12:59:40 INFO: Verbose logging redirected to /var/log/wazuh-install.log
14/03/2024 12:59:46 WARNING: Hardware and system checks ignored.
14/03/2024 12:59:56 INFO: Wazuh development repository added.
14/03/2024 12:59:56 INFO: --- Wazuh indexer ---
14/03/2024 12:59:56 INFO: Starting Wazuh indexer installation.
14/03/2024 13:00:52 INFO: Wazuh indexer installation finished.
14/03/2024 13:00:52 INFO: Wazuh indexer post-install configuration finished.
14/03/2024 13:00:52 INFO: Starting service wazuh-indexer.
14/03/2024 13:01:11 INFO: wazuh-indexer service started.
14/03/2024 13:01:11 INFO: Initializing Wazuh indexer cluster security settings.
14/03/2024 13:01:14 INFO: Wazuh indexer cluster initialized.
14/03/2024 13:01:14 INFO: Installation finished.
14/03/2024 13:01:14 INFO: Starting Wazuh installation assistant. Wazuh version: 4.8.0
14/03/2024 13:01:14 INFO: Verbose logging redirected to /var/log/wazuh-install.log
14/03/2024 13:01:21 INFO: Verifying that your system meets the recommended minimum hardware requirements.
14/03/2024 13:01:35 INFO: Wazuh indexer cluster security configuration initialized.
14/03/2024 13:02:02 INFO: Updating the internal users.
14/03/2024 13:02:06 INFO: A backup of the internal users has been saved in the /etc/wazuh-indexer/internalusers-backup folder.
14/03/2024 13:02:18 INFO: Wazuh indexer cluster started.
root@ubuntu22:/home/vagrant# bash wazuh-passwords-tool.sh -a
14/03/2024 13:02:28 INFO: Updating the internal users.
14/03/2024 13:02:32 ERROR: The backup could not be created
root@ubuntu22:/home/vagrant# 

@davidcr01 davidcr01 requested a review from a team March 14, 2024 13:30
@davidcr01 davidcr01 self-assigned this Mar 14, 2024
@davidcr01 davidcr01 linked an issue Mar 14, 2024 that may be closed by this pull request
2 tasks
@teddytpc1 teddytpc1 merged commit 734ccab into 4.9.0 Mar 15, 2024
5 of 7 checks passed
@teddytpc1 teddytpc1 deleted the bug/2785-add-rollback-in-wia-exit-points branch March 15, 2024 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add roll back to the different WIA exit points
2 participants