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

Improve error handling in installation assistant #1767

Closed
DFolchA opened this issue Aug 1, 2022 · 5 comments
Closed

Improve error handling in installation assistant #1767

DFolchA opened this issue Aug 1, 2022 · 5 comments
Assignees
Labels

Comments

@DFolchA
Copy link
Contributor

DFolchA commented Aug 1, 2022

Wazuh version Install type Action performed Platform
X.Y.Z-rev Manager/API/Agent Install/Upgrade/Remove OS version

In #1760 @fcaffieri implemented a try-catch structure to handle errors in the installation assistant, while interesting it exceeded the scope of the issue. This issue is meant to study the possible solutions to improve how we handle errors in the installation assistant.

@okynos okynos assigned DFolchA and unassigned DFolchA Aug 2, 2022
@snaow snaow added this to the Release 4.5.0 milestone Nov 16, 2022
@snaow snaow removed this from the Release 4.5.0 milestone Dec 21, 2022
@teddytpc1 teddytpc1 added level/task Subtask issue type/enhancement Enhancement issue labels May 22, 2023
@davidcr01
Copy link
Contributor

Update Report

Testing

I was testing the development @fcaffieri made, and I found some unexpected behaviors. While trying to make an AIO installation, I found that the execution of the script was stopped wrongly because a grep command could not fetch any results:

