Skip to content

Commit 2ebbd88

Browse files
committed
added Vagrant setup for lab environment with agent and dispatcher VMs, updated .gitignore to include Vagrant files
1 parent 3a931c6 commit 2ebbd88

File tree

3 files changed

+87
-0
lines changed

3 files changed

+87
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,5 @@ go.work.sum
2424
# env file
2525
.env
2626
.cache
27+
*.vdi
28+
.vagrant

lab/README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
## Lab Environment Setup
2+
3+
Follow these steps to create and use two Vagrant VMs: `agent` and `dispatcher`.
4+
5+
### 1) Install prerequisites
6+
- **Vagrant (AMD64)**: Download and install the Windows AMD64 package from the official site: [Vagrant Install](https://developer.hashicorp.com/vagrant/install)
7+
- **VirtualBox**: Download and install VirtualBox for Windows: [VirtualBox Downloads](https://www.virtualbox.org/wiki/Downloads)
8+
9+
After installing both, **restart your machine**.
10+
11+
### 2) Bring up the VMs
12+
Run these commands from the repository root:
13+
14+
```bash
15+
cd lab
16+
vagrant up
17+
```
18+
19+
The first run may take several minutes while the base box downloads.
20+
21+
### 3) Connect to the VMs
22+
- **Dispatcher**:
23+
24+
```bash
25+
vagrant ssh dispatcher
26+
```
27+
28+
- **Agent**:
29+
30+
```bash
31+
vagrant ssh agent
32+
```
33+
34+
### Notes
35+
- The default provider is VirtualBox; ensure virtualization is enabled in BIOS/UEFI.
36+
- On Windows, run commands in PowerShell or Command Prompt.
37+

lab/Vagrantfile

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
Vagrant.configure("2") do |config|
2+
config.vm.box = "hashicorp-education/ubuntu-24-04"
3+
config.vm.box_version = "0.1.0"
4+
5+
config.vm.define "agent" do |agent|
6+
agent.vm.hostname = "agent"
7+
agent.vm.network "private_network", ip: "192.168.56.20"
8+
end
9+
10+
config.vm.define "dispatcher" do |dispatcher|
11+
dispatcher.vm.hostname = "dispatcher"
12+
dispatcher.vm.network "private_network", ip: "192.168.56.21"
13+
14+
# Configure 60GB additional disk
15+
dispatcher.vm.provider "virtualbox" do |vb|
16+
disk_file = "./dispatcher_disk.vdi"
17+
unless File.exist?(disk_file)
18+
vb.customize ['createhd', '--filename', disk_file, '--size', 60 * 1024]
19+
end
20+
# Try common controller names - typically 'SATA Controller' or 'IDE Controller'
21+
vb.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', disk_file]
22+
end
23+
24+
# Format and mount the disk
25+
dispatcher.vm.provision "shell", inline: <<-SHELL
26+
if ! grep -q "/mnt/data" /etc/fstab; then
27+
# The disk might be /dev/sdb or /dev/sdc depending on the system
28+
DISK_DEVICE=$(lsblk -nd -o NAME,SIZE | grep "60G" | awk '{print "/dev/"$1}' | head -1)
29+
30+
if [ -z "$DISK_DEVICE" ]; then
31+
echo "Could not find 60GB disk, checking available disks:"
32+
lsblk
33+
exit 1
34+
fi
35+
36+
echo "Found disk at: $DISK_DEVICE"
37+
sudo mkfs.ext4 $DISK_DEVICE
38+
sudo mkdir -p /mnt/data
39+
DISK_UUID=$(sudo blkid -s UUID -o value $DISK_DEVICE)
40+
echo "UUID=${DISK_UUID} /mnt/data ext4 defaults 0 2" | sudo tee -a /etc/fstab
41+
sudo mount -a
42+
sudo chown -R vagrant:vagrant /mnt/data
43+
echo "60GB disk mounted at /mnt/data"
44+
df -h /mnt/data
45+
fi
46+
SHELL
47+
end
48+
end

0 commit comments

Comments
 (0)