Vagrant: Setting VM name or description from Vagrantfile ?

Created on 14 Sep 2012  路  10Comments  路  Source: hashicorp/vagrant

Would it be possible to have some options in Vagrantfile to modify the name template used by vagrant when creating the VM ? This would help finding the VM from different projects in the VirtualBox Manager GUI.

This could be handy since VirtualBox 4.2 eventually allow to manage headless VMs.

(By the way, an option to push the actual port forwarding and shared folder settings into the VM description could be very useful.)

Most helpful comment

In the meantime, you can set the name manually like this

config.vm.customize ["modifyvm", :id, "--name", "Gangnam Style"]

All 10 comments

+1 for this.

In the meantime, you can set the name manually like this

config.vm.customize ["modifyvm", :id, "--name", "Gangnam Style"]

+1

+1

+1

Finally shipped this. Vagrant 1.1 offers a great framework for making provider-specific changes like this. In 1.1 Vagrantfile syntax this will look like this:

Vagrant.configure("2") do |config|
  # ... stuff

  config.vm.provider :virtualbox do |vb|
    vb.name = "my_machine"
  end
end

Enjoy! Will be available in 1.1.

figured out how to manage to do this with individually-named vm's (multi-vm setup)...

# -*- mode: ruby -*-
# vi: set ft=ruby :

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

    config.vm.define "centos" do |centos|
        centos.vm.box = "centos"
        config.vm.provider :virtualbox do |vb|
            vb.name = "centos"
        end
    end

end

Sorry for bringing attention to this old issue. I am considering of dynamically naming VM the same name as parent directory. Are there any downsides to this?

Mailing list is best suited for these questions.

no downsides, just avoid duplicates.

Okay sorry. Quick search turned this relevant thread up.

Was this page helpful?
0 / 5 - 0 ratings