更新后重新加载 vagrant

Reload vagrant after an update

更改供应脚本后重新加载 vagrant 的最快方法是什么?

我实际上是将文件"mysql.sql"复制到客户机,在"Vagrant":

config.vm.provision "file", source: "mysql.sql", destination: "mysql.sql"

并从 "bootstrap.sh":

调用它
mysql -h localhost -u root -proot < /home/vagrant/mysql.sql

我曾经用过:

vagrant destroy
vagrant up
vagrant provision
vagrant ssh

我试着看看是否:

vagrant reload

会做同样的事情,但我不确定这一点,因为我的修改发生在 .sql 文件而不是 Vagrant 文件中。

您可以 运行 vagrant reload --provision 到 运行 您的 provisioner

规定

  • On the first vagrant up that creates the environment, provisioning is run. If the environment was already created and the up is just resuming a machine or booting it up, they won't run unless the --provision flag is explicitly provided.

  • When vagrant provision is used on a running environment.

  • When vagrant reload --provision is called. The --provision flag must be present to force provisioning.

P.S。 Vagrant 1.7.2 中修复了一个错误,如果你在 vagrant reload --provision 期间出错,你会在 rm .vagrant/machines/default/virtualbox/synced_folders 和 运行 之后 vagrant provision.