-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVagrantfile
More file actions
79 lines (68 loc) · 2.88 KB
/
Vagrantfile
File metadata and controls
79 lines (68 loc) · 2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# -*- mode: ruby -*-
# vi: set ft=ruby :
# ── OpenClaw VM — VirtualBox (macOS + Linux) ─────────────────
# Requires:
# 1. VirtualBox 7.1+ (free — brew install --cask virtualbox)
# 2. Vagrant: brew install --cask vagrant
# ── Auto-detect host architecture ────────────────────────────
host_arch = `uname -m`.strip
case host_arch
when "arm64", "aarch64"
box_arch = "arm64"
else
box_arch = "amd64"
end
# ── Load VM config from config/.env if present ───────────────
# Generated by `openclaw-vm config` or the first-run wizard.
# Falls back to sensible defaults if the CLI hasn't been run yet.
vm_memory = 8192
vm_cpus = 4
install_ollama = "false"
vm_password = ""
env_file = File.join(__dir__, "config", ".env")
if File.exist?(env_file)
File.readlines(env_file).each do |line|
case line
when /^VM_MEMORY=(\d+)/ then vm_memory = $1.to_i
when /^VM_CPUS=(\d+)/ then vm_cpus = $1.to_i
when /^INSTALL_OLLAMA=(\S+)/ then install_ollama = $1
when /^VM_PASSWORD="?([^"]*)"?/ then vm_password = $1
end
end
end
Vagrant.configure("2") do |config|
config.vm.box = "bento/ubuntu-22.04"
config.vm.box_architecture = box_arch
config.vm.hostname = "openclaw-vm"
# ── Networking ──────────────────────────────────────────────
# Gateway WebUI / WebChat
config.vm.network "forwarded_port", guest: 18789, host: 18789, host_ip: "127.0.0.1"
# Bridge port
config.vm.network "forwarded_port", guest: 18790, host: 18790, host_ip: "127.0.0.1"
# SSH — exposed to LAN so you can connect from other machines.
config.vm.network "forwarded_port", guest: 22, host: 2222, host_ip: "0.0.0.0", id: "ssh"
# Private network so the VM can reach the internet but host
# services can't reach into the VM unexpectedly.
config.vm.network "private_network", type: "dhcp"
config.vm.provider "virtualbox" do |vb|
vb.name = "openclaw-vm"
vb.memory = vm_memory
vb.cpus = vm_cpus
end
# ── Provision ───────────────────────────────────────────────
# System provisioning (root): packages, firewall, Ollama, SSH
# Config values are passed as env vars — no file uploads needed.
config.vm.provision "shell",
path: "scripts/provision.sh",
privileged: true,
env: {
"INSTALL_OLLAMA" => install_ollama,
"VM_PASSWORD" => vm_password
}
# User setup (vagrant user): install OpenClaw, create workspace
# OpenClaw config (models, keys, gateway) is handled by `openclaw onboard`
# inside the VM after first SSH — not by the host CLI.
config.vm.provision "shell",
path: "scripts/user-setup.sh",
privileged: false
end