vagrant poweroff all vms from the same box when destroys one of them

Created on 2 Sep 2015  路  5Comments  路  Source: hashicorp/vagrant

Hi,

I have vagrant multi vm environment with 4 vms each. I'm starting 3 vagrant environments in parallel from different Jenkins jobs. So I clone my Vagrant file from the same repo to different folders and do vagrant up vm1- vm2- vm3-.
For example my first job does: vagrant up vm1-100 vm2-100 vm3-100. All this Vms are in private network network-100.
Then another job starts: vagrant up vm1-101 vm2-101 vm3-101. Private network network-101.

After finishing all my tasks Jenkins destroys all vms in first job:
vagrant destroy vm1-100 --force
vagrant destroy vm2-100 --force
vagrant destroy vm3-100 --force

But after this action all vms from another job go to poweroff or abort state. They are in another folder, they have another names, they are in another private network.

ii vagrant 1:1.7.4
ii virtualbox-5.0 5.0.2-102096~Ubuntu~trusty

Most helpful comment

When we perform vagrant up, by default virtualbox server (VBoxSVC) starts as process. So first Jenkins job performs vagrant up vm1-100 that means it starts VBoxSVC process and then second job use this VBoxSVC process to up another vagrant boxes. When first job finishes, it, of course, kills all processes it started. So after first job finishes, jenkins kills virtualbox server and that is the reason of all VMs go to abort state.
So, in order to fix this you should start virtualbox server in daemon mode before start Jenkins jobs:
/usr/lib/virtualbox/VBoxSVC --pidfile VBoxSVC.pid

All 5 comments

Fixed.

I am seeing exactly the same issue, how did you resolve this?

When we perform vagrant up, by default virtualbox server (VBoxSVC) starts as process. So first Jenkins job performs vagrant up vm1-100 that means it starts VBoxSVC process and then second job use this VBoxSVC process to up another vagrant boxes. When first job finishes, it, of course, kills all processes it started. So after first job finishes, jenkins kills virtualbox server and that is the reason of all VMs go to abort state.
So, in order to fix this you should start virtualbox server in daemon mode before start Jenkins jobs:
/usr/lib/virtualbox/VBoxSVC --pidfile VBoxSVC.pid

Thanks, this solved the problem for me.
One extra gotcha, of course, VBoxSVC needs to run under the same user as Jenkins.

Sure, VBoxSVC should be run under the same user as Jenkins.
You are welcome!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jsirex picture jsirex  路  3Comments

DreadPirateShawn picture DreadPirateShawn  路  3Comments

dorinlazar picture dorinlazar  路  3Comments

rhencke picture rhencke  路  3Comments

mpontillo picture mpontillo  路  3Comments