问题
I read that it's possible to create a file with the name "id" and with the written id inside and put it into .vagrant/... directory. But is it also possible to determine the id in the vagrantfile?
回答1:
As Vagrantfile is a ruby script you can always read the id file from Vagrantfile
Vagrant.configure(2) do |config|
p "read uuid " + File.read(".vagrant/machines/default/virtualbox/index_uuid")
p "read id " + File.read(".vagrant/machines/default/virtualbox/id")
来源:https://stackoverflow.com/questions/37622689/is-it-possible-to-determine-the-id-of-vagrant-vm-in-the-vagrantfile