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

Implement Vagrantfile for generic testing environment #474

Merged
merged 6 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions test-tools/basic_env/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Basic cluster environment

This is a environment definition with the required configuration to be prepared to freshly install a Wazuh Indexer
cluster with two nodes using Vagrant and Libvirt to provision the Virtual Machines.

It also generates the node's required certificates using the `wazuh-certs-tool` and copy them to each node's `home`
directory, leaving a copy in `test-tools/basic_env`.


### Prequisites

1. Download and install Vagrant ([source](https://developer.hashicorp.com/vagrant/downloads))
2. Install vagrant-libvirt ([source](https://vagrant-libvirt.github.io/vagrant-libvirt/installation.html))
> In some cases you must also install `libvirt-dev`

## Usage

1. Navigate to the environment's root directory
```bash
cd test-tools/basic_env
```
2. Initialize the environment
```bash
vagrant up
```
3. Connect to the different systems
```bash
vagrant ssh indexer_[1|2]
```

### Cleanup

After the testing session is complete you can stop or destroy the environment as you wish:
- Stop the environment:
```bash
vagrant halt
```
- Destroy the environment:
```bash
vagrant destroy -f
```
45 changes: 45 additions & 0 deletions test-tools/basic_env/Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
Vagrant.configure("2") do |config|
config.vm.define "indexer_1" do |indexer_1|
indexer_1.vm.box = "generic/rhel9"
indexer_1.vm.synced_folder ".", "/vagrant"
indexer_1.vm.network "private_network", ip: "192.168.56.10"
indexer_1.vm.hostname = "node-1"
indexer_1.vm.provider "libvirt" do |vb|
vb.memory = "6144"
vb.cpus = "4"
end
indexer_1.vm.provision "shell", inline: <<-SHELL
sudo systemctl stop firewalld
sudo systemctl disable firewalld
sudo yum clean all
# Add node-2 to /etc/hosts
echo "192.168.56.11 node-2" >> /etc/hosts
# Generate certificates
cp /vagrant/config.yml config.yml
curl -sO https://packages.wazuh.com/4.9/wazuh-certs-tool.sh
bash ./wazuh-certs-tool.sh -A
# Compress and share certificates
tar -cvf ./wazuh-certificates.tar -C ./wazuh-certificates/ .
rm -rf ./wazuh-certificates *.yml *.log *.sh
cp wazuh-certificates.tar /vagrant/wazuh-vertificates.tar
SHELL
end
config.vm.define "indexer_2" do |indexer_2|
indexer_2.vm.box = "generic/ubuntu2204"
indexer_2.vm.synced_folder ".", "/vagrant"
indexer_2.vm.network "private_network", ip: "192.168.56.11"
indexer_2.vm.hostname = "node-2"
indexer_2.vm.provider "libvirt" do |vb|
vb.memory = "6144"
vb.cpus = "4"
end
indexer_2.vm.provision "shell", inline: <<-SHELL
sudo systemctl stop ufw
sudo systemctl disable ufw
# Add node-1 to /etc/hosts
echo "192.168.56.10 node-1" >> /etc/hosts
# Copy generated certificates
cp /vagrant/wazuh-vertificates.tar wazuh-vertificates.tar
SHELL
end
end
7 changes: 7 additions & 0 deletions test-tools/basic_env/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
nodes:
# Wazuh indexer nodes
indexer:
- name: node-1
ip: "192.168.56.10"
- name: node-2
ip: "192.168.56.11"