当某些项目文件丢失时,有没有办法阻止 "vagrant up" 命令

Is there a way to block "vagrant up" command when some project files are missing

我正在为我的团队开发 vagrant 环境。其中一个假设是数据库必须在机器之外。所以每个团队成员都必须在自己的本地机器上安装自己的 MySQL 服务器,并使用数据库配置创建文件 local.yaml (puppet)。问题是不是每个成员都阅读我的说明,并且在构建几分钟后出现数据库错误(找不到数据库等)。我想在某人 运行 命令 "vagrant up".

之前添加一些信息

问题:在没有local.yaml文件的情况下,有没有办法阻止vagrant up?

您始终可以检查 Vagrantfile 中的 local.yaml 文件,然后 raise 如果它不存在

我认为代码应该是这样的:

...
raise 'You need a local.yaml' unless File.exist?('local.yaml')
...
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
    ...

用法:

$ vagrant up
There was an error loading a Vagrantfile. The file being loaded
and the error message are shown below. This is usually caused by
a syntax error.

Path: /Users/<username>/<workspace>/<project>/Vagrantfile
Line number: 0
Message: RuntimeError: You need a local.yaml