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

Fixed token variable empty in Wazuh manager check #45

Merged
merged 3 commits into from
Aug 30, 2024

Conversation

davidcr01
Copy link
Contributor

@davidcr01 davidcr01 commented Aug 30, 2024

Description

Related: #44

The aim of this PR is to add a validation to the TOKEN variable when checking the Wazuh manager status.

Before this fix, the Wazuh manager API may not be ready, and then the TOKEN variable is empty. With this fix, a retry block has been added to fetch the token. If the token can not be fetched, the installation is roll-backed.

Testing

Wazuh manager installation
[root@ip-172-31-84-123 cloud-user]# bash wazuh-install.sh -ws wazuh-server -v
30/08/2024 10:53:35 DEBUG: Checking root permissions.
30/08/2024 10:53:35 DEBUG: Checking sudo package.
30/08/2024 10:53:35 INFO: Starting Wazuh installation assistant. Wazuh version: 4.9.0
30/08/2024 10:53:35 INFO: Verbose logging redirected to /var/log/wazuh-install.log
30/08/2024 10:53:35 DEBUG: YUM package manager will be used.
30/08/2024 10:53:35 DEBUG: Checking system distribution.
30/08/2024 10:53:35 DEBUG: Detected distribution name: centos
30/08/2024 10:53:35 DEBUG: Detected distribution version: 8
30/08/2024 10:53:35 DEBUG: Installing check dependencies.
30/08/2024 10:53:35 DEBUG: Checking Wazuh installation.
30/08/2024 10:53:35 DEBUG: There are Wazuh indexer remaining files.
30/08/2024 10:53:35 DEBUG: Checking system architecture.
30/08/2024 10:53:35 INFO: Verifying that your system meets the recommended minimum hardware requirements.
30/08/2024 10:53:35 DEBUG: CPU cores detected: 4
30/08/2024 10:53:35 DEBUG: Free RAM memory detected: 7595
30/08/2024 10:53:35 DEBUG: Checking previous certificate existence.
30/08/2024 10:53:35 INFO: --- Dependencies ---
30/08/2024 10:53:35 INFO: Installing lsof.
Last metadata expiration check: 0:04:21 ago on Fri 30 Aug 2024 10:49:15 AM UTC. Dependencies resolved. ================================================================================ Package Architecture Version Repository Size ================================================================================ Installing: lsof x86_64 4.93.2-1.el8 baseos 253 k Transaction Summary ================================================================================ Install 1 Package Total download size: 253 k Installed size: 623 k Downloading Packages: lsof-4.93.2-1.el8.x86_64.rpm 11 MB/s | 253 kB 00:00 -------------------------------------------------------------------------------- Total 11 MB/s | 253 kB 00:00 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : lsof-4.93.2-1.el8.x86_64 1/1 Running scriptlet: lsof-4.93.2-1.el8.x86_64 1/1 Verifying : lsof-4.93.2-1.el8.x86_64 1/1 Installed: lsof-4.93.2-1.el8.x86_64 Complete!
Last metadata expiration check: 0:04:21 ago on Fri 30 Aug 2024 10:49:15 AM UTC. Dependencies resolved. ================================================================================ Package Architecture Version Repository Size ================================================================================ Installing: lsof x86_64 4.93.2-1.el8 baseos 253 k Transaction Summary ================================================================================ Install 1 Package Total download size: 253 k Installed size: 623 k Downloading Packages: lsof-4.93.2-1.el8.x86_64.rpm 11 MB/s | 253 kB 00:00 -------------------------------------------------------------------------------- Total 11 MB/s | 253 kB 00:00 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : lsof-4.93.2-1.el8.x86_64 1/1 Running scriptlet: lsof-4.93.2-1.el8.x86_64 1/1 Verifying : lsof-4.93.2-1.el8.x86_64 1/1 Installed: lsof-4.93.2-1.el8.x86_64 Complete!
30/08/2024 10:53:38 DEBUG: Checking ports availability.
30/08/2024 10:53:38 DEBUG: Checking curl tool version.
30/08/2024 10:53:38 DEBUG: Adding the Wazuh repository.
[wazuh]
gpgcheck=1
gpgkey=https://packages-dev.wazuh.com/key/GPG-KEY-WAZUH
enabled=1
name=EL-${releasever} - Wazuh
baseurl=https://packages-dev.wazuh.com/pre-release/yum/
protect=1
30/08/2024 10:53:38 INFO: Wazuh development repository added.
30/08/2024 10:53:38 DEBUG: Extracting Wazuh configuration.
30/08/2024 10:53:38 DEBUG: Reading configuration file.
30/08/2024 10:53:38 DEBUG: Checking if 127.0.0.1 is private.
30/08/2024 10:53:38 DEBUG: Checking if 127.0.0.1 is private.
30/08/2024 10:53:38 DEBUG: Checking if 127.0.0.1 is private.
30/08/2024 10:53:38 DEBUG: Checking node names in the configuration file.
30/08/2024 10:53:38 INFO: --- Wazuh server ---
30/08/2024 10:53:38 INFO: Starting the Wazuh manager installation.
EL-8 - Wazuh 12 kB/s | 3.5 kB 00:00 Dependencies resolved. ================================================================================ Package Architecture Version Repository Size ================================================================================ Installing: wazuh-manager x86_64 4.9.0-1 wazuh 304 M Transaction Summary ================================================================================ Install 1 Package Total download size: 304 M Installed size: 857 M Downloading Packages: wazuh-manager-4.9.0-1.x86_64.rpm 104 MB/s | 304 MB 00:02 -------------------------------------------------------------------------------- Total 104 MB/s | 304 MB 00:02 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Running scriptlet: wazuh-manager-4.9.0-1.x86_64 1/1 Installing : wazuh-manager-4.9.0-1.x86_64 1/1 Running scriptlet: wazuh-manager-4.9.0-1.x86_64 1/1 Verifying : wazuh-manager-4.9.0-1.x86_64 1/1 Installed: wazuh-manager-4.9.0-1.x86_64 Complete!
30/08/2024 10:54:48 DEBUG: Checking Wazuh installation.
30/08/2024 10:54:48 DEBUG: There are Wazuh remaining files.
30/08/2024 10:54:48 DEBUG: There are Wazuh indexer remaining files.
30/08/2024 10:54:48 INFO: Wazuh manager installation finished.
30/08/2024 10:54:48 DEBUG: Configuring Wazuh manager.
30/08/2024 10:54:48 DEBUG: Setting provisional Wazuh indexer password.
30/08/2024 10:54:48 INFO: Wazuh manager vulnerability detection configuration finished.
30/08/2024 10:54:48 INFO: Starting service wazuh-manager.
Created symlink /etc/systemd/system/multi-user.target.wants/wazuh-manager.service → /usr/lib/systemd/system/wazuh-manager.service.
30/08/2024 10:54:59 INFO: wazuh-manager service started.
30/08/2024 10:54:59 INFO: Checking Wazuh API connection
30/08/2024 10:54:59 INFO: Wazuh API connection successful
30/08/2024 10:54:59 INFO: Starting Filebeat installation.
Last metadata expiration check: 0:01:21 ago on Fri 30 Aug 2024 10:53:39 AM UTC. Dependencies resolved. ================================================================================ Package Architecture Version Repository Size ================================================================================ Installing: filebeat x86_64 7.10.2-1 wazuh 21 M Transaction Summary ================================================================================ Install 1 Package Total download size: 21 M Installed size: 70 M Downloading Packages: filebeat-oss-7.10.2-x86_64.rpm 31 MB/s | 21 MB 00:00 -------------------------------------------------------------------------------- Total 31 MB/s | 21 MB 00:00 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : filebeat-7.10.2-1.x86_64 1/1 Running scriptlet: filebeat-7.10.2-1.x86_64 1/1 Verifying : filebeat-7.10.2-1.x86_64 1/1 Installed: filebeat-7.10.2-1.x86_64 Complete!
30/08/2024 10:55:05 DEBUG: Checking Wazuh installation.
30/08/2024 10:55:05 DEBUG: There are Wazuh remaining files.
30/08/2024 10:55:05 DEBUG: There are Wazuh indexer remaining files.
30/08/2024 10:55:05 DEBUG: There are Filebeat remaining files.
30/08/2024 10:55:05 INFO: Filebeat installation finished.
30/08/2024 10:55:05 DEBUG: Configuring Filebeat.
30/08/2024 10:55:05 DEBUG: Filebeat template was download successfully.
wazuh/
wazuh/_meta/
wazuh/_meta/docs.asciidoc
wazuh/_meta/fields.yml
wazuh/_meta/config.yml
wazuh/alerts/
wazuh/alerts/config/
wazuh/alerts/config/alerts.yml
wazuh/alerts/manifest.yml
wazuh/alerts/ingest/
wazuh/alerts/ingest/pipeline.json
wazuh/module.yml
wazuh/archives/
wazuh/archives/config/
wazuh/archives/config/archives.yml
wazuh/archives/manifest.yml
wazuh/archives/ingest/
wazuh/archives/ingest/pipeline.json
30/08/2024 10:55:05 DEBUG: Filebeat module was downloaded successfully.
30/08/2024 10:55:05 DEBUG: Copying Filebeat certificates.
Created filebeat keystore
Successfully updated the keystore
Successfully updated the keystore
30/08/2024 10:55:06 INFO: Filebeat post-install configuration finished.
30/08/2024 10:55:06 DEBUG: Setting Wazuh indexer cluster passwords.
30/08/2024 10:55:06 DEBUG: Checking Wazuh installation.
30/08/2024 10:55:06 DEBUG: There are Wazuh remaining files.
30/08/2024 10:55:06 DEBUG: There are Wazuh indexer remaining files.
30/08/2024 10:55:06 DEBUG: There are Filebeat remaining files.
Successfully updated the keystore
Successfully updated the keystore
30/08/2024 10:55:07 INFO: The filebeat.yml file has been updated to use the Filebeat Keystore username and password.
30/08/2024 10:55:07 DEBUG: Restarting filebeat service...
30/08/2024 10:55:07 DEBUG: filebeat started.
30/08/2024 10:55:07 DEBUG: Restarting wazuh-manager service...
30/08/2024 10:55:22 DEBUG: wazuh-manager started.
30/08/2024 10:55:22 DEBUG: Changing API passwords.
30/08/2024 10:55:24 INFO: Starting service filebeat.
Synchronizing state of filebeat.service with SysV service script with /usr/lib/systemd/systemd-sysv-install.
Executing: /usr/lib/systemd/systemd-sysv-install enable filebeat
Created symlink /etc/systemd/system/multi-user.target.wants/filebeat.service → /usr/lib/systemd/system/filebeat.service.
30/08/2024 10:55:24 INFO: filebeat service started.
30/08/2024 10:55:24 INFO: Checking Filebeat connection
30/08/2024 10:55:24 INFO: Filebeat connection successful
30/08/2024 10:55:24 INFO: --- Dependencies ---
30/08/2024 10:55:24 INFO: Removing lsof.
Dependencies resolved. ================================================================================ Package Architecture Version Repository Size ================================================================================ Removing: lsof x86_64 4.93.2-1.el8 @baseos 623 k Transaction Summary ================================================================================ Remove 1 Package Freed space: 623 k Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Erasing : lsof-4.93.2-1.el8.x86_64 1/1 Running scriptlet: lsof-4.93.2-1.el8.x86_64 1/1 Verifying : lsof-4.93.2-1.el8.x86_64 1/1 Removed: lsof-4.93.2-1.el8.x86_64 Complete!
30/08/2024 10:55:26 DEBUG: Restoring Wazuh repository.
30/08/2024 10:55:26 INFO: Installation finished.
Wazuh manager installation - forced retry
[root@ip-172-31-84-123 cloud-user]# bash wazuh-install.sh -ws wazuh-server -o -v
30/08/2024 11:02:57 DEBUG: Checking root permissions.
30/08/2024 11:02:57 DEBUG: Checking sudo package.
30/08/2024 11:02:57 INFO: Starting Wazuh installation assistant. Wazuh version: 4.9.0
30/08/2024 11:02:57 INFO: Verbose logging redirected to /var/log/wazuh-install.log
30/08/2024 11:02:57 DEBUG: YUM package manager will be used.
30/08/2024 11:02:57 DEBUG: Checking system distribution.
30/08/2024 11:02:57 DEBUG: Detected distribution name: centos
30/08/2024 11:02:57 DEBUG: Detected distribution version: 8
30/08/2024 11:02:57 DEBUG: Installing check dependencies.
30/08/2024 11:02:58 DEBUG: Checking Wazuh installation.
30/08/2024 11:02:58 DEBUG: There are Wazuh indexer remaining files.
30/08/2024 11:02:58 DEBUG: Checking system architecture.
30/08/2024 11:02:58 INFO: Verifying that your system meets the recommended minimum hardware requirements.
30/08/2024 11:02:58 DEBUG: CPU cores detected: 4
30/08/2024 11:02:58 DEBUG: Free RAM memory detected: 7595
30/08/2024 11:02:58 DEBUG: Checking previous certificate existence.
30/08/2024 11:02:58 INFO: --- Dependencies ---
30/08/2024 11:02:58 INFO: Installing lsof.
Last metadata expiration check: 0:13:43 ago on Fri 30 Aug 2024 10:49:15 AM UTC. Dependencies resolved. ================================================================================ Package Architecture Version Repository Size ================================================================================ Installing: lsof x86_64 4.93.2-1.el8 baseos 253 k Transaction Summary ================================================================================ Install 1 Package Total download size: 253 k Installed size: 623 k Downloading Packages: lsof-4.93.2-1.el8.x86_64.rpm 4.7 MB/s | 253 kB 00:00 -------------------------------------------------------------------------------- Total 4.6 MB/s | 253 kB 00:00 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : lsof-4.93.2-1.el8.x86_64 1/1 Running scriptlet: lsof-4.93.2-1.el8.x86_64 1/1 Verifying : lsof-4.93.2-1.el8.x86_64 1/1 Installed: lsof-4.93.2-1.el8.x86_64 Complete!
Last metadata expiration check: 0:13:43 ago on Fri 30 Aug 2024 10:49:15 AM UTC. Dependencies resolved. ================================================================================ Package Architecture Version Repository Size ================================================================================ Installing: lsof x86_64 4.93.2-1.el8 baseos 253 k Transaction Summary ================================================================================ Install 1 Package Total download size: 253 k Installed size: 623 k Downloading Packages: lsof-4.93.2-1.el8.x86_64.rpm 4.7 MB/s | 253 kB 00:00 -------------------------------------------------------------------------------- Total 4.6 MB/s | 253 kB 00:00 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : lsof-4.93.2-1.el8.x86_64 1/1 Running scriptlet: lsof-4.93.2-1.el8.x86_64 1/1 Verifying : lsof-4.93.2-1.el8.x86_64 1/1 Installed: lsof-4.93.2-1.el8.x86_64 Complete!
30/08/2024 11:03:00 DEBUG: Checking ports availability.
30/08/2024 11:03:00 DEBUG: Checking curl tool version.
30/08/2024 11:03:00 DEBUG: Adding the Wazuh repository.
[wazuh]
gpgcheck=1
gpgkey=https://packages-dev.wazuh.com/key/GPG-KEY-WAZUH
enabled=1
name=EL-${releasever} - Wazuh
baseurl=https://packages-dev.wazuh.com/pre-release/yum/
protect=1
30/08/2024 11:03:01 INFO: Wazuh development repository added.
30/08/2024 11:03:01 DEBUG: Extracting Wazuh configuration.
30/08/2024 11:03:01 DEBUG: Reading configuration file.
30/08/2024 11:03:01 DEBUG: Checking if 127.0.0.1 is private.
30/08/2024 11:03:01 DEBUG: Checking if 127.0.0.1 is private.
30/08/2024 11:03:01 DEBUG: Checking if 127.0.0.1 is private.
30/08/2024 11:03:01 DEBUG: Checking node names in the configuration file.
30/08/2024 11:03:01 INFO: --- Wazuh server ---
30/08/2024 11:03:01 INFO: Starting the Wazuh manager installation.
EL-8 - Wazuh 37 kB/s | 3.5 kB 00:00 Dependencies resolved. ================================================================================ Package Architecture Version Repository Size ================================================================================ Installing: wazuh-manager x86_64 4.9.0-1 wazuh 304 M Transaction Summary ================================================================================ Install 1 Package Total download size: 304 M Installed size: 857 M Downloading Packages: wazuh-manager-4.9.0-1.x86_64.rpm 114 MB/s | 304 MB 00:02 -------------------------------------------------------------------------------- Total 114 MB/s | 304 MB 00:02 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Running scriptlet: wazuh-manager-4.9.0-1.x86_64 1/1 Installing : wazuh-manager-4.9.0-1.x86_64 1/1 Running scriptlet: wazuh-manager-4.9.0-1.x86_64 1/1 Verifying : wazuh-manager-4.9.0-1.x86_64 1/1 Installed: wazuh-manager-4.9.0-1.x86_64 Complete!
30/08/2024 11:04:11 DEBUG: Checking Wazuh installation.
30/08/2024 11:04:11 DEBUG: There are Wazuh remaining files.
30/08/2024 11:04:11 DEBUG: There are Wazuh indexer remaining files.
30/08/2024 11:04:11 INFO: Wazuh manager installation finished.
30/08/2024 11:04:11 DEBUG: Configuring Wazuh manager.
30/08/2024 11:04:11 DEBUG: Setting provisional Wazuh indexer password.
30/08/2024 11:04:11 INFO: Wazuh manager vulnerability detection configuration finished.
30/08/2024 11:04:11 INFO: Starting service wazuh-manager.
Created symlink /etc/systemd/system/multi-user.target.wants/wazuh-manager.service → /usr/lib/systemd/system/wazuh-manager.service.
30/08/2024 11:04:22 INFO: wazuh-manager service started.
30/08/2024 11:04:22 INFO: Checking Wazuh API connection
30/08/2024 11:04:22 INFO: Attempt 1: Trying to get Wazuh API token
30/08/2024 11:04:25 INFO: Wazuh API connection successful
30/08/2024 11:04:25 INFO: Starting Filebeat installation.
Last metadata expiration check: 0:01:25 ago on Fri 30 Aug 2024 11:03:01 AM UTC. Dependencies resolved. ================================================================================ Package Architecture Version Repository Size ================================================================================ Installing: filebeat x86_64 7.10.2-1 wazuh 21 M Transaction Summary ================================================================================ Install 1 Package Total download size: 21 M Installed size: 70 M Downloading Packages: filebeat-oss-7.10.2-x86_64.rpm 25 MB/s | 21 MB 00:00 -------------------------------------------------------------------------------- Total 25 MB/s | 21 MB 00:00 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : filebeat-7.10.2-1.x86_64 1/1 Running scriptlet: filebeat-7.10.2-1.x86_64 1/1 Verifying : filebeat-7.10.2-1.x86_64 1/1 Installed: filebeat-7.10.2-1.x86_64 Complete!
30/08/2024 11:04:31 DEBUG: Checking Wazuh installation.
30/08/2024 11:04:31 DEBUG: There are Wazuh remaining files.
30/08/2024 11:04:31 DEBUG: There are Wazuh indexer remaining files.
30/08/2024 11:04:31 DEBUG: There are Filebeat remaining files.
30/08/2024 11:04:31 INFO: Filebeat installation finished.
30/08/2024 11:04:31 DEBUG: Configuring Filebeat.
30/08/2024 11:04:31 DEBUG: Filebeat template was download successfully.
wazuh/
wazuh/_meta/
wazuh/_meta/docs.asciidoc
wazuh/_meta/fields.yml
wazuh/_meta/config.yml
wazuh/alerts/
wazuh/alerts/config/
wazuh/alerts/config/alerts.yml
wazuh/alerts/manifest.yml
wazuh/alerts/ingest/
wazuh/alerts/ingest/pipeline.json
wazuh/module.yml
wazuh/archives/
wazuh/archives/config/
wazuh/archives/config/archives.yml
wazuh/archives/manifest.yml
wazuh/archives/ingest/
wazuh/archives/ingest/pipeline.json
30/08/2024 11:04:31 DEBUG: Filebeat module was downloaded successfully.
30/08/2024 11:04:31 DEBUG: Copying Filebeat certificates.
Created filebeat keystore
Successfully updated the keystore
Successfully updated the keystore
30/08/2024 11:04:32 INFO: Filebeat post-install configuration finished.
30/08/2024 11:04:32 DEBUG: Setting Wazuh indexer cluster passwords.
30/08/2024 11:04:32 DEBUG: Checking Wazuh installation.
30/08/2024 11:04:32 DEBUG: There are Wazuh remaining files.
30/08/2024 11:04:32 DEBUG: There are Wazuh indexer remaining files.
30/08/2024 11:04:32 DEBUG: There are Filebeat remaining files.
Successfully updated the keystore
Successfully updated the keystore
30/08/2024 11:04:33 INFO: The filebeat.yml file has been updated to use the Filebeat Keystore username and password.
30/08/2024 11:04:33 DEBUG: Restarting filebeat service...
30/08/2024 11:04:33 DEBUG: filebeat started.
30/08/2024 11:04:34 DEBUG: Restarting wazuh-manager service...
30/08/2024 11:04:48 DEBUG: wazuh-manager started.
30/08/2024 11:04:48 DEBUG: Changing API passwords.
30/08/2024 11:04:50 INFO: Starting service filebeat.
Synchronizing state of filebeat.service with SysV service script with /usr/lib/systemd/systemd-sysv-install.
Executing: /usr/lib/systemd/systemd-sysv-install enable filebeat
Created symlink /etc/systemd/system/multi-user.target.wants/filebeat.service → /usr/lib/systemd/system/filebeat.service.
30/08/2024 11:04:50 INFO: filebeat service started.
30/08/2024 11:04:50 INFO: Checking Filebeat connection
30/08/2024 11:04:50 INFO: Filebeat connection successful
30/08/2024 11:04:50 INFO: --- Dependencies ---
30/08/2024 11:04:50 INFO: Removing lsof.
Dependencies resolved. ================================================================================ Package Architecture Version Repository Size ================================================================================ Removing: lsof x86_64 4.93.2-1.el8 @baseos 623 k Transaction Summary ================================================================================ Remove 1 Package Freed space: 623 k Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Erasing : lsof-4.93.2-1.el8.x86_64 1/1 Running scriptlet: lsof-4.93.2-1.el8.x86_64 1/1 Verifying : lsof-4.93.2-1.el8.x86_64 1/1 Removed: lsof-4.93.2-1.el8.x86_64 Complete!
30/08/2024 11:04:52 DEBUG: Restoring Wazuh repository.
30/08/2024 11:04:52 INFO: Installation finished.
[root@ip-172-31-84-123 cloud-user]# 
Wazuh manager installation - forced failure
[root@ip-172-31-84-123 cloud-user]# bash wazuh-install.sh -ws wazuh-server -o -v
30/08/2024 10:58:33 DEBUG: Checking root permissions.
30/08/2024 10:58:33 DEBUG: Checking sudo package.
30/08/2024 10:58:33 INFO: Starting Wazuh installation assistant. Wazuh version: 4.9.0
30/08/2024 10:58:33 INFO: Verbose logging redirected to /var/log/wazuh-install.log
30/08/2024 10:58:33 DEBUG: YUM package manager will be used.
30/08/2024 10:58:33 DEBUG: Checking system distribution.
30/08/2024 10:58:33 DEBUG: Detected distribution name: centos
30/08/2024 10:58:33 DEBUG: Detected distribution version: 8
30/08/2024 10:58:33 DEBUG: Installing check dependencies.
30/08/2024 10:58:33 DEBUG: Checking Wazuh installation.
30/08/2024 10:58:33 DEBUG: There are Wazuh remaining files.
30/08/2024 10:58:33 DEBUG: There are Wazuh indexer remaining files.
30/08/2024 10:58:33 DEBUG: There are Filebeat remaining files.
30/08/2024 10:58:33 INFO: --- Removing existing Wazuh installation ---
30/08/2024 10:58:33 INFO: Removing Wazuh manager.
Dependencies resolved.
================================================================================
 Package                Architecture    Version           Repository       Size
