Search code examples
vagrant

Make Vagrant _not_ bring up certain machines by default?


I have a Vagrantfile which defines multiple machines. Only one of these machines is used for daily development, the other one exists solely for occasional integration testing.

Is there a way to make Vagrant never bring up this secondary machine by default? When I run vagrant up, I'd like it to only bring up the default machine which is defined as:

config.vm.define "centos7", primary: true do |centos7|

and never bring up the secondary machine which is defined as:

config.vm.define "centos6", primary: false do |centos6|

I know that I can just run vagrant up centos7 to not bring up the other machine, but I'd like to make life easier on consumers of my project and not have them inadvertently start two VMs simultaneously on their machines, especially since the second one is irrelevant to their daily needs.


Solution

  • you can define as follow

    config.vm.define "centos6", autostart: false , primary: false do |centos6|
    

    The autostart setting allows you to tell Vagrant to not start specific machines

    When you'll run vagrant up only "centos7" will automatically start, but "centos6" will not start. If you want to run your test you'll force the "centos6" machine to start by running vagrant up centos6.