49
49

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Vagrant / VirtualBoxプロバイダのときにVM名を指定する

Posted at

vboxss と言う便利そうなツールがでてきたけれど、Vagrantはデフォルトでは深遠なVM名をつけてしまうので連携上不便。

https://docs.vagrantup.com/v2/virtualbox/configuration.html の通り、VM名を指定できるのでそうすると良いと思う。

Vagrantfile
config.vm.provider :virtualbox do |vbox|
  vbox.name = "vagrant-foobarproj"
end

multi vm でいちいち名前を変えるためにコピペするのが不毛なので、

Vagrantfile
def define_machine_name(c, name)
  c.vm.provider :virtualbox do |vbox|
    vbox.name = name
  end
end

みたいなマクロを定義して

Vagrantfile
config.vm.define :www do |c|
  define_machine_name c, "vagrant-www-foobarproj"
end

とすると読みやすい。

49
49
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
49
49

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?