🟢 Wazuh indexer is installed without try-catch
root@ubuntu22:/home/vagrant# bash wazuh-install.sh -a -i -v -o
06/11/2023 11:55:35 DEBUG: Checking root permissions.
06/11/2023 11:55:35 INFO: Starting Wazuh installation assistant. Wazuh version: 4.9.0
06/11/2023 11:55:35 INFO: Verbose logging redirected to /var/log/wazuh-install.log
06/11/2023 11:55:35 DEBUG: APT package manager will be used.
06/11/2023 11:55:35 DEBUG: Installing check dependencies.
Hit:1 https://mirrors.edge.kernel.org/ubuntu jammy InRelease
Hit:2 https://mirrors.edge.kernel.org/ubuntu jammy-updates InRelease
Hit:3 https://mirrors.edge.kernel.org/ubuntu jammy-backports InRelease
Hit:4 https://mirrors.edge.kernel.org/ubuntu jammy-security InRelease
Reading package lists...
06/11/2023 11:55:41 DEBUG: Checking system distribution.
06/11/2023 11:55:41 DEBUG: Detected distribution name: ubuntu
06/11/2023 11:55:41 DEBUG: Detected distribution version: 22
06/11/2023 11:55:41 DEBUG: Checking Wazuh installation.
06/11/2023 11:55:43 INFO: --- Removing existing Wazuh installation ---
06/11/2023 11:55:43 DEBUG: Removing GPG key from system.
06/11/2023 11:55:43 INFO: Wazuh GPG key not found in the system
06/11/2023 11:55:43 INFO: Installation cleaned.
06/11/2023 11:55:43 DEBUG: Installing check dependencies.
Hit:1 https://mirrors.edge.kernel.org/ubuntu jammy InRelease
Hit:2 https://mirrors.edge.kernel.org/ubuntu jammy-updates InRelease
Hit:3 https://mirrors.edge.kernel.org/ubuntu jammy-backports InRelease
Hit:4 https://mirrors.edge.kernel.org/ubuntu jammy-security InRelease
Reading package lists...
06/11/2023 11:55:51 DEBUG: Checking system architecture.
06/11/2023 11:55:51 WARNING: Hardware and system checks ignored.
06/11/2023 11:55:51 INFO: Wazuh web interface port will be 443.
06/11/2023 11:55:51 DEBUG: Checking ports availability.
06/11/2023 11:55:51 DEBUG: Installing prerequisites dependencies.
Hit:1 https://mirrors.edge.kernel.org/ubuntu jammy InRelease
Hit:2 https://mirrors.edge.kernel.org/ubuntu jammy-updates InRelease
Hit:3 https://mirrors.edge.kernel.org/ubuntu jammy-backports InRelease
Hit:4 https://mirrors.edge.kernel.org/ubuntu jammy-security InRelease
Reading package lists...
06/11/2023 11:55:55 DEBUG: Checking curl tool version.
06/11/2023 11:55:55 DEBUG: Adding the Wazuh repository.
gpg: keyring '/usr/share/keyrings/wazuh.gpg' created
gpg: key 96B3EE5F29111145: public key "Wazuh.com (Wazuh Signing Key) <[email protected]>" imported
gpg: Total number processed: 1
gpg:               imported: 1
deb [signed-by=/usr/share/keyrings/wazuh.gpg] https://packages-dev.wazuh.com/staging/apt/ unstable main
Hit:1 https://mirrors.edge.kernel.org/ubuntu jammy InRelease
Hit:2 https://mirrors.edge.kernel.org/ubuntu jammy-updates InRelease
Hit:3 https://mirrors.edge.kernel.org/ubuntu jammy-backports InRelease
Hit:4 https://mirrors.edge.kernel.org/ubuntu jammy-security InRelease
Get:5 https://packages-dev.wazuh.com/staging/apt unstable InRelease [17.3 kB]
Get:6 https://packages-dev.wazuh.com/staging/apt unstable/main amd64 Packages [30.4 kB]
Fetched 47.7 kB in 2s (26.4 kB/s)
Reading package lists...
06/11/2023 11:55:59 INFO: Wazuh development repository added.
06/11/2023 11:55:59 INFO: --- Configuration files ---
06/11/2023 11:55:59 INFO: Generating configuration files.
06/11/2023 11:55:59 DEBUG: Creating Wazuh certificates.
06/11/2023 11:55:59 DEBUG: Reading configuration file.
06/11/2023 11:56:00 DEBUG: Creating the root certificate.
.+...+..+.......+..+................+..+.+..+...+....+..+...+.+...........+...+......+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*...............+.......+..+...+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*.+.....+..........+..+...+.........+...+.............+.....+...+.+......+.........+...........+...+....+..+...+............+.+........+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
.......+..............+......+.+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*.....+......+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*.........+...........+.+........+......+.+........+....+..+.....................+.......+...+..+.+......+...+......+......+.........+..+....+........+.......+......+.....+....+...+..+...+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-----
06/11/2023 11:56:00 DEBUG: Generating Admin certificates.
Certificate request self-signature ok
subject=C = US, L = California, O = Wazuh, OU = Wazuh, CN = admin
06/11/2023 11:56:00 DEBUG: Generating Wazuh indexer certificates.
06/11/2023 11:56:00 DEBUG: Creating the Wazuh indexer certificates.
06/11/2023 11:56:00 DEBUG: Generating certificate configuration.
Ignoring -days without -x509; not generating a certificate
....+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*...+..........+..+....+.....+.+............+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*.....+......+.........+.....................+....+..+.........+....+........+....+...+..+..........+...+...+...+.........+...+..............+.........+....+.....+............+.............+...+..+...+.......+.....+.......+.........+..+....+.....+................+..+.+.................+...+.+...+........+...+.........+..........+..+.........+.+......+..+.+..+...+......+.+.........+.....+.+..+.+......+...+.....+...+.........+....+.....................+........+.+......+......+...+..+.......+...+........+.+......+..+..........+...+........+..........+...........+......+.........+.........+....+......+......+........+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
...+....+..+.+.........+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*...+......+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*..+......+.......+..+......+......+...+...............+.+..+....+.....+.+............+..+......+.......+..+.+..+.......+...............+......+.....+.......+............+.........+..+.......+........+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-----
Certificate request self-signature ok
subject=C = US, L = California, O = Wazuh, OU = Wazuh, CN = wazuh-indexer
06/11/2023 11:56:01 DEBUG: Generating Filebeat certificates.
06/11/2023 11:56:01 DEBUG: Creating the Wazuh server certificates.
06/11/2023 11:56:01 DEBUG: Generating certificate configuration.
Ignoring -days without -x509; not generating a certificate
...+........+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*.........+...+.+.........+........+....+........+.+............+..+.+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*.........+.+..+.............+.....+.+........+.......+...+.....+......+.+......+...+......+......+........+....+.................+...+..........+.....+..................+.......+.....+............+...+......+....+.....+.......+...+...+...........................+......+..+....+......+.........+...+..+.........+......+.+..............+...+...+.........+.+.....+.......+..+.+..+.+...........+...+......+.......+...+.....+.......+..+..................+...+.+...........+....+.....+......+...+......+.............+......+.....+.+........+.+..+..........+.........+.........+..+....+...........+....+...+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
.....+.........+..+...+......+...+...+...+...................+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*..+...+......+......+...+.+.........+...+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*....+.........+.......+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-----
Certificate request self-signature ok
subject=C = US, L = California, O = Wazuh, OU = Wazuh, CN = wazuh-server
06/11/2023 11:56:01 DEBUG: Generating Wazuh dashboard certificates.
06/11/2023 11:56:01 DEBUG: Creating the Wazuh dashboard certificates.
06/11/2023 11:56:01 DEBUG: Generating certificate configuration.
Ignoring -days without -x509; not generating a certificate
..+.+.....+.........+..........+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*.........+.....+.+.....+....+..+....+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*............+....................+................+...........+..................+......+....+..+.........+......+...+...+....+.....+....+.....+.+........+.+.....+....+..+.+..+.+.....+.......+..+.......+...+.................+.........+.......+.....+..................+........................+......+.+......+...+.........+........+....+.....+...............+...+............+...+...+...+....+......+..+...+.+...+.....+.............+.....+....+...+..+...................+.....+......+......+....+...............+...+...+..+.+.....+......+................+...+.....+.+...+..+......+....+.................................+......+..+.......+.....+.+.....+.......+..+......+.+.....................+..+...+.........+......+...+....+..+..................+.......+...+.....+.......+......+...+.................+...+.+......+...............+.....+...+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
..+.+.....+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*....+.+.................+...+....+.....+...+......+....+..+....+.....+....+...+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*....+........+............+.+...+...............+..+....+.....+...+.+..+...+.......+..+...+........................+.+.........+...+.................+.............+...+............+......+..+...+.......+..+..........+..+.+...+......+........+.+..+...+......+.+..+...+.......+...+........+..........+..+.......+..+......+...+.+...+...+............+...+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-----
Certificate request self-signature ok
subject=C = US, L = California, O = Wazuh, OU = Wazuh, CN = wazuh-dashboard
06/11/2023 11:56:02 DEBUG: Cleaning certificate files.
06/11/2023 11:56:02 DEBUG: Generating password file.
06/11/2023 11:56:02 DEBUG: Generating random passwords.
06/11/2023 11:56:02 INFO: Created wazuh-install-files.tar. It contains the Wazuh cluster key, certificates, and passwords necessary for installation.
06/11/2023 11:56:02 DEBUG: Extracting Wazuh configuration.
06/11/2023 11:56:02 DEBUG: Reading configuration file.
06/11/2023 11:56:02 INFO: --- Wazuh indexer ---
06/11/2023 11:56:02 INFO: Starting Wazuh indexer installation.
Reading package lists... Building dependency tree... Reading state information... The following NEW packages will be installed: wazuh-indexer 0 upgraded, 1 newly installed, 0 to remove and 148 not upgraded. Need to get 0 B/685 MB of archives. After this operation, 969 MB of additional disk space will be used. S NEEDRESTART-VER: 3.5 NEEDRESTART-KCUR: 5.15.0-69-generic NEEDRESTART-KEXP: 5.15.0-69-generic NEEDRESTART-KSTA: 1
06/11/2023 11:56:57 DEBUG: Checking Wazuh installation.
06/11/2023 11:56:58 DEBUG: There are Wazuh indexer remaining files.
06/11/2023 11:56:59 INFO: Wazuh indexer installation finished.
06/11/2023 11:56:59 DEBUG: Configuring Wazuh indexer.
06/11/2023 11:56:59 DEBUG: Copying Wazuh indexer certificates.
06/11/2023 11:56:59 INFO: Wazuh indexer post-install configuration finished.
06/11/2023 11:56:59 INFO: Starting service wazuh-indexer.
Created symlink /etc/systemd/system/multi-user.target.wants/wazuh-indexer.service → /lib/systemd/system/wazuh-indexer.service.
06/11/2023 11:57:37 INFO: wazuh-indexer service started.
06/11/2023 11:57:37 INFO: Initializing Wazuh indexer cluster security settings.
**************************************************************************
** This tool will be deprecated in the next major release of OpenSearch **
** https://github.com/opensearch-project/security/issues/1755           **
**************************************************************************
Security Admin v7
Will connect to 127.0.0.1:9200 ... done
Connected as "CN=admin,OU=Wazuh,O=Wazuh,L=California,C=US"
OpenSearch Version: 2.8.0
Contacting opensearch cluster 'opensearch' and wait for YELLOW clusterstate ...
Clustername: wazuh-cluster
Clusterstate: GREEN
Number of nodes: 1
Number of data nodes: 1
.opendistro_security index does not exists, attempt to create it ... done (0-all replicas)
Populate config from /etc/wazuh-indexer/opensearch-security/
Will update '/config' with /etc/wazuh-indexer/opensearch-security/config.yml 
   SUCC: Configuration for 'config' created or updated
