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 cluster checks to kibana installation #1184

Merged

Conversation

DFolchA
Copy link
Contributor

@DFolchA DFolchA commented Jan 19, 2022

Related issue

Description

This PR adds check for the elasticsearch cluster to the kibana installation.

Logs example

### Failure ##
[root@centos repo]# ./wazuh_install.sh -l -k KI_C -d
20/01/2022 09:48:35 INFO: Check recommended minimum hardware requirements for Kibana done.
20/01/2022 09:48:35 INFO: Starting all necessary utility installation.
20/01/2022 09:48:35 INFO: All necessary utility installation finished.
20/01/2022 09:48:35 INFO: Adding the Wazuh repository.
20/01/2022 09:48:36 INFO: Wazuh repository added.
20/01/2022 09:48:36 INFO: Starting Kibana installation.
20/01/2022 09:50:02 INFO: Kibana installation finished.
20/01/2022 09:50:23 INFO: Wazuh Kibana plugin installed.
20/01/2022 09:50:24 INFO: Kibana certificate setup finished.
20/01/2022 09:50:24 INFO: Setting passwords.
20/01/2022 09:50:25 INFO: Kibana started
20/01/2022 09:50:25 INFO: Starting service kibana.
20/01/2022 09:50:25 INFO: Kibana service started.
20/01/2022 09:50:25 INFO: Starting Kibana (this may take a while).
20/01/2022 09:52:26 ERROR: Cannot connect to Kibana.
20/01/2022 09:52:26 ERROR: Failed to connect with nodes ES_U ES_C. Connection refused.
20/01/2022 09:52:26 INFO: If want to install Kibana without waiting for the Elasticsearch cluster, use the -F option
20/01/2022 09:52:26 INFO: Cleaning the installation.
20/01/2022 09:52:26 WARNING: Removing Kibana.
20/01/2022 09:52:29 INFO: Installation cleaned. Check the /var/log/wazuh-unattended-installation.log file to learn more about the issue.

##### Ignore ####
[root@centos repo]# ./wazuh_install.sh -l -d -o -k KI_C -F
19/01/2022 16:27:42 INFO: Check recommended minimum hardware requirements for Kibana done.
19/01/2022 16:27:42 INFO: Starting all necessary utility installation.
19/01/2022 16:27:43 INFO: All necessary utility installation finished.
19/01/2022 16:27:43 INFO: Adding the Wazuh repository.
19/01/2022 16:27:43 INFO: Wazuh repository added.
19/01/2022 16:27:43 INFO: Starting Kibana installation.
19/01/2022 16:28:40 INFO: Kibana installation finished.
19/01/2022 16:28:58 INFO: Wazuh Kibana plugin installed.
19/01/2022 16:29:00 INFO: Kibana certificate setup finished.
19/01/2022 16:29:00 INFO: Setting passwords.
19/01/2022 16:29:00 INFO: Kibana started
19/01/2022 16:29:00 INFO: Starting service kibana.
19/01/2022 16:29:01 INFO: Kibana service started.
19/01/2022 16:29:01 INFO: Starting Kibana (this may take a while).
19/01/2022 16:31:02 WARNING: Cannot connect to Kibana.
19/01/2022 16:31:02 WARNING: Failed to connect with nodes ES_U ES_C. Connection refused.
19/01/2022 16:31:02 INFO: When Kibana is able to connect to your elasticsearch cluster, you can access the web interface https://172.16.1.29. The credentials are admin:NS2dx84IEmNanHnO1N6EHlfAB1K26ygB
19/01/2022 16:31:02 INFO: The Wazuh repository set to production.
19/01/2022 16:31:02 INFO: Installation finished.

### OK installation###

