-
Notifications
You must be signed in to change notification settings - Fork 23
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
Implement Vagrantfile for generic testing environment #474
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vagrant failed to start
@alex-GL66 ➜ test-tools git:(enhancement/459-vagrantfile-for-testing) ✗ vagrant up
Bringing machine 'indexer_1' up with 'libvirt' provider...
Bringing machine 'indexer_2' up with 'libvirt' provider...
==> indexer_2: Checking if box 'generic/ubuntu2204' version '4.3.12' is up to date...
==> indexer_1: Checking if box 'generic/rhel9' version '4.3.12' is up to date...
==> indexer_2: Creating image (snapshot of base box volume).
==> indexer_1: Creating image (snapshot of base box volume).
==> indexer_2: Creating domain with the following settings...
==> indexer_1: Creating domain with the following settings...
==> indexer_2: -- Name: test-tools_indexer_2
==> indexer_1: -- Name: test-tools_indexer_1
==> indexer_2: -- Description: Source: /home/alex/wazuh/wazuh-indexer/test-tools/Vagrantfile
==> indexer_2: -- Domain type: kvm
==> indexer_2: -- Cpus: 4
==> indexer_1: -- Description: Source: /home/alex/wazuh/wazuh-indexer/test-tools/Vagrantfile
==> indexer_2: -- Feature: acpi
==> indexer_2: -- Feature: apic
==> indexer_1: -- Domain type: kvm
==> indexer_2: -- Feature: pae
==> indexer_1: -- Cpus: 4
==> indexer_2: -- Clock offset: utc
==> indexer_2: -- Memory: 6144M
==> indexer_1: -- Feature: acpi
==> indexer_2: -- Base box: generic/ubuntu2204
==> indexer_1: -- Feature: apic
==> indexer_2: -- Storage pool: default
==> indexer_1: -- Feature: pae
==> indexer_2: -- Image(vda): /var/lib/libvirt/images/test-tools_indexer_2.img, virtio, 128G
==> indexer_1: -- Clock offset: utc
==> indexer_2: -- Disk driver opts: cache='default'
==> indexer_1: -- Memory: 6144M
==> indexer_2: -- Graphics Type: vnc
==> indexer_1: -- Base box: generic/rhel9
==> indexer_2: -- Video Type: cirrus
==> indexer_1: -- Storage pool: default
==> indexer_2: -- Video VRAM: 256
==> indexer_1: -- Image(vda): /var/lib/libvirt/images/test-tools_indexer_1.img, virtio, 128G
==> indexer_1: -- Disk driver opts: cache='default'
==> indexer_2: -- Video 3D accel: false
==> indexer_1: -- Graphics Type: vnc
==> indexer_2: -- Keymap: en-us
==> indexer_1: -- Video Type: cirrus
==> indexer_2: -- TPM Backend: passthrough
==> indexer_1: -- Video VRAM: 256
==> indexer_2: -- INPUT: type=mouse, bus=ps2
==> indexer_1: -- Video 3D accel: false
==> indexer_1: -- Keymap: en-us
==> indexer_1: -- TPM Backend: passthrough
==> indexer_1: -- INPUT: type=mouse, bus=ps2
==> indexer_2: Creating shared folders metadata...
==> indexer_1: Creating shared folders metadata...
==> indexer_2: Starting domain.
==> indexer_1: Starting domain.
==> indexer_2: Domain launching with graphics connection settings...
==> indexer_1: Domain launching with graphics connection settings...
==> indexer_2: -- Graphics Port: 5900
==> indexer_1: -- Graphics Port: 5901
==> indexer_2: -- Graphics IP: 127.0.0.1
==> indexer_1: -- Graphics IP: 127.0.0.1
==> indexer_2: -- Graphics Password: Not defined
==> indexer_1: -- Graphics Password: Not defined
==> indexer_2: -- Graphics Websocket: 5700
==> indexer_1: -- Graphics Websocket: 5701
==> indexer_2: Waiting for domain to get an IP address...
==> indexer_1: Waiting for domain to get an IP address...
==> indexer_2: Waiting for machine to boot. This may take a few minutes...
indexer_2: SSH address: 192.168.121.225:22
indexer_2: SSH username: vagrant
indexer_2: SSH auth method: private key
indexer_2: Warning: Connection refused. Retrying...
==> indexer_1: Waiting for machine to boot. This may take a few minutes...
indexer_1: SSH address: 192.168.121.52:22
indexer_1: SSH username: vagrant
indexer_1: SSH auth method: private key
indexer_1:
indexer_1: Vagrant insecure key detected. Vagrant will automatically replace
indexer_1: this with a newly generated keypair for better security.
indexer_1:
indexer_1: Inserting generated public key within guest...
indexer_2: Warning: Connection refused. Retrying...
indexer_1: Removing insecure key from the guest if it's present...
indexer_1: Key inserted! Disconnecting and reconnecting using new SSH key...
==> indexer_1: Machine booted and ready!
==> indexer_1: Setting hostname...
==> indexer_1: Rsyncing folder: /home/alex/wazuh/wazuh-indexer/test-tools/ => /vagrant
indexer_2: Warning: Connection refused. Retrying...
==> indexer_1: Configuring and enabling network interfaces...
==> indexer_1: Running provisioner: shell...
indexer_1: Running: inline script
indexer_1: Removed "/etc/systemd/system/multi-user.target.wants/firewalld.service".
indexer_1: Removed "/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service".
indexer_1: 0 files removed
indexer_1: 18/10/2024 10:53:55 INFO: Verbose logging redirected to /home/vagrant/wazuh-certificates-tool.log
indexer_1: 18/10/2024 10:53:55 INFO: Generating the root certificate.
indexer_1: 18/10/2024 10:53:55 INFO: Generating Admin certificates.
indexer_1: 18/10/2024 10:53:55 INFO: Admin certificates created.
indexer_1: 18/10/2024 10:53:55 INFO: Generating Wazuh indexer certificates.
indexer_1: 18/10/2024 10:53:56 INFO: Wazuh indexer certificates created.
indexer_1: ./
indexer_1: ./root-ca.key
indexer_1: ./root-ca.pem
indexer_1: ./admin-key.pem
indexer_1: ./admin.pem
indexer_1: ./node-1-key.pem
indexer_1: ./node-1.pem
indexer_1: ./node-2-key.pem
indexer_1: ./node-2.pem
indexer_2: Warning: Connection refused. Retrying...
indexer_2: Warning: Connection refused. Retrying...
indexer_2: Warning: Connection refused. Retrying...
indexer_2: Warning: Connection refused. Retrying...
indexer_2: Warning: Connection refused. Retrying...
indexer_2: Warning: Connection refused. Retrying...
indexer_2: Warning: Connection refused. Retrying...
indexer_2: Warning: Connection refused. Retrying...
indexer_2: Warning: Connection refused. Retrying...
indexer_2:
indexer_2: Vagrant insecure key detected. Vagrant will automatically replace
indexer_2: this with a newly generated keypair for better security.
indexer_2:
indexer_2: Inserting generated public key within guest...
indexer_2: Removing insecure key from the guest if it's present...
indexer_2: Key inserted! Disconnecting and reconnecting using new SSH key...
==> indexer_2: Machine booted and ready!
==> indexer_2: Setting hostname...
==> indexer_2: Rsyncing folder: /home/alex/wazuh/wazuh-indexer/test-tools/ => /vagrant
==> indexer_2: Configuring and enabling network interfaces...
==> indexer_2: Running provisioner: shell...
indexer_2: Running: inline script
indexer_2: Synchronizing state of ufw.service with SysV service script with /lib/systemd/systemd-sysv-install.
indexer_2: Executing: /lib/systemd/systemd-sysv-install disable ufw
indexer_2: Removed /etc/systemd/system/multi-user.target.wants/ufw.service.
indexer_2: cp: cannot stat '/vagrant/wazuh-vertificates.tar': No such file or directory
==> indexer_2: An error occurred. The error will be shown after all tasks complete.
An error occurred while executing multiple actions in parallel.
Any errors that occurred are shown below.
An error occurred while executing the action on the 'indexer_2'
machine. Please handle this error then try again:
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.
63eab84
to
8e98fbe
Compare
Fixed the error at the provision stage on the vagrant start, it was caused by a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@alex-GL66 ➜ test-tools git:(enhancement/459-vagrantfile-for-testing) ✗ vagrant ssh indexer_2
vagrant@node-2:~$ ls
wazuh-certificates.tar
vagrant@node-2:~$ md5sum wazuh-certificates.tar
d41d8cd98f00b204e9800998ecf8427e wazuh-certificates.tar
vagrant@node-2:~$ ls -l
total 0
-rw-r--r-- 1 root root 0 Oct 18 15:39 wazuh-certificates.tar
vagrant@node-2:~$ exit
logout
@alex-GL66 ➜ test-tools git:(enhancement/459-vagrantfile-for-testing) ✗ vagrant ssh indexer_1
Register this system with Red Hat Insights: insights-client --register
Create an account or view all your systems at https://red.ht/insights-dashboard
Last login: Fri Oct 18 15:43:08 2024 from 192.168.121.1
[vagrant@node-1 ~]$ md5sum wazuh-certificates.tar
d41d8cd98f00b204e9800998ecf8427e wazuh-certificates.tar
* Add Vagrantfile and config.yml for generic testing environment setup * Rename vagrantfile storing directory * Add vagrant basic environment README.md * Remove basic_env folder * Fix typo on Vagrantfile * Add pre-start bash script to generate the certificates --------- Co-authored-by: Álex Ruiz <alejandro.ruiz.becerra@wazuh.com>
* Add Vagrantfile and config.yml for generic testing environment setup * Rename vagrantfile storing directory * Add vagrant basic environment README.md * Remove basic_env folder * Fix typo on Vagrantfile * Add pre-start bash script to generate the certificates --------- Co-authored-by: Álex Ruiz <alejandro.ruiz.becerra@wazuh.com>
* Add Vagrantfile and config.yml for generic testing environment setup * Rename vagrantfile storing directory * Add vagrant basic environment README.md * Remove basic_env folder * Fix typo on Vagrantfile * Add pre-start bash script to generate the certificates --------- Co-authored-by: Álex Ruiz <alejandro.ruiz.becerra@wazuh.com>
Description
Adds a Vagrantfile that provides and configure two VMs to be used as testing environment.
It generates the required certificates using the corresponding values of the nodes and copy them to each node's user
home
directory.Update
Due to
libvirt
limitations with shared folders, we discovered that provisioning failed when trying to copy generated certificates from the indexer_1 system to the indexer_2 system. To work around this, I added apre-start.sh
script that generates the certificates locally and copies them to the corresponding systemsRelated Issues
Check List