Skip to content

Commit f74dc9f

Browse files
ehelmsclaude
andcommitted
Scope Vagrant libvirt domains to allow multiple checkouts
Use a hash of the absolute working directory path to generate a unique libvirt domain prefix per checkout, preventing collisions when multiple clones or git worktrees deploy Vagrant boxes simultaneously. Both the libvirt domain name prefix and the VM hostnames are scoped using the prefix, ensuring full isolation between deployments. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 6e99e94 commit f74dc9f

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

‎Vagrantfile‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
require 'digest'
2+
3+
prefix = Digest::MD5.hexdigest(Dir.pwd)[0..7]
4+
15
Vagrant.configure("2") do |config|
26
config.vm.synced_folder ".", "/vagrant"
37

@@ -12,9 +16,10 @@ Vagrant.configure("2") do |config|
1216

1317
config.vm.define "quadlet" do |override|
1418
override.vm.box = ENV.fetch("FOREMANCTL_BASE_BOX", "centos/stream9")
15-
override.vm.hostname = "quadlet.example.com"
19+
override.vm.hostname = "quadlet.#{prefix}.example.com"
1620

1721
override.vm.provider "libvirt" do |libvirt, provider|
22+
libvirt.default_prefix = prefix
1823
libvirt.memory = 10240
1924
libvirt.cpus = 4
2025
libvirt.machine_virtual_size = 30
@@ -23,19 +28,22 @@ Vagrant.configure("2") do |config|
2328

2429
config.vm.define "client" do |override|
2530
override.vm.box = "centos/stream9"
26-
override.vm.hostname = "client.example.com"
31+
override.vm.hostname = "client.#{prefix}.example.com"
2732

2833
override.vm.provider "libvirt" do |libvirt, provider|
34+
libvirt.default_prefix = prefix
2935
libvirt.memory = 1024
3036
end
3137
end
3238

3339
config.vm.define "database" do |override|
3440
override.vm.box = "centos/stream9"
35-
override.vm.hostname = "database.example.com"
41+
override.vm.hostname = "database.#{prefix}.example.com"
3642

3743
override.vm.provider "libvirt" do |libvirt, provider|
44+
libvirt.default_prefix = prefix
3845
libvirt.memory = 2048
3946
end
4047
end
4148
end
49+

0 commit comments

Comments
 (0)