[vagrant-up] Problem with Vagrantfile launching machines
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 > ': 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 > `' 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 -- 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+unsubscr...@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.
Re: [vagrant-up] Problem with Vagrantfile launching machines
great. Thanks. -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/a72a2e75-054b-4073-a097-3e696d4e4f54%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[vagrant-up] Error attempting to add additional disk
Hello All, I've been trying to figure out how to add a second disk to my Vagrant hosts. I receive the following error on 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: > Line number: 17 > Message: ArgumentError: wrong number of arguments (given 5, expected 1..2) Here is my Vagrantfile; Vagrant.configure("2") do |config| HOSTS=5 (1..HOSTS).each do |host_id| config.vm.box = "centos/7" config.vm.define "mariadb#{host_id}" do |mariadb| mariadb.vm.hostname = "mariadb#{host_id}" mariadb.vm.network "private_network", ip: "192.168.13.#{1+host_id}" #mariadb.vm.synced_folder '.', '/vagrant', disabled: true mariadb.vm.provider "virtualbox" do |v| v.name = "mariadb#{host_id}" v.memory = 1024 v.cpus = 1 [ "data", "log" ].each do |volume| # MariaDB volumes file_to_disk = "./mariadb#{host_id}_#{volume}.vdi" unless File.exist?(file_to_disk) v.customize[ 'createhd', '--filename', file_to_disk, '--size', 500 * 1024 ] end v.customize[ 'storageattach', :id, '--storagectl', 'SATA Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', file_to_disk ] end end mariadb.vm.provision :shell, path: "bash/bootstrap_avahi.sh", run: "always" # All vms have been provisioned. Run Ansible if host_id == HOSTS mariadb.vm.provision :ansible do |ansible| ansible.limit = "all" # Connect to all machines ansible.playbook = "mariadb.yaml" ansible.groups = { "masters" => ["mariadb1", "mariadb2"], "slaves" => ["mariadb3", "mariadb4", "mariadb5"] } #ansible.inventory_path = ".vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory" end end end end end Can anyone tell me what I'm doing wrong. I am using Vagrant 1.9.7 on OS X with VirtualBox 5.0.26. -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/601afc0a-0751-458e-aee6-6ec1d40e95b0%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [vagrant-up] Error attempting to add additional disk
Thanks. It was copied and pasted from somewhere so something got mangled. Had to make a few additional changes to get it working with my box. Settled on this; device=0 [ "data", "log" ].each do |volume| # MariaDB volumes file_to_disk = "/tmp/mariadb#{host_id}_#{volume}.vdi" unless File.exist?(file_to_disk) # v.customize['createhd', # '--filename', # "#{file_to_disk}", # '--size', # (500 * 1024).floor] v.customize ['createhd', '--filename', "#{file_to_disk}", '--size', (5 * 1024).floor] end #v.customize ['storageattach', # :id, # '--storagectl', # 'SATA Controller', # '--port', # 1, # '--device', # 0, # '--type', # 'hdd', # '--medium', # "#{file_to_disk}"] v.customize ['storageattach', :id, '--storagectl', 'IDE Controller', '--port', 1, '--device', device, '--type', 'hdd', '--medium', "#{file_to_disk}"] device+=1 end -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/d8384d15-98be-481d-aad4-e521333b1e8c%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[vagrant-up] Using a custom version of Ansible with Vagrant
Hello, Is there a way to instruct Vagrant to use a custom version of Ansible. I've forked the Ansible code and want to test a couple of modules without affecting my installed instance. Rhys -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/0698db80-c64c-499e-b213-605861da0da4%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[vagrant-up] Re: Using a custom version of Ansible with Vagrant
Answer my own question here.. http://docs.ansible.com/ansible/latest/dev_guide/developing_modules_general.html#playbook-module-testing Performed via python venv. -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/b0efb5cc-532c-486b-9a53-efc2319dbcb4%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[vagrant-up] Incrementing a port number for forwarding
Hello All, I am trying to forward a port to a couple of servers in a Vagrant file but the variable is not being incremented for some reason... All I'm doing is this... if host.start_with?("testnagios") config.vm.network "forwarded_port", guest: 80, host: nagios_forward_port nagios_forward_port += 1 The first instance works but I get the following error when the second instance fires up... Vagrant cannot forward the specified ports on this VM, since they would collide with some other application that is already listening on these ports. The forwarded port to is already in use on the host machine. To fix this, modify your current project's Vagrantfile to use another port. Example, where '1234' would be replaced by a unique host port: config.vm.network :forwarded_port, guest: 80, host: 1234 Sometimes, Vagrant will attempt to auto-correct this for you. In this case, Vagrant was unable to. This is usually because the guest machine is in a state which doesn't allow modifying port forwarding. You could try 'vagrant reload' (equivalent of running a halt followed by an up) so vagrant can attempt to auto-correct this upon booting. Be warned that any unsaved work might be lost. I set the nagios_forward_port right after the Vagrant.configure("2") do |config| line. It is not referenced anywhere else in the Vagrantfile other than the lines given above. Is there something about scope I'm missing here? Cheers, Rhys -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/deadadb0-ef6e-4d8f-8683-e5a63b9cd98c%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [vagrant-up] Incrementing a port number for forwarding
My full Vagrant file is as below. I've since "fixed" this by removing the increment and adding auto_correct: true to the port mapping. That works but I don;t see what I'm doing wrong the old way. Cheers, Rhys Vagrant.configure("2") do |config| nagios_forward_port= nrpe_hosts = [ "nrpeyum01", "nrpepip02", "nrpescript03", "nrpeyumpip04", "nrpeyumscript05", "nrpepipscript06", "nrpeall07" ] nagios_hosts = [ "testnagios01", "testnagios02" ] all_hosts = nrpe_hosts + nagios_hosts all_hosts.each do |host| config.vm.define "#{host}" do |nrpe| nrpe.vm.box = "bento/centos-7.5" nrpe.vm.provider :virtualbox do |vb| vb.customize [ "modifyvm", :id, "--name", "#{host}", "--memory", "1024" ] vb.cpus = 1 end config.vm.hostname = "#{host}" if host.start_with?("testnagios") config.vm.network "forwarded_port", guest: 80, host: nagios_forward_port nagios_forward_port += 1 end if host == all_hosts[-1] config.vm.provision :ansible do |ansible| ansible.groups = { "nrpe" => nrpe_hosts, "nagios" => nagios_hosts, } ansible.limit = "nrpe" ansible.playbook = "nrpe.yml" end config.vm.provision :ansible do |ansible| ansible.groups = { "nrpe" => nrpe_hosts, "nagios" => nagios_hosts, } ansible.limit = "nagios" ansible.playbook = "nagios.yml" end end end end end -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/d8bcdbf5-8f4b-48a3-8f72-75a97ec6140f%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [vagrant-up] Incrementing a port number for forwarding
There are two Nagios servers. The first one should be allocated the port in the forwarding. The second one should get 8889 because I increment it right after the first one. So I basically want the port assigned as follows... testnagios01 - testnagios02 - 8889 This does not happen and the Vagrantfile errors with the following... Vagrant cannot forward the specified ports on this VM, since they would collide with some other application that is already listening on these ports. The forwarded port to is already in use on the host machine. To fix this, modify your current project's Vagrantfile to use another port. Example, where '1234' would be replaced by a unique host port: config.vm.network :forwarded_port, guest: 80, host: 1234 Sometimes, Vagrant will attempt to auto-correct this for you. In this case, Vagrant was unable to. This is usually because the guest machine is in a state which doesn't allow modifying port forwarding. You could try 'vagrant reload' (equivalent of running a halt followed by an up) so vagrant can attempt to auto-correct this upon booting. Be warned that any unsaved work might be lost. So basically the increment isn't happening. -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/7401d515-17a4-4463-9a93-ce7ccf57c094%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [vagrant-up] Incrementing a port number for forwarding
OK. This is strange. This... if host.eql?("testnagios01") config.vm.network "forwarded_port", guest: 80, host: end if host.eql?("testnagios02") config.vm.network "forwarded_port", guest: 80, host: 8889 end ==> testnagios01: Checking for guest additions in VM... > ==> testnagios01: Setting hostname... > ==> testnagios01: Mounting shared folders... > testnagios01: /vagrant => /vagrant > ==> testnagios02: Importing base box 'bento/centos-7.5'... > ==> testnagios02: Matching MAC address for NAT networking... > ==> testnagios02: Checking if box 'bento/centos-7.5' is up to date... > ==> testnagios02: Setting the name of the VM: > vagrant_testnagios02_1543229171053_3544 > Vagrant cannot forward the specified ports on this VM, since they > would collide with some other application that is already listening > on these ports. The forwarded port to is already in use > on the host machine. > To fix this, modify your current project's Vagrantfile to use another > port. Example, where '1234' would be replaced by a unique host port: > config.vm.network :forwarded_port, guest: 80, host: 1234 > Sometimes, Vagrant will attempt to auto-correct this for you. In this > case, Vagrant was unable to. This is usually because the guest machine > is in a state which doesn't allow modifying port forwarding. You could > try 'vagrant reload' (equivalent of running a halt followed by an up) > so vagrant can attempt to auto-correct this upon booting. Be warned > that any unsaved work might be lost. If I append auto_correct: true to the mappings it work but I get a different end result... Rhyss-MacBook-Pro:vagrant rhyscampbell$ vagrant port testnagios01 > The forwarded ports for the machine are listed below. Please note that > these values may differ from values configured in the Vagrantfile if the > provider supports automatic port collision detection and resolution. > 22 (guest) => 2206 (host) > 80 (guest) => (host) > Rhyss-MacBook-Pro:vagrant rhyscampbell$ vagrant port testnagios02 > The forwarded ports for the machine are listed below. Please note that > these values may differ from values configured in the Vagrantfile if the > provider supports automatic port collision detection and resolution. > 22 (guest) => 2208 (host) > 80 (guest) => 2207 (host) > 80 (guest) => 8889 (host) Note the second host has two mappings to port 80. Which is really weird. One is the result of the auto_correct so it's being applied twice to the second host. -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/9e47e759-a094-4cc5-a8b4-8ec9ccc506c8%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.