Where does the name \'default\' come from when launching a vagrant box?
$ vagrant up
Bringing machine \'default\' up with \'virtualbox\' provider...
<
You can change vagrant default machine name by changing value of config.vm.define
.
Here is the simple Vagrantfile which uses getopts and allows you to change the name dynamically:
# -*- mode: ruby -*-
require 'getoptlong'
opts = GetoptLong.new(
[ '--vm-name', GetoptLong::OPTIONAL_ARGUMENT ],
)
vm_name = ENV['VM_NAME'] || 'default'
begin
opts.each do |opt, arg|
case opt
when '--vm-name'
vm_name = arg
end
end
rescue
end
Vagrant.configure(2) do |config|
config.vm.define vm_name
config.vm.provider "virtualbox" do |vbox, override|
override.vm.box = "ubuntu/wily64"
# ...
end
# ...
end
So to use different name, you can run for example:
vagrant --vm-name=my_name up --no-provision
Note: The --vm-name
parameter needs to be specified before up
command.
or:
VM_NAME=my_name vagrant up --no-provision