5

I have moved this question over from Serverfault I thought it was more of a question belonging there :-)

I have Vagrant version 1.9.1 on macOS and I have VirtualBox 5.1.12 I am trying to have a go at creating a multi machine Vagrant file and I am running into trouble when I want to run it.

I get the message:

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

Now at this stage I have commented out the second machine, because I get the error twice - so I am just trying to fix the first one.

I have seen on other threads I should remove the .vm in the lines that are in the "web" block, but if I do that then I get this error:

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'.

I am at a bit of a loss here, because the answers I am getting make sense in theory and I started this from the vagrant up docs, but somehow in my case I can't get it running.

My vagrant file is right here - so please any help would be appreciated :-)

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
Community
  • 1
  • 1
jwknz
  • 6,598
  • 16
  • 72
  • 115

1 Answers1

14

name and memory are provider specific parameters so they need to be moved in this block

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
Frederic Henri
  • 51,761
  • 10
  • 113
  • 139