Vagrant vm doesn't up properly - windows

I'm a Win10 user with Vagrant. I'm not be able to work a virtual machine. This is its Vagrantfile:
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/focal64"
config.vm.network "forwarded_port", guest: 3000, host: 3000
config.vm.network "forwarded_port", guest: 3001, host: 3001
config.vm.network "forwarded_port", guest: 3306, host: 3002
config.vm.network "forwarded_port", guest: 27017, host: 3003
config.vm.network "forwarded_port", guest: 80, host: 3004
config.vm.network "forwarded_port", guest: 8080, host: 3005
config.vm.synced_folder "E:\\dev", "/workspace"
config.vm.provision "file", source: "secure_mongo.js", destination: "./"
config.vm.provision "shell", path: "provision.sh"
config.vm.provision "shell", path: "secure_mysql.sh"
end
When I type vagrant up it's getting freeze at the same point
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'ubuntu/focal64'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'ubuntu/focal64' version '20220608.0.0' is up to date...
==> default: Setting the name of the VM: ubuntu-v_default_1655053088358_18221
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 3000 (guest) => 3000 (host) (adapter 1)
default: 3001 (guest) => 3001 (host) (adapter 1)
default: 3306 (guest) => 3002 (host) (adapter 1)
default: 27017 (guest) => 3003 (host) (adapter 1)
default: 80 (guest) => 3004 (host) (adapter 1)
default: 8080 (guest) => 3005 (host) (adapter 1)
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.
If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.
If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes.
Verify that authentication configurations are also setup properly,
as well.
If the box appears to be booting properly, you may want to increase
the timeout ("config.vm.boot_timeout") value.
If you try to connect using vagrant ssh nothing is happend. I also tried Putty and there is no signal...
Any solution?

Related

Configuration issue with OpenShift3 origin/all-in-one, vagrant Cluster setup

I am facing issue to see login page at
https://10.2.2.2:8443/console
,
even when I trying to do
"oc login https://10.2.2.2"
It worked for the first installation and I was able to login, but I had no luck when I did few re-installations to customize.
I have already gone throgh existing github vagrant issues, and stackoverflow as well but no clues for this issue.
I appreciate if someone can help me with this issue.
Installations Detals:
I've followed this blog for cluster setup in my mac ,
1) Installed VirtualBox Version 5.1.14 r112924 (Qt5.6.2)
2) Installed Vagrant 1.9.1
Here is my Vagrantfile config,
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.require_version ">= 1.7.2"
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version. Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
config.vm.box = "openshift/origin-all-in-one"
# uncomment this line if you downloaded the box and want to use it instead
# config.vm.box = "openshift3"
config.vm.box_check_update = false
config.vm.network "private_network", ip: "10.2.2.2"
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.hostname = "origin"
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
# config.vm.network "forwarded_port", guest: 80, host: 8080
# config.vm.network "forwarded_port", guest: 80, host: 1080
# config.vm.network "forwarded_port", guest: 443, host: 1443
# config.vm.network "forwarded_port", guest: 5000, host: 5000
# config.vm.network "forwarded_port", guest: 8080, host: 8080
# config.vm.network "forwarded_port", guest: 8443, host: 8443
config.vm.provider "virtualbox" do |vb|
# vb.gui = true
vb.memory = "4096"
vb.cpus = 2
vb.name = "origin-1.3.0"
end
end
This is my debug logs for Vagrant up --debug
Last login: Wed Feb 1 13:59:59 on ttys000
xxxxxs-MBP:origin xxxxx$ vagrant init openshift/origin-all-in-one
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.
xxxxxs-MBP:origin xxxxx$ vagrant up --provider=virtualbox
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'openshift/origin-all-in-one' could not be found. Attempting to find and install...
default: Box Provider: virtualbox
default: Box Version: >= 0
==> default: Loading metadata for box 'openshift/origin-all-in-one'
default: URL: https://atlas.hashicorp.com/openshift/origin-all-in-one
==> default: Adding box 'openshift/origin-all-in-one' (v1.3.0) for provider: virtualbox
default: Downloading: https://atlas.hashicorp.com/openshift/boxes/origin-all-in-one/versions/1.3.0/providers/virtualbox.box
==> default: Successfully added box 'openshift/origin-all-in-one' (v1.3.0) for 'virtualbox'!
/Users/xxxxx/.vagrant.d/boxes/openshift-VAGRANTSLASH-origin-all-in-one/1.3.0/virtualbox/include/_Vagrantfile:5: warning: already initialized constant VAGRANTFILE_API_VERSION
/Users/xxxxx/origin/Vagrantfile:5: warning: previous definition of VAGRANTFILE_API_VERSION was here
==> default: Importing base box 'openshift/origin-all-in-one'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: origin-1.3.0
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
default: Adapter 3: hostonly
==> default: Forwarding ports...
default: 8443 (guest) => 8443 (host) (adapter 1)
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Remote connection disconnect. Retrying...
default:
default: Vagrant insecure key detected. Vagrant will automatically replace
default: this with a newly generated keypair for better security.
default:
default: Inserting generated public key within guest...
default: Removing insecure key from the guest if it's present...
default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
default: No guest additions were detected on the base box for this VM! Guest
default: additions are required for forwarded ports, shared folders, host only
default: networking, and more. If SSH fails on this machine, please install
default: the guest additions and repackage the box to continue.
default:
default: This is not an error message; everything may continue to work properly,
default: in which case you may ignore this message.
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Running provisioner: shell...
default: Running: inline script
==> default:
==> default: Successfully started and provisioned VM with 2 cores and 5 G of memory.
openshift.service in vm is failing to start automatically,
I did ssh to machine and started manually with command sudo systemctl start origin and everything working perfect.
I had a bit of issue with Origin myself. I ended up using Docker and OpenShift Client. I have written down step by step on how to get started with OpenShift Origin on Windows. I am not trying to promote anything here. The entry is too long for me to cut and paste it. Please visit the link below:
http://blog.muralibala.com/2017/01/getting-started-with-openshift-origin-on-windows/
Hope this is helpful.