Will update '/roles' with /etc/wazuh-indexer/opensearch-security/roles.yml 
   SUCC: Configuration for 'roles' created or updated
Will update '/rolesmapping' with /etc/wazuh-indexer/opensearch-security/roles_mapping.yml 
   SUCC: Configuration for 'rolesmapping' created or updated
Will update '/internalusers' with /etc/wazuh-indexer/opensearch-security/internal_users.yml 
   SUCC: Configuration for 'internalusers' created or updated
Will update '/actiongroups' with /etc/wazuh-indexer/opensearch-security/action_groups.yml 
   SUCC: Configuration for 'actiongroups' created or updated
Will update '/tenants' with /etc/wazuh-indexer/opensearch-security/tenants.yml 
   SUCC: Configuration for 'tenants' created or updated
Will update '/nodesdn' with /etc/wazuh-indexer/opensearch-security/nodes_dn.yml 
   SUCC: Configuration for 'nodesdn' created or updated
Will update '/whitelist' with /etc/wazuh-indexer/opensearch-security/whitelist.yml 
   SUCC: Configuration for 'whitelist' created or updated
Will update '/audit' with /etc/wazuh-indexer/opensearch-security/audit.yml 
   SUCC: Configuration for 'audit' created or updated
Will update '/allowlist' with /etc/wazuh-indexer/opensearch-security/allowlist.yml 
   SUCC: Configuration for 'allowlist' created or updated