[root@centos repo]# ./wazuh_install.sh -l -d -o -k KI_C
19/01/2022 16:36:11 INFO: Check recommended minimum hardware requirements for Kibana done.
19/01/2022 16:36:11 INFO: Starting all necessary utility installation.
19/01/2022 16:36:11 INFO: All necessary utility installation finished.
19/01/2022 16:36:11 INFO: Adding the Wazuh repository.
19/01/2022 16:36:13 INFO: Wazuh repository added.
19/01/2022 16:36:13 INFO: Starting Kibana installation.
19/01/2022 16:37:08 INFO: Kibana installation finished.
19/01/2022 16:37:25 INFO: Wazuh Kibana plugin installed.
19/01/2022 16:37:27 INFO: Kibana certificate setup finished.
19/01/2022 16:37:27 INFO: Setting passwords.
19/01/2022 16:37:28 INFO: Kibana started
19/01/2022 16:37:28 INFO: Starting service kibana.
19/01/2022 16:37:28 INFO: Kibana service started.
19/01/2022 16:37:28 INFO: Starting Kibana (this may take a while).
19/01/2022 16:37:38 INFO: You can access the web interface https://172.16.1.29. The credentials are admin:NS2dx84IEmNanHnO1N6EHlfAB1K26ygB
19/01/2022 16:37:38 INFO: The Wazuh repository set to production.
19/01/2022 16:37:38 INFO: Installation finished.

Tests

  • Build the package in any supported platform
    • Linux
    • Windows
    • macOS
    • Solaris
    • AIX
    • HP-UX
  • Package installation
  • Package upgrade
  • Package downgrade
  • Package remove
  • Package install/remove/install
  • Change added to CHANGELOG.md
  • Tests for Linux RPM
    • Build the package for x86_64
    • Build the package for i386
    • Build the package for armhf
    • Build the package for aarch64
    • %files section is correctly updated if necessary
  • Tests for Linux deb
    • Build the package for x86_64
    • Build the package for i386
    • Build the package for armhf
    • Build the package for aarch64
    • Package install/remove/install
    • Package install/purge/install
    • Check file permissions after installing the package
  • Tests for macOS
    • Test the package from macOS Sierra to Mojave
  • Tests for Solaris
    • Test the package on Solaris 10
    • Test the package on Solaris 11
    • Check file permissions on Solaris 11 template
  • Tests for IBM AIX
    • %files section is correctly updated if necessary
    • Check the changes from IBM AIX 5 to 7

@DFolchA DFolchA changed the base branch from master to unify-unattended January 19, 2022 17:13
@DFolchA
Copy link
Contributor Author

DFolchA commented Jan 20, 2022

Unit tests