Conditional port forwarding in vagrantfile

I'm trying to create a multi vm setup using vagrant where only the server's exposed port needs to be forwarded to the specified host machine port. Client ports need not be exposed. But when I try to do this using the attached Vagrantfile, it for some reason is evaluating my if condition for filtering the clients out, true for clients also. Can someone point out what I may be doing wrong here?
Vagrantfile:
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = '2'
BASEBOX = 'centos-6.7'
BOX_MEMORY = '256'
# Declare the cluster config in a hash
HOST_CONFIG = {
'some_server' => '192.168.205.10',
'some_client' => '192.168.205.11'
}
# Create the vms
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = BASEBOX
HOST_CONFIG.each do |hostname, hostip|
config.vm.network "forwarded_port", guest: 80, host: 8080 if hostname == "some_server"
config.vm.define hostname do |hname|
hname.vm.provider 'virtualbox' do |v|
v.name = hostname
v.customize [ 'modifyvm', :id, '--cpus', '1' ]
v.customize [ 'modifyvm', :id, '--memory', BOX_MEMORY ]
end
hname.vm.network 'private_network', ip: hostip
hname.vm.provision :hosts do |provisioner|
provisioner.autoconfigure = true
provisioner.sync_hosts = true
end
hname.vm.provision 'ansible' do |ansible|
ansible.playbook = 'bootstrap.yml'
end
end
end
end
Output:
$ vagrant up
Bringing machine 'server' up with 'virtualbox' provider...
Bringing machine 'client' up with 'virtualbox' provider...
==> server: Importing base box 'centos-6.7'...
==> server: Matching MAC address for NAT networking...
==> server: Setting the name of the VM: server
==> server: Clearing any previously set network interfaces...
==> server: Preparing network interfaces based on configuration...
server: Adapter 1: nat
server: Adapter 2: hostonly
==> server: Forwarding ports...
server: 80 (guest) => 8080 (host) (adapter 1)
server: 22 (guest) => 2222 (host) (adapter 1)
==> server: Running 'pre-boot' VM customizations...
==> server: Booting VM...
==> server: Waiting for machine to boot. This may take a few minutes...
server: SSH address: 127.0.0.1:2222
server: SSH username: vagrant
server: SSH auth method: private key
server: Warning: Remote connection disconnect. Retrying...
server: Warning: Remote connection disconnect. Retrying...
==> server: Machine booted and ready!
==> server: Checking for guest additions in VM...
==> server: Configuring and enabling network interfaces...
==> server: Mounting shared folders...
server: /vagrant => /Users/ANJUWAA/Projects/Nagios
==> server: Running provisioner: hosts...
==> client: Importing base box 'centos-6.7'...
==> client: Matching MAC address for NAT networking...
==> client: Setting the name of the VM: client
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 8080 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.
Now you are effectively setting the vm.network value for all machines if one of them is named some_server.
You should place the vm.network setting inside the vm.define-loop:
HOST_CONFIG.each do |hostname, hostip|
config.vm.define hostname do |hname|
hname.vm.network "forwarded_port", guest: 80, host: 8080 if hostname == "some_server"
hname.vm.provider 'virtualbox' do |v|
v.name = hostname
v.customize [ 'modifyvm', :id, '--cpus', '1' ]
v.customize [ 'modifyvm', :id, '--memory', BOX_MEMORY ]
end

