Skip to content

Commit

Permalink
Add pre-start bash script to generate the certificates
Browse files Browse the repository at this point in the history
  • Loading branch information
QU3B1M committed Oct 18, 2024
1 parent 053c94e commit 8e98fbe
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 10 deletions.
22 changes: 12 additions & 10 deletions test-tools/Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
system("
if [ #{ARGV[0]} = 'up' ]; then
echo 'Executing pre-start script.'
bash ./pre-start.sh
fi
")

Vagrant.configure("2") do |config|
config.vm.define "indexer_1" do |indexer_1|
indexer_1.vm.box = "generic/rhel9"
Expand All @@ -13,15 +20,9 @@ Vagrant.configure("2") do |config|
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-certificates.tar
sudo echo "192.168.56.11 node-2" >> /etc/hosts
# Copy generated certificates
cp /vagrant/wazuh-certificates.tar /home/vagrant/wazuh-certificates.tar
SHELL
end
config.vm.define "indexer_2" do |indexer_2|
Expand All @@ -36,10 +37,11 @@ Vagrant.configure("2") do |config|
indexer_2.vm.provision "shell", inline: <<-SHELL
sudo systemctl stop ufw
sudo systemctl disable ufw
sudo apt install sshpass -y
# Add node-1 to /etc/hosts
echo "192.168.56.10 node-1" >> /etc/hosts
# Copy generated certificates
cp /vagrant/wazuh-certificates.tar wazuh-certificates.tar
cp /vagrant/wazuh-certificates.tar /home/vagrant/wazuh-certificates.tar
SHELL
end
end
23 changes: 23 additions & 0 deletions test-tools/pre-start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

# SPDX-License-Identifier: Apache-2.0
# The OpenSearch Contributors require contributions made to
# this file be licensed under the Apache-2.0 license or a
# compatible open source license.

# Download the Wazuh certs tool
curl -sO https://packages.wazuh.com/4.9/wazuh-certs-tool.sh

# Make the script executable
chmod +x ./wazuh-certs-tool.sh

# Run the Wazuh certs tool
bash ./wazuh-certs-tool.sh -A

# Create a tarball of the generated certificates
tar -cvf ./wazuh-certificates.tar -C ./wazuh-certificates/ .

# Clean up
rm -rf ./wazuh-certificates wazuh-certs-tool.sh *.log

echo "Setup complete and certificates archived."

0 comments on commit 8e98fbe

Please sign in to comment.