From 073bde71c49e3caa2b8f3cba5063dff9dc6cef3c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matev=C5=BE=20Er=C5=BEen?= <matevz.erzen@xlab.si>
Date: Fri, 1 Apr 2022 12:30:40 +0000
Subject: [PATCH] Vagrant update

---
 README.md                                 | 19 ++++++++++++-------
 environments/full-setup/Vagrantfile       |  5 -----
 environments/full-setup/full-setup.mk     |  3 +++
 environments/no-collector/no-collector.mk |  3 +++
 4 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/README.md b/README.md
index 73d38f2..f720e31 100644
--- a/README.md
+++ b/README.md
@@ -16,14 +16,17 @@ In addition to Wazuh, ClamAV is also installed on agent machines.
 
 ## Requirements
 
- * Vagrant 2.2.14
- * Ansible 2.9.16
+ * Vagrant `2.2.19`
+ * VirtualBox `6.1.32`
+ * Ansible `>=2.9.6`
  * (optional / integrations) `npm` / `npx` in order to run the simple HTTP server for the integrations
 
 ---
 
 ## Setting up the demo
 
+> Important: make sure you have installed the right versions of Vagrant and VirtualBox!
+
 1. Checkout Wazuh's tag `v4.1.5` into the current directory:
 
     ```
@@ -48,6 +51,8 @@ In addition to Wazuh, ClamAV is also installed on agent machines.
     $ make create provision
     ```
 
+    > Note: `create` command also adds `/etc/vbox/networks.conf` config required by Vagrant/VirtualBox.
+
 ---
 
 ## Using demo components
@@ -69,14 +74,15 @@ Clouditor starts automatically when Clouditor VM is provisioned.
 To see Clouditor's output, `ssh` to its machine and examine the log file:  
 
 ```
-$ make ssh-clouditor
-$ tail /var/log/clouditor.log
+$ make logs-clouditor
 ```
 
 To manually (re)start Clouditor (normally not needed), you can use the following command on the Clouditor VM (inside `/home/vagrant/clouditor`):
 
 ```
-$ make run
+$ make ssh-clouditor    # on host machine
+
+$ make run              # on VM
 ```
 
 ### Evidence Collector
@@ -84,8 +90,7 @@ $ make run
 To see Evidence Collector's output, `ssh` to its machine and open Docker logs:
 
 ```
-$ make ssh-evidence-collector
-$ docker logs -ft evidence-collector
+$ make logs-evidence-collector
 ```
 
 ### Wazuh
diff --git a/environments/full-setup/Vagrantfile b/environments/full-setup/Vagrantfile
index 1365358..66e0628 100644
--- a/environments/full-setup/Vagrantfile
+++ b/environments/full-setup/Vagrantfile
@@ -6,7 +6,6 @@ servers=[
     :hostname => "manager",
     :ip => "192.168.33.10",
     :box => "centos/stream8",
-    :forward_ports => [{:guest => 55000, :host => 55000}, {:guest => 9200, :host => 9200}],
     :ram => 2048,
     :cpu => 2
   },  
@@ -35,7 +34,6 @@ servers=[
     :hostname => "clouditor",
     :ip => "192.168.33.14",
     :box => "centos/stream8",
-    :forward_ports => [{:guest => 9090, :host => 9090}],
     :ram => 1024,
     :cpu => 1
   }
@@ -44,9 +42,6 @@ servers=[
 Vagrant.configure(2) do |config|
   servers.each do |machine|
       config.vm.define machine[:hostname] do |node|
-          # node.vm.provision "ansible" do |ansible|
-          #   ansible.playbook = "../../ansible/provision.yml"
-          # end
           node.vm.box = machine[:box]
           node.vm.hostname = machine[:hostname]
           node.vm.network "private_network", ip: machine[:ip]
diff --git a/environments/full-setup/full-setup.mk b/environments/full-setup/full-setup.mk
index 0718191..c15fc34 100644
--- a/environments/full-setup/full-setup.mk
+++ b/environments/full-setup/full-setup.mk
@@ -3,6 +3,9 @@ SSH_PRIVATE_KEY = $(HOME)/.vagrant.d/insecure_private_key
 SSH_USER = vagrant
 
 create:
+	sudo mkdir -p /etc/vbox
+	sudo touch /etc/vbox/networks.conf
+	grep -Fxq "* 192.168.33.0/24" /etc/vbox/networks.conf || sudo sh -c 'echo "* 192.168.33.0/24\n" >> /etc/vbox/networks.conf' 
 	@$(VAGRANT_RUN) up
 
 delete:
diff --git a/environments/no-collector/no-collector.mk b/environments/no-collector/no-collector.mk
index 244fcdd..64627ee 100644
--- a/environments/no-collector/no-collector.mk
+++ b/environments/no-collector/no-collector.mk
@@ -3,6 +3,9 @@ SSH_PRIVATE_KEY = $(HOME)/.vagrant.d/insecure_private_key
 SSH_USER = vagrant
 
 create:
+	sudo mkdir -p /etc/vbox
+	sudo touch /etc/vbox/networks.conf
+	grep -Fxq "* 192.168.33.0/24" /etc/vbox/networks.conf || sudo sh -c 'echo "* 192.168.33.0/24\n" >> /etc/vbox/networks.conf' 
 	@$(VAGRANT_RUN) up
 
 delete:
-- 
GitLab