SUCC: Expected 10 config types for node {"updated_config_types":["allowlist","tenants","rolesmapping","nodesdn","audit","roles","whitelist","internalusers","actiongroups","config"],"updated_config_size":10,"message":null} is 10 (["allowlist","tenants","rolesmapping","nodesdn","audit","roles","whitelist","internalusers","actiongroups","config"]) due to: null
Done with success
06/11/2023 11:57:49 INFO: Wazuh indexer cluster initialized.
🔴 Wazuh indexer is not installed with try-catch
root@ubuntu22:/home/vagrant# bash wazuh-install.sh -a -i -v -o
06/11/2023 11:51:29 DEBUG: Checking root permissions.
06/11/2023 11:51:29 INFO: Starting Wazuh installation assistant. Wazuh version: 4.9.0
06/11/2023 11:51:29 INFO: Verbose logging redirected to /var/log/wazuh-install.log
06/11/2023 11:51:29 DEBUG: APT package manager will be used.
06/11/2023 11:51:29 DEBUG: Installing check dependencies.
Hit:1 https://mirrors.edge.kernel.org/ubuntu jammy InRelease
Get:2 https://mirrors.edge.kernel.org/ubuntu jammy-updates InRelease [119 kB]
Hit:3 https://mirrors.edge.kernel.org/ubuntu jammy-backports InRelease
Get:4 https://mirrors.edge.kernel.org/ubuntu jammy-security InRelease [110 kB]
Get:5 https://mirrors.edge.kernel.org/ubuntu jammy-updates/main amd64 Packages [1,149 kB]
Get:6 https://mirrors.edge.kernel.org/ubuntu jammy-updates/universe amd64 Packages [999 kB]
Fetched 2,377 kB in 4s (624 kB/s)
Reading package lists...
06/11/2023 11:51:38 DEBUG: Checking system distribution.
06/11/2023 11:51:38 DEBUG: Detected distribution name: ubuntu
06/11/2023 11:51:38 DEBUG: Detected distribution version: 22
06/11/2023 11:51:38 DEBUG: Checking Wazuh installation.
06/11/2023 11:51:39 INFO: --- Removing existing Wazuh installation ---
06/11/2023 11:51:39 INFO: Removing Wazuh indexer.
Reading package lists...
Building dependency tree...
Reading state information...
The following packages will be REMOVED:
  wazuh-indexer*
