Issue with hanging vagrant up on win7 while configuring network adapter - vagrant

Vagrant version: 1.4.0
vagrant-windows version: 1.5.1
Vagrant file:
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "win7.x86.v.004"
config.vm.box_url = "URL"
config.vm.boot_timeout = 300
config.vm.provider :virtualbox do |vb|
vb.gui = true
end
config.windows.halt_timeout = 15
config.winrm.username = "vagrant"
config.winrm.password = "vagrant"
config.vm.guest = :windows
config.vm.network :forwarded_port, guest: 5985, host: 5685, id: "winrm", :auto => true
config.vm.network :forwarded_port, guest: 5986, host: 5686
config.vm.network :forwarded_port, guest: 8080, host: 5687
config.vm.network :forwarded_port, guest: 1521, host: 5688
config.winrm.host = "192.168.33.33"
config.winrm.port = 5985
config.windows.set_work_network = true
config.vm.network :private_network, ip: "192.168.33.33"
config.vm.provision :shell, :path => "provision.bat"
end
I am using selfcreated Win7 enterprise SP1 box
vagrant up hangs on configuring network adapter, debug logs here:
DEBUG configure_networks: vm_interface_map: {1=>{:net_connection_id=>"Local Area
Connection", :mac_address=>"08002753776B", :interface_index=>"11", :index=>"7"}
, 2=>{:net_connection_id=>"Local Area Connection 2", :mac_address=>"080027F5E843
", :interface_index=>"14", :index=>"12"}}
INFO winrmshell: Configuring NIC Local Area Connection 2 using static ip 192.16
8.33.33
DEBUG winrmshell: powershell executing:
netsh interface ip set address "Local Area Connection 2" static 192.168.33.33 25
5.255.255.0
After "netsh" command execution hangs.
Any workaround of how I can resolve this?

found solution, in my VagrantFile there wrong
config.winrm.host = "192.168.33.33"
this shoult be host IP address, but i used guest IP, thats why while executing netsh command "vagrant up" silently hungs.
Reason is that netsh command resets network interface and vagrant can not get result of netsh comand.
mainly, this parametr should not be set or set to 127.0.0.1

Related

Strange behaviour of Vagrant Up command

Whenever I run Vagrant up, I am getting the following error.
Following is my vagrant file
default_box = "generic/opensuse42"
Vagrant.configure("2") do |config|
config.vm.define "master" do |master|
master.vm.box = default_box
master.vm.box_version = "v3.4.4"
master.vm.hostname = "master"
master.vm.network 'private_network', ip: "192.168.0.200", virtualbox__intnet: true
master.vm.network "forwarded_port", guest: 22, host: 2222, id: "ssh", disabled: true
master.vm.network "forwarded_port", guest: 22, host: 2000 # Master Node SSH
master.vm.network "forwarded_port", guest: 6443, host: 6443 # API Access
for p in 30000..30100 # expose NodePort IP's
master.vm.network "forwarded_port", guest: p, host: p, protocol: "tcp"
end
master.vm.provider "virtualbox" do |v|
v.memory = "3072"
v.name = "master"
end
master.vm.provision "shell", inline: <<-SHELL
sudo zypper refresh
sudo zypper --non-interactive install bzip2
sudo zypper --non-interactive install etcd
sudo zypper --non-interactive install apparmor-parser
curl -sfL https://get.k3s.io | sh -
SHELL
end
Any hints will be much appreciated.
The error message provides the info you require:
in 'parse': Illformed requirement ["v3.4.4"] (Gem::Requirement::BadRequirementError)
It basically advises that there is a problem with your version of vm requested from your Vagrantfile:
default_box = "generic/opensuse42"
Vagrant.configure("2") do |config|
config.vm.define "master" do |master|
master.vm.box = default_box
master.vm.box_version = "v3.4.4"
master.vm.hostname = "master"
The problem is that you have used 'v' to define the version, which cannot be parsed for the value attained for the 'config.vm.box_version' attribute variable - it should be :
master.vm.box_version = "3.4.4"
You can always double check your config for a vm from the Vagrant website, in your case generic/opensuse42 - v3.4.4, it shows that it should be:
Vagrant.configure("2") do |config|
config.vm.box = "generic/opensuse42"
config.vm.box_version = "3.4.4"
end
I found that generic/opensuse42 has been expired so changing the box to opensuse/Leap-15.2.x86_64, solved my issue

Vagrant giving me issues when I try to use on WSL2 with Warning: Connection refused. Retrying

I'm so close to booting up my instances to test Vagrant on WSL2 but I continue to run into this issue where when I run vagrant up it gives me the following error:
app1: SSH address: 127.0.0.1:2200
app1: SSH username: vagrant
app1: SSH auth method: private key
app1: Warning: Connection refused. Retrying...
app1: Warning: Connection refused. Retrying...
app1: Warning: Connection refused. Retrying...
Here is my Vagrantfile code:
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "generic/ubuntu1804"
config.ssh.forward_agent = true
config.ssh.forward_agent = true
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.provider :virtualbox do |v|
v.memory = 512
v.linked_clone = true
end
# Application server 1
config.vm.define "app1" do |app|
app.vm.hostname = "orc-app1.test"
app.vm.network :private_network, ip: "192.168.60.4"
end
# Application server 2
config.vm.define "app2" do |app|
app.vm.hostname = "orc-app2.test"
app.vm.network :private_network, ip: "192.168.60.5"
end
# Database server
config.vm.define "db" do |db|
db.vm.hostname = "orc-db.test"
db.vm.network :private_network, ip: "192.168.60.6"
end
end
I removed rm insecure_private_keyand ran vagrant upso it can recreate the insecure_private_key but the error still persists.
Would appreciate any help on this. Feel like moving completely to Linux :)

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

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

Error while running Vagrant up

Initially, I had 8 vagrant machines running and something went wrong. So I deleted the vms in ~/VirtualBox\ VMs folder and placed the backup .vmdk files in the same location.
Then I tried running vagrant up...
But I'm getting the following error
Bringing machine 'virtual-am1' up with 'virtualbox' provider...
==> virtual-am1: Importing base box 'centos653'...
==> virtual-am1: Matching MAC address for NAT networking...
==> virtual-am1: Setting the name of the VM: vagrant_virtual-am1_1478100170176_83326
==> virtual-am1: Clearing any previously set network interfaces...
==> virtual-am1: Preparing network interfaces based on configuration...
virtual-am1: Adapter 1: nat
virtual-am1: Adapter 2: bridged
==> virtual-am1: Forwarding ports...
virtual-am1: 22 (guest) => 2203 (host) (adapter 1)
==> virtual-am1: Running 'pre-boot' VM customizations...
A customization command failed:
["modifyvm", :id, "--name", "virtual-am1"]
The following error was experienced:
#<Vagrant::Errors::VBoxManageError: There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.
Command: ["modifyvm", "6dd13964-e648-40cd-932e-3e18be375d31", "--name", "virtual-am1"]
Stderr: VBoxManage: error: Could not rename the directory '/home/vagrant/VirtualBox VMs/vagrant_virtual-am1_1478100170176_83326' to '/home/vagrant/VirtualBox VMs/virtual-am1' to save the settings file (VERR_ALREADY_EXISTS)
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component SessionMachine, interface IMachine, callee nsISupports
VBoxManage: error: Context: "SaveSettings()" at line 2788 of file VBoxManageModifyVM.cpp
>Please fix this customization and try again.
This is how my Vagrantfile looks like...
We had a custom Vagrant file
# -*- mode: ruby -*-
# vi: set ft=ruby :
#Parse nodes config file
nodes_config = (JSON.parse(File.read("nodes.json")))['nodes']
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.ssh.insert_key = false
config.vm.box = "centos653"
config.vm.box_url = "https://github.com/2creatives/vagrant-centos/releases/download/v6.5.3/centos65-x86_64-20140116.box"
# config.vm.provision :shell, path: "bootstrap.sh"
nodes_config.each do |node|
node_name = node[0] # name of node
node_values = node[1] # content of node
config.vm.define node_name do |config|
# configures all forwarding ports in JSON array
ports = node_values['ports']
ports.each do |port|
config.vm.network :forwarded_port,
host: port[':host'],
guest: port[':guest'],
id: port[':id']
end
config.vm.synced_folder "/bits", "/vagrant/bits"
config.vm.synced_folder "../virtual", "/vagrant/virtual"
config.vm.hostname = node_values[':hostname']
#config.vm.network :private_network, ip: node_values[':ip']
config.vm.network "public_network", bridge: 'enp134s1f0', ip: node_values[':ip']
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", node_values[':memory']]
vb.customize ["modifyvm", :id, "--name", node_values[':node']]
vb.customize ["modifyvm", :id, "--cpus", 8]
end
end
end
end
This is how my nodes.json file looks like
{
"nodes": {
"virtual-am1": {
":node": "virtual-am1",
":ip": "192.168.1.50",
":hostname": "am1.onefederation.org",
"ports": [
{
":host": 2203,
":guest": 22,
":id": "ssh"
}
],
":memory": 1024
},
}
}
Please help!!!
I've had this error and you can use this fix:
Delete folder project in vagrant
rm -rf /home/protobox/VirtualBox VMs/project_folder
Go to project folder:
cd /var/www/project_folder
Then restart vagrant:
vagrant destroy**maybe more**`vagrant destroy -f`
vagrant reload
Finally you start vagrant
vagrant up
vagrant ssh
Or you can refer to here: http://getprotobox.com/docs/issues/vbox_rename
Good luck!

after upgrading from vagrant 1.8.1 to 1.84 not all machines start by default

After i have upgraded the vagrant from 1.8.1 to 1.8.4, when i issue vagrant up command, only first machine starts, while second only will only start if I issue "vagrant up vmname" command. I do not have anything regarding autostart and i assume that both should start, but they dont...
code below:
Vagrant.configure(2) do |config|
config.vm.define :webserver do |webserver|
webserver.vm.box = BASE_IMAGE_NAME
webserver.vm.box_url = BASE_IMAGE_ARTIFACTORY_REF
webserver.vm.network "private_network", ip: "10.2.0.10"
webserver.vm.network "forwarded_port", guest: 80, host: 8880
webserver.vm.network "forwarded_port", guest: 443, host: 4443
webserver.vm.network "forwarded_port", guest: 8080, host: 8888
webserver.vm.synced_folder VAGRANT_SYNC_PATH, TOMCAT_INSTALL_PATH
webserver.vm.synced_folder WEBSERVER_PATH, "/srv/salt/"
webserver.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--memory", "512"]
vb.customize ["modifyvm", :id, "--cpus", "2"]
end
webserver.vm.provision "shell", inline: <<-SHELL
sudo hostname web1.domain.com
SHELL
webserver.vm.provision "salt" do |salt|
salt.masterless = true
salt.minion_config = WEBSERVER_MINION_PATH
###salt.minion_config = "/srv/salt/minion"
salt.run_highstate = true
salt.colorize = true
#salt.verbose = true
end
end
config.vm.define :redis do |redis|
redis.vm.box = BASE_IMAGE_NAME
redis.vm.box_url = BASE_IMAGE_ARTIFACTORY_REF
redis.vm.network "private_network", ip: "10.2.0.20"
redis.vm.network "forwarded_port", guest: 6379, host: 6379
redis.vm.synced_folder VAGRANT_SYNC_PATH, TOMCAT_INSTALL_PATH
redis.vm.synced_folder REDIS_PATH, "/srv/salt/"
redis.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--memory", "512"]
vb.customize ["modifyvm", :id, "--cpus", "2"]
end
redis.vm.provision "shell", inline: <<-SHELL
sudo hostname redis1.domain.com
SHELL
redis.vm.provision "salt" do |salt|
salt.masterless = true
salt.minion_config = REDIS_MINION_PATH
#salt.minion_config = "/srv/salt/minion"
salt.run_highstate = true
salt.colorize = true
#salt.verbose = true
end
end
end
here is the output with salt commented out:
C:\vagrantfiles\MOBILEWEB\WINDOWS\TOMCAT-REDIS>vagrant up
Bringing machine 'webserver' up with 'virtualbox' provider...
==> webserver: Importing base box 'vagrant-centos7-base'...
==> webserver: Matching MAC address for NAT networking...
==> webserver: Setting the name of the VM: TOMCAT-REDIS_webserver_1468231810504_5980 ==> webserver: Clearing any previously set network interfaces...
==> webserver: Preparing network interfaces based on configuration...
webserver: Adapter 1: nat
webserver: Adapter 2: hostonly
==> webserver: Forwarding ports...
webserver: 80 (guest) => 8880 (host) (adapter 1)
webserver: 443 (guest) => 4443 (host) (adapter 1)
webserver: 8080 (guest) => 8888 (host) (adapter 1)
webserver: 22 (guest) => 2222 (host) (adapter 1)
==> webserver: Running 'pre-boot' VM customizations...
==> webserver: Booting VM...
==> webserver: Waiting for machine to boot. This may take a few minutes...
webserver: SSH address: 127.0.0.1:2222
webserver: SSH username: vagrant
webserver: SSH auth method: private key
webserver: Warning: Remote connection disconnect. Retrying...
webserver: Warning: Remote connection disconnect. Retrying...
webserver: Warning: Remote connection disconnect. Retrying...
webserver:
webserver: Vagrant insecure key detected. Vagrant will automatically replace
webserver: this with a newly generated keypair for better security.
webserver:
webserver: Inserting generated public key within guest...
webserver: Removing insecure key from the guest if it's present...
webserver: Key inserted! Disconnecting and reconnecting using new SSH key...
==> webserver: Machine booted and ready!
==> webserver: Checking for guest additions in VM...
==> webserver: Configuring and enabling network interfaces...
==> webserver: Mounting shared folders...
webserver: /vagrant => C:/vagrantfiles/MOBILEWEB/WINDOWS/TOMCAT-REDIS
webserver: /srv/salt => C:/vagrantfiles/vgsalt/webserver
webserver: /opt/apache-tomcat-8.0.33/webapps => C:/vagrantsync
==> webserver: Running provisioner: shell...
webserver: Running: inline script
C:\vagrantfiles\MOBILEWEB\WINDOWS\TOMCAT-REDIS>

Resources