================================================================================
Removing:
 wazuh-manager          x86_64          4.9.0-1           @wazuh          857 M

Transaction Summary
================================================================================
Remove  1 Package

Freed space: 857 M
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                        1/1 
  Running scriptlet: wazuh-manager-4.9.0-1.x86_64                           1/1 
  Erasing          : wazuh-manager-4.9.0-1.x86_64                           1/1 
warning: /var/ossec/etc/ossec.conf saved as /var/ossec/etc/ossec.conf.rpmsave

  Running scriptlet: wazuh-manager-4.9.0-1.x86_64                           1/1 
  Verifying        : wazuh-manager-4.9.0-1.x86_64                           1/1 

Removed:
  wazuh-manager-4.9.0-1.x86_64                                                  

Complete!
30/08/2024 10:59:00 INFO: Wazuh manager removed.
30/08/2024 10:59:00 INFO: Removing Filebeat.
Dependencies resolved.
================================================================================
 Package            Architecture     Version             Repository        Size
================================================================================
Removing:
 filebeat           x86_64           7.10.2-1            @wazuh            70 M

Transaction Summary
================================================================================
Remove  1 Package

Freed space: 70 M
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                        1/1 
  Erasing          : filebeat-7.10.2-1.x86_64                               1/1 
warning: /etc/filebeat/filebeat.yml saved as /etc/filebeat/filebeat.yml.rpmsave

  Running scriptlet: filebeat-7.10.2-1.x86_64                               1/1 
  Verifying        : filebeat-7.10.2-1.x86_64                               1/1 

