Problem with Vagrantfile launching machines

338 views
Skip to first unread message

rhys.jame...@googlemail.com

unread,
Jul 15, 2017, 1:57:00 PM7/15/17
to Vagrant
Hello. I'm working with Vagrant for the first time trying to create a bunch of VM's for a MongoDB cluster. I've stumbled quite quickly.

After executing "vagrant up" I receive the following error...


/Users/rhys1/Documents/vagrant/mongo/Vagrantfile:22:in `block (2 levels) in <top (required)>': undefined local variable or method `mongos1' for main:Object (NameError)
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.0/lib/vagrant/config/v2/loader.rb:37:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.0/lib/vagrant/config/v2/loader.rb:37:in `load'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.0/lib/vagrant/config/loader.rb:113:in `block (2 levels) in load'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.0/lib/vagrant/config/loader.rb:107:in `each'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.0/lib/vagrant/config/loader.rb:107:in `block in load'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.0/lib/vagrant/config/loader.rb:104:in `each'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.0/lib/vagrant/config/loader.rb:104:in `load'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.0/lib/vagrant/vagrantfile.rb:153:in `machine_config'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.0/lib/vagrant/environment.rb:333:in `default_provider'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.0/lib/vagrant/plugin/v2/command.rb:174:in `block in with_target_vms'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.0/lib/vagrant/plugin/v2/command.rb:201:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.0/lib/vagrant/plugin/v2/command.rb:201:in `block in with_target_vms'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.0/lib/vagrant/plugin/v2/command.rb:183:in `each'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.0/lib/vagrant/plugin/v2/command.rb:183:in `with_target_vms'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.0/plugins/commands/up/command.rb:131:in `install_providers'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.0/plugins/commands/up/command.rb:85:in `execute'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.0/lib/vagrant/cli.rb:42:in `execute'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.0/lib/vagrant/environment.rb:308:in `cli'
from /opt/vagrant/embedded/gems/gems/vagrant-1.9.0/bin/vagrant:123:in `<main>'

The content of my Vagrant file is as follows...

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

  config.vm.define "mongos1" do |mongos1|
    mongos1.vm.box = "centos/7"
    mongos1.vm.provision :shell, path: "bootstrap_mongos.sh"
  end
  
  config.vm.define "mongos2" do |mongos2|
    mongos2.vm.box = "centos/7"
    mongos2.vm.provision :shell, path: "bootstrap_mongos.sh"
  end
  
  config.vm.define "mongos3" do |mongos3|
    mongos3.vm.box = "centos/7"
    mongos3.vm.provision :shell, path: "bootstrap_mongos.sh"
  end  

  config.vm.define "mongod1" do |mongod1|
    mongod1.vm.box = "centos/7"
    mongos1.vm.provision :shell, path: "bootstrap_mongod.sh"
  end
  
  config.vm.define "mongod2" do |mongod2|
    mongod2.vm.box = "centos/7"
    mongos2.vm.provision :shell, path: "bootstrap_mongod.sh"
  end  
 
  config.vm.define "mongod3" do |mongod3|
    mongod3.vm.box = "centos/7"
    mongos3.vm.provision :shell, path: "bootstrap_mongod.sh"
  end  
 
   config.vm.define "mongod4" do |mongod4|
    mongod4.vm.box = "centos/7"
    mongos4.vm.provision :shell, path: "bootstrap_mongod.sh"
  end
  
  config.vm.define "mongod5" do |mongod5|
    mongod5.vm.box = "centos/7"
    mongos5.vm.provision :shell, path: "bootstrap_mongod.sh"
  end  
 
  config.vm.define "mongod6" do |mongod6|
    mongod6.vm.box = "centos/7"
    mongos6.vm.provision :shell, path: "bootstrap_mongod.sh"
  end  
  
end

Is anyone able to see what I am doing wrong?

Many thanks,

Rhys



 

Salty Vagrant

unread,
Jul 16, 2017, 6:43:37 AM7/16/17
to rhys.james.campbell via Vagrant

Ryhs:

Typos. You have mongos1 in your mongod1 and mongod2 blocks

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/9af7ee0f-0694-4f90-9291-d45ef44025ad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

rhys.jame...@googlemail.com

unread,
Jul 16, 2017, 6:45:38 AM7/16/17
to Vagrant
great. Thanks.

Salty Vagrant

unread,
Jul 16, 2017, 6:45:50 AM7/16/17
to Vagrant
Oops. Typo myself :_ Sorry Rhys for misspelling your name
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+unsubscribe@googlegroups.com.

Salty Vagrant

unread,
Jul 16, 2017, 6:49:56 AM7/16/17
to Vagrant
Rhys

Actually, you have a few other typos in there too. Check your mongod blocks, they all have mongos in them :)

On Sunday, July 16, 2017 at 11:45:38 AM UTC+1, rhys.jame...@googlemail.com wrote:
great. Thanks.
Reply all
Reply to author
Forward
0 new messages