0 upgraded, 0 newly installed, 1 to remove and 148 not upgraded.
                                                                After this operation, 969 MB disk space will be freed.
(Reading database ... 76943 files and directories currently installed.)
Removing wazuh-indexer (4.9.0-1) ...
Stopping wazuh-indexer service... OK
(Reading database ... 75846 files and directories currently installed.)
Purging configuration files for wazuh-indexer (4.9.0-1) ...
Deleting configuration directory... OK
dpkg: warning: while removing wazuh-indexer, directory '/usr/lib/systemd/system' not empty so not removed
06/11/2023 11:51:42 INFO: Wazuh indexer removed.
06/11/2023 11:51:42 DEBUG: Removing GPG key from system.
06/11/2023 11:51:42 INFO: Wazuh GPG key not found in the system
06/11/2023 11:51:42 INFO: Installation cleaned.
06/11/2023 11:51:42 DEBUG: Installing check dependencies.
Hit:1 https://mirrors.edge.kernel.org/ubuntu jammy InRelease
Hit:2 https://mirrors.edge.kernel.org/ubuntu jammy-updates InRelease
Hit:3 https://mirrors.edge.kernel.org/ubuntu jammy-backports InRelease
Hit:4 https://mirrors.edge.kernel.org/ubuntu jammy-security InRelease
Reading package lists...
06/11/2023 11:51:48 DEBUG: Checking system architecture.
06/11/2023 11:51:48 WARNING: Hardware and system checks ignored.
06/11/2023 11:51:48 INFO: Wazuh web interface port will be 443.
06/11/2023 11:51:48 DEBUG: Checking ports availability.
06/11/2023 11:51:48 DEBUG: Installing prerequisites dependencies.
Hit:1 https://mirrors.edge.kernel.org/ubuntu jammy InRelease
Hit:2 https://mirrors.edge.kernel.org/ubuntu jammy-updates InRelease
Hit:3 https://mirrors.edge.kernel.org/ubuntu jammy-backports InRelease
Hit:4 https://mirrors.edge.kernel.org/ubuntu jammy-security InRelease
Reading package lists...
06/11/2023 11:51:52 DEBUG: Checking curl tool version.
06/11/2023 11:51:52 DEBUG: Adding the Wazuh repository.
gpg: keyring '/usr/share/keyrings/wazuh.gpg' created
gpg: key 96B3EE5F29111145: public key "Wazuh.com (Wazuh Signing Key) <[email protected]>" imported
gpg: Total number processed: 1
gpg:               imported: 1
deb [signed-by=/usr/share/keyrings/wazuh.gpg] https://packages-dev.wazuh.com/staging/apt/ unstable main
Hit:1 https://mirrors.edge.kernel.org/ubuntu jammy InRelease
Hit:2 https://mirrors.edge.kernel.org/ubuntu jammy-updates InRelease
Hit:3 https://mirrors.edge.kernel.org/ubuntu jammy-backports InRelease
Hit:4 https://mirrors.edge.kernel.org/ubuntu jammy-security InRelease
Get:5 https://packages-dev.wazuh.com/staging/apt unstable InRelease [17.3 kB]
Get:6 https://packages-dev.wazuh.com/staging/apt unstable/main amd64 Packages [30.4 kB]
Fetched 47.7 kB in 2s (27.6 kB/s)
Reading package lists...
06/11/2023 11:51:56 INFO: Wazuh development repository added.
06/11/2023 11:51:56 INFO: --- Configuration files ---
06/11/2023 11:51:56 INFO: Generating configuration files.
06/11/2023 11:51:56 DEBUG: Creating Wazuh certificates.
06/11/2023 11:51:57 DEBUG: Reading configuration file.
06/11/2023 11:51:57 DEBUG: Creating the root certificate.
...+.....+......+.+........+.+......+...+.....+....+...+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*....+..+....+...+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*...+......+..+....+.........+......+.....+.+........+......+......+...+.+...+......+..............+...+.......+.....+.+......+...........+....+......+...+.....+..........+.....+......+.........+....+...+...+.....+......+...+..........+........+.......+...........+....+..+.+..+.......+......+.....+.......+........+...+.+.....+.+............+..+......+.......+.....+.+..+............+..........+..+.........+.+.....+...+...+.........+.+..+.......+.........+..+...+......+...+.......+..................+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
...+......+.......+.....+....+...+..+...+...+....+.........+..+.........+...+...+.........+....+.....+.+......+........+....+...+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*.......+...+.......+.................+......+....+.....+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*.....+..........+...+...............+..+....+...........+..........+.....+...................+...............+......+..+.......+.........+..+...+....+...+..+.+.........+..+...+.....................+......+...+...............+...+...+.+...............+...+..+.+..............+..........+..................+...+...+..+....+..............+.+......+..+...+...+....+...........+....+......+..+...+.......+............+..+...+......+....+........+..............................+..........+.....+.........+....+..+.......+......+......+.........+..+.............+.........+.....+.+.....+.+......+..+...+............+......+..........+............+.....+...............+............+......+......+.........+...................+..+...+......+....+......+.........+...+..................+..+....+...+......+..+...+......+...+.+............+...+......+......+..+......+............+...+....+...+..+.+......+.........+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-----
06/11/2023 11:51:58 DEBUG: Generating Admin certificates.
Certificate request self-signature ok
subject=C = US, L = California, O = Wazuh, OU = Wazuh, CN = admin
06/11/2023 11:51:58 DEBUG: Generating Wazuh indexer certificates.
06/11/2023 11:51:58 DEBUG: Creating the Wazuh indexer certificates.
06/11/2023 11:51:58 DEBUG: Generating certificate configuration.
Ignoring -days without -x509; not generating a certificate
...........+...+....+......+.....+.+...+.....+............+.+..+.+......+.....+.+..+...+....+...+...........+....+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*.........+..+.+...............+...+.....+....+..+...+............+...+.+....................+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*.+......+.......+..............+...+.+......+.........+...........+......+...+.+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
..+.....+......+...+.......+......+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*..........+............+..+............+...+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*....+....+...+...+...............+..+......+......+.+........+.+.....+.........+....+.....+.+.........+.....+.+.....................+.....+.+........+.+........+...+...+....+...+.........+...+.....................+..+.......+.....+...+....+...........+...+.......+...+...............+..............+......+............+............+...+..................+.+......+..+......+.+...+....................+.+..+....+...+.....+...+...+.+.....+.........+......+...+......................+......+..+.+..+....+.........+......+....................+.........+....+...+...+...........+.+............+......+.....+....+...............+...+...............+..+......+...............+......+.+..............+....+.........+..+....+..+.......+........+...+......+....+.....+......+.+.....+...+.+........+...+.......+......+..+...+.......+...+......+...........+...+..........+.....+.+......+..+...............+...+.......+...+..+...+.......+..+......+...+.........+.+.........+............+...+.....+.+.........+...+..+............+.........+....+..+......+.........+....+............+..............+...+..................+....+...............+.....+.+...+..+.........+.+........+.+...........+...+................+...+..+......+.......+...+.....+...+......+.+..+.+.....+.....................+.....................+...+.........+.+..+.......+.....+.+.....+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-----
Certificate request self-signature ok
subject=C = US, L = California, O = Wazuh, OU = Wazuh, CN = wazuh-indexer
06/11/2023 11:51:59 DEBUG: Generating Filebeat certificates.
06/11/2023 11:51:59 DEBUG: Creating the Wazuh server certificates.
06/11/2023 11:51:59 DEBUG: Generating certificate configuration.
Ignoring -days without -x509; not generating a certificate
.......+..............+..........+..+....+...+..+.+..+...........................+....+......+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*....+..........+.........+.....+.+..+....+...+...+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*.+.......+.....+......+......+.........+...................+..+...+...+...+....+......+.....+....+...+...............+.....+...+.+...+........+.........+................+...+.................+..........+...+..+.........+....+.....+.........+.+..+...+.+........+......+.....................+.+..+.+......+...+..+................+........+....+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
......+...+......+.....+...+.............+..+.......+...+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*.....+.+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*...........+........+...+.......+.....+.+..+....+...+...+...+.....+......+.+..+...............+..........+.................+.+.....+...............+...+.......+............+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-----
Certificate request self-signature ok
subject=C = US, L = California, O = Wazuh, OU = Wazuh, CN = wazuh-server
06/11/2023 11:51:59 DEBUG: Generating Wazuh dashboard certificates.
06/11/2023 11:51:59 DEBUG: Creating the Wazuh dashboard certificates.
06/11/2023 11:51:59 DEBUG: Generating certificate configuration.
Ignoring -days without -x509; not generating a certificate
...+.........+.+...........+.+...+...........+.........+......+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*..........+...+...........+.+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*.+........+.+..+...+.+...+...+..+......+....+...............+...............+...........+....+...+...+..+...+.+....................+....+...........+......+....+......+...+...........+..........+.........+......+........+.+......+.....+....+.....+......+...+.+.........+...+..+.............+...+..............+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*.....+..........+..+.......+...+.....+......+.+......+.....+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*..+..+.+............+..+.+..+.+......+...+....................+.+...........+.........+......+....+.....+....+..+......+...+...............+.......+.......................+....+......+.....+......+..................+.+......+........+......+.+.....+.............+......+.........+..+...+......+.+...+...+..+...+....+.....+...+......+................+.....+.+..............+.+.....+...+.........+.+..+.......+......+......+.........+.....+......+...............+...+...+......................+..+.+...+..+.......+..+...+...+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-----
Certificate request self-signature ok
subject=C = US, L = California, O = Wazuh, OU = Wazuh, CN = wazuh-dashboard
06/11/2023 11:52:00 DEBUG: Cleaning certificate files.
06/11/2023 11:52:00 DEBUG: Generating password file.
06/11/2023 11:52:00 DEBUG: Generating random passwords.
06/11/2023 11:52:00 INFO: Created wazuh-install-files.tar. It contains the Wazuh cluster key, certificates, and passwords necessary for installation.
06/11/2023 11:52:00 DEBUG: Extracting Wazuh configuration.
06/11/2023 11:52:00 DEBUG: Reading configuration file.
06/11/2023 11:52:00 INFO: --- Wazuh indexer ---
06/11/2023 11:52:00 INFO: Starting Wazuh indexer installation.
Reading package lists... Building dependency tree... Reading state information... The following NEW packages will be installed: wazuh-indexer 0 upgraded, 1 newly installed, 0 to remove and 148 not upgraded. Need to get 0 B/685 MB of archives. After this operation, 969 MB of additional disk space will be used. S NEEDRESTART-VER: 3.5 NEEDRESTART-KCUR: 5.15.0-69-generic NEEDRESTART-KEXP: 5.15.0-69-generic NEEDRESTART-KSTA: 1
06/11/2023 11:52:52 INFO: AIO installation failed
06/11/2023 11:52:52 INFO: --- Removing existing Wazuh installation ---
06/11/2023 11:52:52 INFO: Removing Wazuh indexer.
Reading package lists...
Building dependency tree...
Reading state information...
The following packages will be REMOVED:
  wazuh-indexer*