Removed:
  filebeat-7.10.2-1.x86_64                                                      

Complete!
30/08/2024 10:59:00 WARNING: The Filebeat package could not be removed.
30/08/2024 10:59:00 DEBUG: Removing GPG key from system.
30/08/2024 10:59:00 INFO: Installation cleaned.
30/08/2024 10:59:00 DEBUG: Checking system architecture.
30/08/2024 10:59:00 INFO: Verifying that your system meets the recommended minimum hardware requirements.
30/08/2024 10:59:00 DEBUG: CPU cores detected: 4
30/08/2024 10:59:01 DEBUG: Free RAM memory detected: 7595
30/08/2024 10:59:01 DEBUG: Checking previous certificate existence.
30/08/2024 10:59:01 INFO: --- Dependencies ---
30/08/2024 10:59:01 INFO: Installing lsof.
Last metadata expiration check: 0:09:46 ago on Fri 30 Aug 2024 10:49:15 AM UTC. Dependencies resolved. ================================================================================ Package Architecture Version Repository Size ================================================================================ Installing: lsof x86_64 4.93.2-1.el8 baseos 253 k Transaction Summary ================================================================================ Install 1 Package Total download size: 253 k Installed size: 623 k Downloading Packages: lsof-4.93.2-1.el8.x86_64.rpm 10 MB/s | 253 kB 00:00 -------------------------------------------------------------------------------- Total 9.6 MB/s | 253 kB 00:00 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : lsof-4.93.2-1.el8.x86_64 1/1 Running scriptlet: lsof-4.93.2-1.el8.x86_64 1/1 Verifying : lsof-4.93.2-1.el8.x86_64 1/1 Installed: lsof-4.93.2-1.el8.x86_64 Complete!
Last metadata expiration check: 0:09:46 ago on Fri 30 Aug 2024 10:49:15 AM UTC. Dependencies resolved. ================================================================================ Package Architecture Version Repository Size ================================================================================ Installing: lsof x86_64 4.93.2-1.el8 baseos 253 k Transaction Summary ================================================================================ Install 1 Package Total download size: 253 k Installed size: 623 k Downloading Packages: lsof-4.93.2-1.el8.x86_64.rpm 10 MB/s | 253 kB 00:00 -------------------------------------------------------------------------------- Total 9.6 MB/s | 253 kB 00:00 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : lsof-4.93.2-1.el8.x86_64 1/1 Running scriptlet: lsof-4.93.2-1.el8.x86_64 1/1 Verifying : lsof-4.93.2-1.el8.x86_64 1/1 Installed: lsof-4.93.2-1.el8.x86_64 Complete!
30/08/2024 10:59:03 DEBUG: Checking ports availability.
30/08/2024 10:59:03 DEBUG: Checking curl tool version.
30/08/2024 10:59:03 DEBUG: Adding the Wazuh repository.
[wazuh]
gpgcheck=1
gpgkey=https://packages-dev.wazuh.com/key/GPG-KEY-WAZUH
enabled=1
name=EL-${releasever} - Wazuh
baseurl=https://packages-dev.wazuh.com/pre-release/yum/
protect=1
30/08/2024 10:59:04 INFO: Wazuh development repository added.
30/08/2024 10:59:04 DEBUG: Extracting Wazuh configuration.
30/08/2024 10:59:04 DEBUG: Reading configuration file.
30/08/2024 10:59:04 DEBUG: Checking if 127.0.0.1 is private.
30/08/2024 10:59:04 DEBUG: Checking if 127.0.0.1 is private.
30/08/2024 10:59:04 DEBUG: Checking if 127.0.0.1 is private.
30/08/2024 10:59:04 DEBUG: Checking node names in the configuration file.
30/08/2024 10:59:04 INFO: --- Wazuh server ---
30/08/2024 10:59:04 INFO: Starting the Wazuh manager installation.
EL-8 - Wazuh 11 kB/s | 3.5 kB 00:00 Dependencies resolved. ================================================================================ Package Architecture Version Repository Size ================================================================================ Installing: wazuh-manager x86_64 4.9.0-1 wazuh 304 M Transaction Summary ================================================================================ Install 1 Package Total download size: 304 M Installed size: 857 M Downloading Packages: wazuh-manager-4.9.0-1.x86_64.rpm 106 MB/s | 304 MB 00:02 -------------------------------------------------------------------------------- Total 106 MB/s | 304 MB 00:02 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Running scriptlet: wazuh-manager-4.9.0-1.x86_64 1/1 Installing : wazuh-manager-4.9.0-1.x86_64 1/1 Running scriptlet: wazuh-manager-4.9.0-1.x86_64 1/1 Verifying : wazuh-manager-4.9.0-1.x86_64 1/1 Installed: wazuh-manager-4.9.0-1.x86_64 Complete!
30/08/2024 11:00:13 DEBUG: Checking Wazuh installation.
30/08/2024 11:00:13 DEBUG: There are Wazuh remaining files.
30/08/2024 11:00:13 DEBUG: There are Wazuh indexer remaining files.
30/08/2024 11:00:13 INFO: Wazuh manager installation finished.
30/08/2024 11:00:13 DEBUG: Configuring Wazuh manager.
30/08/2024 11:00:13 DEBUG: Setting provisional Wazuh indexer password.
30/08/2024 11:00:14 INFO: Wazuh manager vulnerability detection configuration finished.
30/08/2024 11:00:14 INFO: Starting service wazuh-manager.
Created symlink /etc/systemd/system/multi-user.target.wants/wazuh-manager.service → /usr/lib/systemd/system/wazuh-manager.service.
30/08/2024 11:00:23 INFO: wazuh-manager service started.
30/08/2024 11:00:23 INFO: Checking Wazuh API connection
30/08/2024 11:00:23 INFO: Attempt 1: Trying to get Wazuh API token
30/08/2024 11:00:23 INFO: Attempt 2: Trying to get Wazuh API token
30/08/2024 11:00:23 INFO: Attempt 3: Trying to get Wazuh API token
30/08/2024 11:00:23 INFO: Attempt 4: Trying to get Wazuh API token
30/08/2024 11:00:23 INFO: Attempt 5: Trying to get Wazuh API token
30/08/2024 11:00:23 ERROR: Failed to obtain Wazuh API token after 5 attempts.
30/08/2024 11:00:23 INFO: --- Removing existing Wazuh installation ---
30/08/2024 11:00:23 INFO: Removing Wazuh manager.
Dependencies resolved.
================================================================================
 Package                Architecture    Version           Repository       Size
