Is it possible to determine the id of vagrant vm in the vagrantfile?

喜你入骨 提交于 2019-12-13 19:37:09

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!