0 upgraded, 0 newly installed, 1 to remove and 148 not upgraded.
                                                                After this operation, 969 MB disk space will be freed.
(Reading database ... 76943 files and directories currently installed.)
Removing wazuh-indexer (4.9.0-1) ...
Stopping wazuh-indexer service... OK
(Reading database ... 75854 files and directories currently installed.)
Purging configuration files for wazuh-indexer (4.9.0-1) ...
Deleting configuration directory... OK
dpkg: warning: while removing wazuh-indexer, directory '/var/lib/wazuh-indexer' not empty so not removed
dpkg: warning: while removing wazuh-indexer, directory '/usr/lib/systemd/system' not empty so not removed
06/11/2023 11:52:57 INFO: Wazuh indexer removed.
06/11/2023 11:52:57 DEBUG: Removing GPG key from system.
06/11/2023 11:52:57 INFO: Installation cleaned.
06/11/2023 11:52:57 DEBUG: Restoring Wazuh repository.
06/11/2023 11:52:57 DEBUG: Wazuh repository does not exists.
sed: no input files
sed: no input files
sed: no input files
06/11/2023 11:52:57 INFO: Installation finished.

The thing is that the rollback is performed because of these lines:

+ install_result=0
+ eval 'echo ${apt_output} 2>&1 | tee -a /var/log/wazuh-install.log'
++ tee -a /var/log/wazuh-install.log
++ echo Reading package lists... Building dependency tree... Reading state information... The following NEW packages will be installed: wazuh-indexer 0 upgraded, 1 newly installed, 0 to remove and 148 not upgraded. Need to get 0 B/685 MB of archives. After this operation, 969 MB of additional disk space will be' Preparing to unpack .../wazuh-indexer_4.9.0-1_amd64.deb $'...\r' Creating wazuh-indexer group... $'OK\r' Creating wazuh-indexer user... $'OK\r' Unpacking wazuh-indexer '(4.9.0-1)' $'...\r' Setting up wazuh-indexer '(4.9.0-1)' $'...\r' Created opensearch keystore in $'/etc/wazuh-indexer/opensearch.keystore\r' Processing triggers for libc-bin '(2.35-0ubuntu3.1)' $'...\r' NEEDRESTART-VER: 3.5 NEEDRESTART-KCUR: 5.15.0-69-generic NEEDRESTART-KEXP: 5.15.0-69-generic NEEDRESTART-KSTA: 1
Reading package lists... Building dependency tree... Reading state information... The following NEW packages will be installed: wazuh-indexer 0 upgraded, 1 newly installed, 0 to remove and 148 not upgraded. Need to get 0 B/685 MB of archives. After this operation, 969 MB of additional disk space will be used. S NEEDRESTART-VER: 3.5 NEEDRESTART-KCUR: 5.15.0-69-generic NEEDRESTART-KEXP: 5.15.0-69-generic NEEDRESTART-KSTA: 1