dfolch@pop-os:~/wazuh-packages/tests/unattended/unit$ sudo bash unit-tests.sh -r  -a
20/01/2022 12:22:53 INFO: Removing old image.
Error: No such image: unattended-installer-unit-tests-launcher
20/01/2022 12:22:53 INFO: Building image.
20/01/2022 12:22:54 INFO: Docker image built successfully.
20/01/2022 12:22:54 INFO: Unit tests for common.sh.
1..75
ok 1 - rollBack kibana installation all installed zypper
ok 2 - getPass no args
ok 3 - rollBack nothing installed remove /etc/systemd/system/multi user.target.wants/kibana.service
ok 4 - rollBack aio all remaining files yum
ok 5 - rollBack aio all remaining files apt
ok 6 - rollBack wazuh installation all installed zypper
ok 7 - ASSERT FAIL getConfig no args
ok 8 - addWazuhrepo zypper
ok 9 - readPasswordFileUsers changeall correct
ok 10 - rollBack kibana installation all installed apt
ok 11 - rollBack aio all remaining files zypper
ok 12 - rollBack nothing installed remove /lib/firewalld/services/kibana.xml
ok 13 - ASSERT FAIL startService no args
ok 14 - rollBack nothing installed remove /securityadmin_demo.sh
ok 15 - installPrerequisites zypper no openssl
ok 16 - rollBack aio all installed zypper
ok 17 - rollBack elasticsearch installation all installed apt
ok 18 - rollBack aio all installed apt
ok 19 - rollBack nothing installed remove /var/log/elasticsearch/
ok 20 - changePasswords with tarfile aio
ok 21 - readPasswordFileUsers no changeall filebeat correct
ok 22 - rollBack nothing installed remove /etc/systemd/system/multi user.target.wants/elasticsearch.service
ok 23 - getConfig online error
ok 24 - restoreWazuhrepo apt
ok 25 - getConfig local error
ok 26 - ASSERT FAIL readPasswordFileUsers file incorrect
ok 27 - restoreWazuhrepo apt no file
ok 28 - addWazuhrepo yum
ok 29 - restoreWazuhrepo zypper
ok 30 - restoreWazuhrepo zypper no file
ok 31 - installPrerequisites apt no openssl
ok 32 - rollBack nothing installed remove yum repo
ok 33 - ASSERT FAIL changePasswords no tarfile
ok 34 - rollBack nothing installed remove /etc/systemd/system/multi user.target.wants/wazuh manager.service
ok 35 - startService rc.d/init.d
ok 36 - createCertificates no aio
ok 37 - restoreWazuhrepo no dev
ok 38 - addWazuhrepo yum file present
ok 39 - rollBack wazuh installation all installed yum
ok 40 - readPasswordFileUsers changeall user doesnt exist
ok 41 - changePasswords with tarfile start elastic cluster
ok 42 - installPrerequisites zypper no libcap progs
ok 43 - rollBack elasticsearch installation all installed zypper
ok 44 - createCertificates aio
ok 45 - createClusterKey
ok 46 - addWazuhrepo apt
ok 47 - rollBack nothing installed remove /var/log/filebeat/
ok 48 - startService systemd error
ok 49 - getConfig online
ok 50 - addWazuhrepo zypper file present
ok 51 - rollBack aio nothing installed
ok 52 - rollBack nothing installed remove /lib/firewalld/services/elasticsearch.xml
ok 53 - startService initd error
ok 54 - rollBack nothing installed remove /etc/systemd/system/kibana.service
ok 55 - ASSERT FAIL startService no service manager
ok 56 - addWazuhrepo apt file present
ok 57 - getPass admin
ok 58 - startService initd
ok 59 - rollBack aio all installed yum
ok 60 - installPrerequisites apt
ok 61 - restoreWazuhrepo yum
ok 62 - rollBack nothing installed remove zypper repo
ok 63 - readPasswordFileUsers no changeall kibana correct
ok 64 - restoreWazuhrepo yum no file
ok 65 - installPrerequisites yum
ok 66 - installPrerequisites yum no openssl
ok 67 - rollBack kibana installation all installed yum
ok 68 - ASSERT FAIL getConfig one argument
ok 69 - getConfig local
ok 70 - startService systemd
ok 71 - rollBack elasticsearch installation all installed yum
ok 72 - rollBack nothing installed remove /etc/systemd/system/elasticsearch.service.wants
ok 73 - rollBack wazuh installation all installed apt
ok 74 - rollBack nothing installed remove /etc/systemd/system/multi user.target.wants/filebeat.service
ok 75 - changePasswords with tarfile
# -----
# All tests: 75, failed: 0, skipped: 0
20/01/2022 12:22:59 INFO: All unit tests for the functions in common.sh finished.
20/01/2022 12:22:59 INFO: Unit tests for checks.sh.
1..79
ok 1 - checkArguments install wazuh filebeat remaining files overwrite
ok 2 - checkNames all correct installing kibana
ok 3 - ASSERT FAIL checkArguments install aio elastic installed no overwrite
ok 4 - ASSERT FAIL checkArguments uninstall and wazuh
ok 5 - checkArguments install aio wazuh installed overwrite
ok 6 - checkArguments install kibana already installed overwrite
ok 7 - ASSERT FAIL checkArguments certificate creation certs file present
ok 8 - ASSERT FAIL checkNames kibana node name not in config
ok 9 - checkArguments install wazuh already installed overwrite
ok 10 - ASSERT FAIL checkNames wazuh node name not in config
ok 11 - ASSERT FAIL checkArguments install kibana remaining files no overwrite
ok 12 - ASSERT FAIL checkNames kibana wazuh equals
ok 13 - ASSERT FAIL checkArguments uninstall and kibana
ok 14 - checkArguments install aio kibana installed overwrite
ok 15 - ASSERT FAIL checkArguments install wazuh remaining files no overwrite
ok 16 - checkHealth elasticsearch 2 cores 3700 ram
ok 17 - ASSERT FAIL checkSystem empty
ok 18 - ASSERT FAIL checkHealth AIO 2 cores 3000 ram
ok 19 - ASSERT FAIL checkNames elastic wazuh equals
ok 20 - checkPreviousCertificates all correct
ok 21 - ASSERT FAIL checkHealth AIO 1 core 3700 ram
ok 22 - checkArguments uninstall no component installed
ok 23 - checkArguments install wazuh filebeat already installed overwrite
ok 24 - ASSERT FAIL checkArguments install aio and elastic
ok 25 - ASSERT FAIL checkArch empty
ok 26 - ASSERT FAIL checkArguments install aio wazuh installed no overwrite
ok 27 - checkHealth kibana 2 cores 3700 ram
ok 28 - checkArch x86_64
ok 29 - ASSERT FAIL checkArguments uninstall and aio
ok 30 - ASSERT FAIL checkArguments install aio wazuh files no overwrite
ok 31 - checkNames all correct installing wazuh
ok 32 - checkArguments install aio kibana files overwrite
ok 33 - ASSERT FAIL checkPreviousCertificates winame not in tar_file
ok 34 - checkNames all correct installing elastic
ok 35 - checkSystem yum
ok 36 - checkIfInstalled nothing installed apt
ok 37 - checkArguments install kibana remaining files overwrite
ok 38 - ASSERT FAIL checkArguments install elastic remaining files no overwrite
ok 39 - ASSERT FAIL checkPreviousCertificates kiname not in tar_file
ok 40 - checkArguments install aio elastic files overwrite
ok 41 - ASSERT FAIL checkPreviousCertificates no tar_file
ok 42 - ASSERT FAIL checkArguments install aio and wazuh
ok 43 - checkHealth wazuh 2 cores 1700 ram
ok 44 - ASSERT FAIL checkArguments install wazuh already installed no overwrite
ok 45 - ASSERT FAIL checkArguments install wazuh filebeat already installed no overwrite
ok 46 - ASSERT FAIL checkHealth kibana 2 cores 3000 ram
ok 47 - checkIfInstalled nothing installed zypper
ok 48 - ASSERT FAIL checkPreviousCertificates einame not in tar_file
ok 49 - ASSERT FAIL checkNames elasticsearch node name not in config
ok 50 - checkHealth no installation
ok 51 - ASSERT FAIL checkArguments overwrite with no component installed
ok 52 - ASSERT FAIL checkHealth wazuh 2 cores 1000 ram
ok 53 - ASSERT FAIL checkArguments install aio elastic files no overwrite
ok 54 - checkArguments install elastic remaining files overwrite
ok 55 - ASSERT FAIL checkHealth elasticsearch 1 core 3700 ram
ok 56 - ASSERT FAIL checkArguments uninstall and elasticsearch
ok 57 - ASSERT FAIL checkHealth wazuh 1 core 1700 ram
ok 58 - ASSERT FAIL checkHealth elasticsearch 2 cores 3000 ram
ok 59 - checkIfInstalled all installed zypper
ok 60 - checkIfInstalled all installed apt
ok 61 - ASSERT FAIL checkArguments install kibana already installed no overwrite
ok 62 - ASSERT FAIL checkArch i386
ok 63 - checkArguments install wazuh remaining files overwrite
ok 64 - ASSERT FAIL checkArguments install aio kibana files no overwrite
ok 65 - checkIfInstalled nothing installed yum
ok 66 - ASSERT FAIL checkNames elastic kibana equals
ok 67 - checkSystem apt
ok 68 - checkArguments install aio elastic installed overwrite
ok 69 - ASSERT FAIL checkArguments install elastic already installed no overwrite
ok 70 - checkHealth AIO 2 cores 4gb
ok 71 - checkIfInstalled all installed yum
ok 72 - ASSERT FAIL checkArguments install wazuh filebeat remaining files no overwrite
ok 73 - checkSystem zypper
ok 74 - ASSERT FAIL checkArguments install aio certs file present
ok 75 - ASSERT FAIL checkArguments install aio kibana installed no overwrite
ok 76 - ASSERT FAIL checkArguments install aio and kibana
ok 77 - checkArguments install elastic already installed overwrite
ok 78 - ASSERT FAIL checkHealth kibana 1 core 3700 ram
ok 79 - checkArguments install aio wazuh files overwrite
# -----
# All tests: 79, failed: 0, skipped: 0
20/01/2022 12:23:02 INFO: All unit tests for the functions in checks.sh finished.
20/01/2022 12:23:02 INFO: Unit tests for wazuh.sh.
1..7
ok 1 - configureWazuhCluster
ok 2 - installWazuh zypper error
ok 3 - installWazuh yum
ok 4 - installWazuh yum error
ok 5 - installWazuh zypper
ok 6 - installWazuh apt error
ok 7 - installWazuh apt
# -----
# All tests: 7, failed: 0, skipped: 0
20/01/2022 12:23:03 INFO: All unit tests for the functions in wazuh.sh finished.
20/01/2022 12:23:03 INFO: Unit tests for filebeat.sh.
1..14
ok 1 - configureFilebeat more than one elastic node
ok 2 - ASSERT FAIL installFilebeat apt error
ok 3 - installFilebeat apt
ok 4 - ASSERT FAIL copyCertificatesFilebeat no tarfile
ok 5 - ASSERT FAIL installFilebeat zypper error
ok 6 - configureFilebeat one elastic node
ok 7 - installFilebeat zypper
ok 8 - configureFilebeatAIO no previous variables
ok 9 - copyCertificatesFilebeat AIO
ok 10 - installFilebeat yum
ok 11 - copyCertificatesFilebeat distributed
ok 12 - configureFilebeatAIO
ok 13 - ASSERT FAIL installFilebeat yum error
ok 14 - configureFilebeat no previous variables
# -----
# All tests: 14, failed: 0, skipped: 0
20/01/2022 12:23:04 INFO: All unit tests for the functions in filebeat.sh finished.
20/01/2022 12:23:04 INFO: Unit tests for kibana.sh.
1..21
ok 1 - ASSERT FAIL initializeKibana distributed two kibana nodes two wazuh nodes curl error
ok 2 - configureKibana dist two kibana nodes two elastic nodes
ok 3 - ASSERT FAIL installKibana zypper error
ok 4 - ASSERT FAIL initializeKibanaAIO curl error
ok 5 - initializeKibana distributed one kibana node one wazuh node curl correct
ok 6 - ASSERT FAIL configureKibana dist error downloading plugin
ok 7 - initializeKibana distributed two kibana nodes two wazuh nodes curl error force
ok 8 - ASSERT FAIL installKibana apt error
ok 9 - copyKibanacerts
ok 10 - configureKibana dist one kibana node one elastic node
ok 11 - modifyKibanaLogin
ok 12 - ASSERT FAIL installKibana yum error
ok 13 - initializeKibanaAIO curl correct
ok 14 - ASSERT FAIL configureKibanaAIO error downloading plugin
ok 15 - installKibana zypper
ok 16 - installKibana yum
ok 17 - ASSERT FAIL copyKibanacerts no tarfile
ok 18 - ASSERT FAIL initializeKibana distributed one kibana node one wazuh node curl error
ok 19 - initializeKibana distributed two kibana nodes two wazuh nodes curl correct
ok 20 - installKibana apt
ok 21 - configureKibana AIO
# -----
# All tests: 21, failed: 0, skipped: 0
20/01/2022 12:23:07 INFO: All unit tests for the functions in kibana.sh finished.
20/01/2022 12:23:07 INFO: Cleaning temporary files.

@DFolchA DFolchA marked this pull request as ready for review January 20, 2022 11:24
Copy link
Contributor

@alberpilot alberpilot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@alberpilot alberpilot merged commit 9ea7ecf into unify-unattended Jan 20, 2022
@alberpilot alberpilot deleted the unify-unattended-check-elastic-status-kibana branch January 20, 2022 11:44
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.

3 participants