when i vagrant up, port 80 is not forwarded

i get this output when i vagrant up, port 80 is not forwarding so how i will be able to access the site via web browser
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'hashicorp/precise64'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'hashicorp/precise64' is up to date...
==> default: Setting the name of the VM: Homestead_default_1472822347316_22641
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
default:
default: Vagrant insecure key detected. Vagrant will automatically replace
default: this with a newly generated keypair for better security.
default:
default: Inserting generated public key within guest...
default: Removing insecure key from the guest if it's present...
default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
help me ,thanks
The default Vagrantfile, generated by vagrant init, includes an example of how to forward port 80:
# config.vm.network "forwarded_port", guest: 80, host: 8080
Simply uncomment this line and adjust the ports as necessary.
Vagrant can't forward host ports < 1024.
So if you do config.vm.network "forwarded_port", guest: 80, host: 80 it won't work.
You can use a local SSH tunnel to listen on port 80 on your host and forward the traffic to port 80 on your guest.
sudo ssh -p 2222 -gNfL 80:localhost:80 vagrant#localhost -i ~/.vagrant.d/insecure_private_key

forwarding the ssh port fails when running two vagrant instances from the same host?

Trying to run two vagrant instances on the same host. The vagrant files on the first instance does nothing special with the SSH ports:
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
config.vm.network "forwarded_port", guest: 8080, host: 9080
config.vm.network "forwarded_port", guest: 8081, host: 9081
config.vm.network "forwarded_port", guest: 9990, host: 9090
config.vm.network "forwarded_port", guest: 8983, host: 8983
config.vm.network "forwarded_port", guest: 8985, host: 8985
config.vm.network "forwarded_port", guest: 2181, host: 2181
config.vm.network "forwarded_port", guest: 8002, host: 8002
# If true, then any SSH connections made will enable agent forwarding.
# Default value: false
# config.ssh.forward_agent = true
And this instance spins up as expected:
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'hashicorp/precise32' is up to date...
==> default: Resuming suspended VM...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection refused. Retrying...
==> default: Machine booted and ready!
The second instance forwards port guest 22 to host 2221:
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
config.vm.network "forwarded_port", guest: 8080, host: 10080
config.vm.network "forwarded_port", guest: 80, host: 45678
config.vm.network "forwarded_port", guest: 9999, host: 10999
config.vm.network "forwarded_port", guest: 9000, host: 10900
config.vm.network "forwarded_port", guest: 22, host: 2221
But when it spins up, I'm still getting conflicts on port 22222:
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'hashicorp/precise32' is up to date...
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 2222 is already in use on the host
machine.
To fix this, modify your current projects Vagrantfile to use another
port. Example, where '1234' would be replaced by a unique host port:
config.vm.network :forwarded_port, guest: 22, 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.
So I had this working, with the same two vagrant files 3 months ago. It seems like there has been an update to the underlying 'hashicorp/precise32' boxes without a corresponding documentation change, and modifications to the ssh port forrwarding are no longer allowed? Updating the config.ssh.port would seem to require a change to the underlying image.
Thoughts?
==================================================
Update:
Launching the 2nd instance (forwards 22 => 2221), then reloading produces the following output:
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'hashicorp/precise32' is up to date...
==> default: Resuming suspended VM...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection refused. Retrying...
==> default: Machine booted and ready!
Elizabeth#Work /cygdrive/c/Gui-again
$ vagrant reload
==> default: Attempting graceful shutdown of VM...
==> default: Checking if box 'hashicorp/precise32' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 8080 => 10080 (adapter 1)
default: 80 => 45678 (adapter 1)
default: 9999 => 10999 (adapter 1)
default: 9000 => 10900 (adapter 1)
default: 22 => 2221 (adapter 1)
default: 22 => 2222 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection timeout. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
default: The guest additions on this VM do not match the installed version of
default: VirtualBox! In most cases this is fine, but in rare cases it can
default: prevent things such as shared folders from working properly. If you see
default: shared folder errors, please make sure the guest additions within the
default: virtual machine match the version of VirtualBox you have installed on
default: your host and reload your VM.
default:
default: Guest Additions Version: 4.2.0
default: VirtualBox Version: 4.3
==> default: Mounting shared folders...
default: /vagrant => C:/OSC/PBD-Gui-again
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: to force provisioning. Provisioners marked to run always will still run
So somewhere the ssh port is being forced to 2222. This isn't in the vagrant file itself, where else to look?
You can try adding an 'id ssh' to the end
config.vm.network :forwarded_port, guest: 22, host: 2221, id: 'ssh'
Or maybe this works for you, to first disable the ssh port (Depends on the Vagrant version)
config.vm.network :forwarded_port, guest: 22, host: 2221, id: "ssh", disabled: true
config.vm.network :forwarded_port, guest: 22, host: 2221, auto_correct: true
Source:
https://github.com/mitchellh/vagrant/issues/3232

