Vagrant - 不应存在以下设置:内存、名称

Vagrant - The following settings shouldn't exist: memory, name

我已将这个问题从 Serverfault 移过来,我认为它更像是一个属于那里的问题:-)

我在 macOS 上有 Vagrant 版本 1.9.1,我有 VirtualBox 5.1.12 我正在尝试创建一个多机 Vagrant 文件,但当我想 运行 它时,我 运行 遇到了麻烦。

我收到消息:

There are errors in the configuration of this machine. Please fix the following errors and try again:

vm: * The following settings shouldn't exist: memory, name

现在在这个阶段我已经注释掉了第二台机器,因为我得到了两次错误 - 所以我只是想修复第一台机器。

我在其他线程上看到我应该删除 "web" 块中的行中的 .vm,但是如果我这样做,我会收到此错误:

There are errors in the configuration of this machine. Please fix the following errors and try again:

Vagrant: * Unknown configuration section 'memory='.
* Unknown configuration section 'name='.
* Unknown configuration section 'network'.
* Unknown configuration section 'provision'.

我在这里有点不知所措,因为我得到的答案在理论上是有道理的,而且我是从 vagrant up 文档开始的,但不知何故,我无法得到它 运行宁.

我的 vagrant 文件就在这里 - 所以请提供任何帮助:-)

Vagrant.configure("2") do |config|

config.vm.box = "bento/ubuntu-16.04"

config.vm.provider "virtualbox" do |vb|
    vb.gui = false
end

config.vm.define "web" do |web|
    web.vm.name = "16.04-web01"
    web.vm.memory = "512"
    web.vm.network "private_network", ip: "192.168.50.3"
    web.vm.network "forwarded_port", guest: 80, host: 8083
    web.vm.network "public_network", bridge: "en1: Wi-Fi (AirPort)"
    web.vm.provision :shell, path: "bootstrap.sh"    
end

#    config.vm.define :sql01 do |sql|
#     sql.vm.name = "16.04-sqlserver"
#     sql.vm.memory = "4096"
#     sql.vm.network "private_network", ip: "192.168.50.2"
#     sql.vm.network "forwarded_port", guest: 80, host: 8084
#     sql.vm.network "public_network", bridge: "en1: Wi-Fi (AirPort)"
#     sql.vm.provision :shell, path: "bootstrap.sh"    
#   end

#Options for Me specific
config.vm.synced_folder "/Applications/MAMP/htdocs/", "/htdocs_home"

end

namememory 是提供商特定参数,因此需要将它们移到此块中

Vagrant.configure("2") do |config|

    config.vm.box = "geerlingguy/ubuntu1604"

    config.vm.define "web" do |web|
        web.vm.network "private_network", ip: "192.168.50.3"
        web.vm.network "forwarded_port", guest: 80, host: 8083
        web.vm.network "public_network", bridge: "en1: Wi-Fi (AirPort)"
        web.vm.provision :shell, path: "bootstrap.sh"    

        web.vm.provider "virtualbox" do |vb|
            vb.gui = false
            vb.name = "16.04-web01"
            vb.memory = "512"
        end
    end

    config.vm.define :sql01 do |sql|
        sql.vm.network "private_network", ip: "192.168.50.2"
        sql.vm.network "forwarded_port", guest: 80, host: 8084
        sql.vm.network "public_network", bridge: "en1: Wi-Fi (AirPort)"
        sql.vm.provision :shell, path: "bootstrap.sh"    

        sql.vm.provider "virtualbox" do |vb|
            vb.gui = false
            vb.name = "16.04-sqlserver"
            vb.memory = "4096"
        end
    end

    #Options for Me specific
    config.vm.synced_folder "/Applications/MAMP/htdocs/", "/htdocs_home"

end