================================================================================
Removing:
 wazuh-manager          x86_64          4.9.0-1           @wazuh          857 M

Transaction Summary
================================================================================
Remove  1 Package

Freed space: 857 M
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                        1/1 
  Running scriptlet: wazuh-manager-4.9.0-1.x86_64                           1/1 
  Erasing          : wazuh-manager-4.9.0-1.x86_64                           1/1 
warning: /var/ossec/etc/ossec.conf saved as /var/ossec/etc/ossec.conf.rpmsave

  Running scriptlet: wazuh-manager-4.9.0-1.x86_64                           1/1 
  Verifying        : wazuh-manager-4.9.0-1.x86_64                           1/1 

Removed:
  wazuh-manager-4.9.0-1.x86_64                                                  

Complete!
30/08/2024 11:00:48 INFO: Wazuh manager removed.
30/08/2024 11:00:48 DEBUG: Removing GPG key from system.
30/08/2024 11:00:48 INFO: --- Dependencies ---
30/08/2024 11:00:48 INFO: Removing lsof.
Dependencies resolved. ================================================================================ Package Architecture Version Repository Size ================================================================================ Removing: lsof x86_64 4.93.2-1.el8 @baseos 623 k Transaction Summary ================================================================================ Remove 1 Package Freed space: 623 k Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Erasing : lsof-4.93.2-1.el8.x86_64 1/1 Running scriptlet: lsof-4.93.2-1.el8.x86_64 1/1 Verifying : lsof-4.93.2-1.el8.x86_64 1/1 Removed: lsof-4.93.2-1.el8.x86_64 Complete!
30/08/2024 11:00:49 INFO: Installation cleaned.
[root@ip-172-31-84-123 cloud-user]# 

