wazuh / wazuh-packages

Wazuh - Tools for packages creation
https://wazuh.com
GNU General Public License v2.0
105 stars 97 forks source link

The `lsof` and `openssl` packages are installed only when needed in Installation Assistant #2862

Closed davidcr01 closed 9 months ago

davidcr01 commented 9 months ago
Related issue
https://github.com/wazuh/wazuh-packages/issues/2772

Description

The aim of this PR is to modify the Wazuh installation assistant to install the lsof and openssl packages only when they are needed. Before, the tool installed these dependencies when they were not necessary.

Logs example

Notice that the dependencies are installed only when needed, and then, removed.

:green_circle: Certificates generation

root@ubuntu22:/home/vagrant# lsof
bash: /usr/bin/lsof: No such file or directory
root@ubuntu22:/home/vagrant# openssl
bash: /usr/bin/openssl: No such file or directory

root@ubuntu22:/home/vagrant# bash wazuh-install.sh -g -i
04/03/2024 13:57:34 INFO: Starting Wazuh installation assistant. Wazuh version: 4.8.0
04/03/2024 13:57:34 INFO: Verbose logging redirected to /var/log/wazuh-install.log
04/03/2024 13:57:40 WARNING: Hardware and system checks ignored.
04/03/2024 13:57:40 INFO: --- Configuration files ---
04/03/2024 13:57:40 INFO: Generating configuration files.
04/03/2024 13:57:40 INFO: --- Dependencies ----
04/03/2024 13:57:40 INFO: Installing openssl.
04/03/2024 13:57:44 INFO: Created wazuh-install-files.tar. It contains the Wazuh cluster key, certificates, and passwords necessary for installation.
04/03/2024 13:57:44 INFO: --- Dependencies ----
04/03/2024 13:57:44 INFO: Removing openssl.    

root@ubuntu22:/home/vagrant# tar -xvf wazuh-install-files.tar 
wazuh-install-files/
wazuh-install-files/root-ca.key
wazuh-install-files/wazuh-indexer-key.pem
wazuh-install-files/admin-key.pem
wazuh-install-files/wazuh-passwords.txt
wazuh-install-files/config.yml
wazuh-install-files/root-ca.pem
wazuh-install-files/admin.pem
wazuh-install-files/wazuh-dashboard-key.pem
wazuh-install-files/wazuh-server-key.pem
wazuh-install-files/wazuh-server.pem
wazuh-install-files/wazuh-dashboard.pem
wazuh-install-files/wazuh-indexer.pem
root@ubuntu22:/home/vagrant# 

:green_circle: Cluster initialization

root@ubuntu22:/home/vagrant# bash wazuh-install.sh -wi wazuh-indexer -i
04/03/2024 14:04:48 INFO: Starting Wazuh installation assistant. Wazuh version: 4.8.0
04/03/2024 14:04:48 INFO: Verbose logging redirected to /var/log/wazuh-install.log
04/03/2024 14:04:57 WARNING: Hardware and system checks ignored.
04/03/2024 14:04:57 INFO: --- Dependencies ----
04/03/2024 14:04:57 INFO: Installing lsof.
04/03/2024 14:05:11 INFO: Wazuh development repository added.
04/03/2024 14:05:11 INFO: --- Wazuh indexer ---
04/03/2024 14:05:11 INFO: Starting Wazuh indexer installation.
04/03/2024 14:09:38 INFO: Wazuh indexer installation finished.
04/03/2024 14:09:38 INFO: Wazuh indexer post-install configuration finished.
04/03/2024 14:09:38 INFO: Starting service wazuh-indexer.
04/03/2024 14:10:08 INFO: wazuh-indexer service started.
04/03/2024 14:10:08 INFO: Initializing Wazuh indexer cluster security settings.
04/03/2024 14:10:11 INFO: Wazuh indexer cluster initialized.
04/03/2024 14:10:11 INFO: --- Dependencies ----
04/03/2024 14:10:11 INFO: Removing lsof.
04/03/2024 14:10:13 INFO: Installation finished.
root@ubuntu22:/home/vagrant# 

root@ubuntu22:/home/vagrant# bash wazuh-install.sh -s -i
04/03/2024 14:10:39 INFO: Starting Wazuh installation assistant. Wazuh version: 4.8.0
04/03/2024 14:10:39 INFO: Verbose logging redirected to /var/log/wazuh-install.log
04/03/2024 14:10:51 WARNING: Hardware and system checks ignored.
04/03/2024 14:10:59 INFO: Wazuh indexer cluster security configuration initialized.
04/03/2024 14:11:00 INFO: The Wazuh indexer cluster ISM initialized.
04/03/2024 14:11:02 INFO: Updating the internal users.
04/03/2024 14:11:07 INFO: A backup of the internal users has been saved in the /etc/wazuh-indexer/internalusers-backup folder.
04/03/2024 14:11:24 INFO: Wazuh indexer cluster started.
root@ubuntu22:/home/vagrant# 

Tests

:green_circle: RHEL7 https://ci.wazuh.info/job/Test_unattended/5379/ :green_circle: AL2 https://ci.wazuh.info/job/Test_unattended/5378/ :green_circle: Ubuntu Focal https://ci.wazuh.info/job/Test_unattended/5377/ :green_circle: Ubuntu Xenial https://ci.wazuh.info/job/Test_unattended/5376/ :green_circle: Ubuntu Bionic https://ci.wazuh.info/job/Test_unattended/5375/ :green_circle: CentOS 8 https://ci.wazuh.info/job/Test_unattended/5374/ :green_circle: CentOS 7 https://ci.wazuh.info/job/Test_unattended/5373/ :green_circle: RHEL8 https://ci.wazuh.info/job/Test_unattended/5372/