1

With Vagrant, I aim to have three master and two node machines on my Ubuntu host.

My Vagrantfile:

Vagrant.configure("2") do |config|
  config.ssh.insert_key = false
  (1..3).each do |i|
    config.vm.define "master" do |master|
      master.vm.box = "ubuntu/bionic64"
    end
  end
  (1..2).each do |i|
    config.vm.define "node" do |node|
      node.vm.box = "ubuntu/bionic64"
    end
  end
  config.vm.network "public_network"
  config.vm.provider "virtualbox" do |vb|
    vb.memory = "3072"
    vb.cpus = "3"
  end
end

I have after vagrant up:

$ vagrant status
Current machine states:

master                    running (virtualbox)
node                      running (virtualbox)

Why did the loop fail?

1 Answer 1

1

-#{i} was missing in both do loops, while everything else was ok and there was no need for further changes:

Vagrant.configure("2") do |config|
  config.ssh.insert_key = false
  (1..3).each do |i|
    config.vm.define "master-#{i}" do |master|
      master.vm.box = "ubuntu/bionic64"
    end
  end
  (1..2).each do |i|
    config.vm.define "node-#{i}" do |node|
      node.vm.box = "ubuntu/bionic64"
    end
  end
  config.vm.network "public_network"
  config.vm.provider "virtualbox" do |vb|
    vb.memory = "3072"
    vb.cpus = "3"
  end
end
0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.