I’m new to Vagrant and I need help with a problem.
I wrote the Vagrantfile you see below and I tried to bring up all my nodes. Unfortunately, when I run vagrant up, I see the message below and need to do vagrant reload. This only resolves the issue for one node at a time, so I have to repeat this operation for each node, which is absolutely inconvenient. Can you help me resolve this problem so I can bring up all my nodes automatically? I tried adding a reboot at the end of my Vagrantfile using a shell provisioner, but it doesn’t work properly.
I also tried the method described in this article: https://forums.virtualbox.org/viewtopic.php?t=109606, but it didn’t work.
servers=[
{
:hostname => "master",
:box => "bento/ubuntu-24.04",
:ip => "192.168.56.50",
:ssh_port => '2200'
},
{
:hostname => "node1",
:box => "bento/ubuntu-24.04",
:ip => "192.168.56.51",
:ssh_port => '2201'
},
{
:hostname => "node2",
:box => "bento/ubuntu-24.04",
:ip => "192.168.56.52",
:ssh_port => '2202'
},
{
:hostname => "node3",
:box => "bento/ubuntu-24.04",
:ip => "192.168.56.53",
:ssh_port => '2203'
}
]
servers.each do |machine|
config.vm.define machine[:hostname] do |node|
node.vm.box = machine[:box]
node.vm.hostname = machine[:hostname]
node.vm.network :private_network, ip: machine[:ip]
node.vm.network "forwarded_port", guest: 22, host: machine[:ssh_port], id: "ssh"
node.vm.synced_folder ".", "/vagrant", type: "virtualbox"
node.vm.provision "shell", inline: <<-SHELL
sudo cp /vagrant/hosts /etc/hosts
SHELL
node.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", 512]
vb.customize ["modifyvm", :id, "--cpus", 1]
end
end
end
end
LOGS:
Verifying archive integrity... 100% MD5 checksums are OK. All good.
Uncompressing VirtualBox 7.0.18 Guest Additions for Linux 100%
VirtualBox Guest Additions installer
Removing installed version 7.0.16 of VirtualBox Guest Additions...
update-initramfs: Generating /boot/initrd.img-6.8.0-31-generic
Copying additional installer modules ...
Installing additional modules ...
VirtualBox Guest Additions: Starting.
VirtualBox Guest Additions: Setting up modules
VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel
modules. This may take a while.
VirtualBox Guest Additions: To build modules for other installed kernels, run
VirtualBox Guest Additions: /sbin/rcvboxadd quicksetup <version>
VirtualBox Guest Additions: or
VirtualBox Guest Additions: /sbin/rcvboxadd quicksetup all
VirtualBox Guest Additions: Building the modules for kernel 6.8.0-31-generic.
update-initramfs: Generating /boot/initrd.img-6.8.0-31-generic
VirtualBox Guest Additions: Running kernel modules will not be replaced until
the system is restarted or 'rcvboxadd reload' triggered
VirtualBox Guest Additions: reloading kernel modules and services
VirtualBox Guest Additions: kernel modules and services 7.0.18 r162988 reloaded
VirtualBox Guest Additions: NOTE: you may still consider to re-login if some
user session specific services (Shared Clipboard, Drag and Drop, Seamless or
Guest Screen Resize) were not restarted automatically