After storing the API token command in a variable, it is checked that the command is executed correctly:

30/08/2024 11:52:49 INFO: Checking Wazuh API connection
++ eval '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"'
+++ 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
+ TOKEN=eyJhbGciOiJFUzUxMiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ3YXp1aCIsImF1ZCI6IldhenVoIEFQSSBSRVNUIiwibmJmIjoxNzI1MDE4NzcwLCJleHAiOjE3MjUwMTk2NzAsInN1YiI6IndhenVoLXd1aSIsInJ1bl9hcyI6dHJ1ZSwicmJhY19yb2xlcyI6W10sInJiYWNfbW9kZSI6IndoaXRlIiwiaGFzaF9hdXRoX2NvbnRleHQiOiI2ZTUxZGExOTNjMTFhYTVhYmQ0NDgxNTgxNjViZjJmNyJ9.AKXwHhaEYQgt04dCJSzKw7E-S4S149yGJJzNfBGIvRBElqonVQqhkiLU-ocPtePja7b61fiQiPmvp6QiryrDmsUNAeg-SK0BdulWFJbQvLSjcFlIPaEcbeHP4S_C80YLHN_xPBDpZ9EQQ224VBrbVwj4BLCSCGe7_KqJyLi9f1iurh4Y

@davidcr01 davidcr01 requested a review from a team August 30, 2024 11:09
@davidcr01 davidcr01 self-assigned this Aug 30, 2024
@davidcr01 davidcr01 changed the title Added not empty token variable check Fixed token variable empty in Wazuh manager check Aug 30, 2024
vcerenu
vcerenu previously approved these changes Aug 30, 2024
@c-bordon c-bordon merged commit 393c414 into 4.10.0 Aug 30, 2024
0 of 2 checks passed
@teddytpc1 teddytpc1 linked an issue Sep 2, 2024 that may be closed by this pull request
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.

Token variable is empty in manager check
3 participants