Windows + Vagrant port forwarding not working

I am using vagrant 1.6.2 on Windows 7, to run a Ubuntu 12.04 Virtual Machine.
I have enabled this on my Vagrantfile:
config.vm.network :forwarded_port, guest: 3000, host: 3000
config.vm.network :forwarded_port, guest: 27017, host: 27017, auto_correct: true
config.vm.network :forwarded_port, guest: 27018, host: 27018, auto_correct: true
config.vm.network :forwarded_port, guest: 9494, host: 9494
In the box, I can see that Mongodb is running,
~ $ mongo
MongoDB shell version: 2.0.4
connecting to: test
> exit
bye
However, from my Windows Host, I am unable to connect to the Mongodb instance, using localhost:27017.
The auto_correct: true was something I read on one of the forums, and tried it out.
On vagrant up this is what I get on the console:
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 3000 => 3000 (adapter 1)
default: 27017 => 27017 (adapter 1)
default: 27018 => 27018 (adapter 1)
default: 9494 => 9494 (adapter 1)
default: 22 => 2222 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection timeout. Retrying...
==> default: Machine booted and ready!
GuestAdditions 4.3.12 running --- OK.
And if I do a rackup -p 3000, I am able to hit http://localhost:3000. Port 9494 also works, it is just the Mongo ports that aren't working.
And I had Mongo installed in my host (Windows), I uninstalled it, still the same problem.
Any hints?
It seems your Vagrant port forwarding is working fine. Your issue is probably because MongoDB is setup to only listen on 127.0.0.1. Check your bindip setting.

Resources