[vagrant] vagrant primary box defined but commands still run against all boxes

I am trying to set my "dev" VM as primary so most commands such as vagrant up, vagrant halt, etc operate on the "dev" VM and ignore the "stage" VM unless the "stage" VM name is explicitly listed on the command line. Here's my Vagrantfile, but when I run vagrant up both VMs are brought up instead of just "dev".

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! VAGRANTFILE_API_VERSION = "2"  def box_setup(config, ip, playbook, inventory)   config.vm.network :private_network, ip: ip   config.vm.provision "ansible" do |ansible|     ansible.playbook = playbook     ansible.inventory_path = inventory     # ansible.verbose = "vvv"   end end  Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|   # common settings shared by all vagrant boxes for this project   config.vm.box = "debian-7-amd64"   config.vm.box_url = "https://dl.dropboxusercontent.com/s/xymcvez85i29lym/vagrant-debian-wheezy64.box"   config.ssh.forward_agent = true   # development box intended for ongoing development   config.vm.define "dev", primary: true do |dev|     box_setup dev, \       "10.9.8.30", "deploy/playbook_dev.yml", "deploy/hosts/vagrant_dev.yml"   end   # stage box intended for configuration closely matching production   config.vm.define "stage" do |stage|     box_setup stage, \       "10.9.8.31", "deploy/playbook_full_stack.yml", "deploy/hosts/vagrant_stage.yml"   end end 

This question is related to vagrant

The answer is


The primary flag seems to only work for vagrant ssh for me.

In the past I have used the following method to hack around the issue.

# stage box intended for configuration closely matching production if ARGV[1] == 'stage'     config.vm.define "stage" do |stage|         box_setup stage, \         "10.9.8.31", "deploy/playbook_full_stack.yml", "deploy/hosts/vagrant_stage.yml"     end end