+ eval 'tail -n 2 /var/log/wazuh-install.log | grep -q '\''Could not get lock'\''' # 1
++ grep -q 'Could not get lock'
++ tail -n 2 /var/log/wazuh-install.log

06/11/2023 12:01:22 INFO: AIO failed.
06/11/2023 12:01:22 DEBUG: Restoring Wazuh repository.
06/11/2023 12:01:22 INFO: Installation finished.

root@ubuntu22:/home/vagrant# tail -n 2 /var/log/wazuh-install.log | grep -q 'Could not get lock'
root@ubuntu22:/home/vagrant# echo $?
1

The previous lines check if the APT lock exists by consulting the wazuh-install.log, and the grep command generates 1 as the return code, so the rollback is performed because this is interpreted as an error.

Is necessary to evaluate this development and decide if it is an improvement to the existing WIA.

@fcaffieri
Copy link
Member

@davidcr01 this was explained and resolved here

@davidcr01
Copy link
Contributor

Update Report

Development

After the clarification of @fcaffieri, the issue reported in the previous comments can be solved easily by adding the || true string and checking the output of the command instead of the return code:

  • Instead of:
 grep_result=$(tail -n 2 ${logfile} | grep -q 'Could not get lock')
 while [ "${grep_result}" -eq 0 ] && [ "${attempt}" -lt 10 ]; do
  • The APT lock check will be:
grep_result=$(tail -n 2 ${logfile} | grep -q 'Could not get lock' || true)
while [ -n "${grep_result}" ] && [ "${attempt}" -lt 10 ]; do

Nevertheless, this specific code is changed in 4.8.0, in this PR, so this grep problem will be solved too, as it is removed.

@davidcr01
Copy link
Contributor

This issue goes to "On hold" because of the priority of the 4.8.0 issues.

@teddytpc1
Copy link
Member

We won't apply this.
We will improve tests, validations, etc. in other issues, like this one:

@teddytpc1 teddytpc1 closed this as not planned Won't fix, can't repro, duplicate, stale Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

6 participants