Hyperledger fabric end to end flow: vagrant up in devenv fails - vagrant

I'm following the instructions at this link: https://github.com/hyperledger/fabric/blob/master/examples/e2e_cli/end-to-end.rst
I have set the development environment following instructions here (http://hyperledger-fabric.readthedocs.io/en/latest/dev-setup/devenv.html)
Now when inside the devenv folder I run 'vagrant up', I get the following:
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'hyperledger/fabric-baseimage'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'hyperledger/fabric-baseimage' is up to date...
==> default: Setting the name of the VM: hyperledger
==> default: Destroying VM and associated drives...
C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant- 1.9.3/lib/vagrant/util/is_port_open.rb:21:in `initialize': The requested address is not valid in its context. - connect(2) for "0.0.0.0" port 7050 (Errno::EADDRNOTAVAIL)
I appreciate some help here.

This is a problem with vagrant 1.9.3 which should be fixed in the next release:
https://github.com/mitchellh/vagrant/pull/8399
In the meantime you can work around it by specifying in the Vagrantfile the host ip in every port forwarding command:
config.vm.network :forwarded_port, guest: 7050, host: 7050, host_ip: "127.0.0.1" # fabric orderer service
config.vm.network :forwarded_port, guest: 7051, host: 7051, host_ip: "127.0.0.1" # fabric peer service
config.vm.network :forwarded_port, guest: 7053, host: 7053, host_ip: "127.0.0.1" # fabric peer event service
config.vm.network :forwarded_port, guest: 7054, host: 7054, host_ip: "127.0.0.1" # fabric-ca service
config.vm.network :forwarded_port, guest: 5984, host: 15984, host_ip: "127.0.0.1" # CouchDB service
With this change vagrant up works for me.

Related

vagrant port forwarding guest and host port messed up

I'm using a vagrant trusty64 box with nginx, flask, gunicorn and port forwarding is not working as expected
In the vagrant file, I have:
config.vm.network "forwarded_port", guest: 8090, host: 3100
config.vm.network "private_network", ip: "10.10.1.10"
On the box, I have run:
gunicorn myprj:app -b 10.10.1.10:8090
find nothing on host machine with http://10.10.1.10:3100
trying curl -v http://10.10.1.10:3100 gives the following output:
connect to 10.10.1.10 port 3100 failed: Connection refused
Reachable with guest port on host machine http://10.10.1.10:8090
I am new to the vagrant, did I miss/mess to Vagrant file.
Complete Vagrant file:
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.box_check_update = false
config.vm.network "forwarded_port", guest: 8090, host: 3100
config.vm.network "private_network", ip: "10.10.1.10"
config.vm.synced_folder ".", "/vagrant_data"
config.vm.provider "virtualbox" do |vb|
vb.memory = "1024"
vb.name = "lopamudra_dev"
end
config.vm.provision "shell", inline: <<-SHELL
# Upgrading the environment
apt-get update
apt-get upgrade
# Installing nginx + uwsgi + flask
apt-get install -y python-pip python-dev nginx
pip install uwsgi flask gunicorn
SHELL
end
You are forwarding container 8090 to hostIP:3100 (localhost:3100)
At the same time you are creating a IP to access your container with 10.10.1.10 and you container has 8090 exposed, thats why you can acces it on 10.10.1.10:8090
# 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.
# NOTE: This will enable public access to the opened port
config.vm.network "forwarded_port", guest: 8090, host: 3100
# Create a private network, which allows host-only access to the machine
# using a specific IP.
config.vm.network "private_network", ip: "10.10.1.10"

Files created in Vagrant centos/7 do not appear in Windows [duplicate]

This question already has answers here:
Vagrant Synced Folder without reload?
(2 answers)
Closed 5 years ago.
I have primarily used Ubuntu boxes in Vagrant and in those any files created within the box have been successfully synced to Windows also. Usually things like git pull.
However, I now have centos/7 and cannot get any files to sync to Windows. If you create a file in /vagrant it never appears anywhere in Windows - not under C:\cygwin64\ nor C:\vm\machine. When I vagrant reload the box, all the files created inside the box are gone, except configuration files eg. /etc/httpd/conf/httpd.conf. Any changes in them are still present upon vagrant reload and also vagrant halt; vagrant up.
Here's the Vagrantfile:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.vm.network "forwarded_port", guest: 80, host: 8086, host_ip: "127.0.0.1"
config.vm.network "forwarded_port", guest: 3306, host: 3386, host_ip: "127.0.0.1"
config.vm.synced_folder "./", "/vagrant"
# I have also tried the following:
# config.vm.synced_folder "C:/vm/machine", "/vagrant"
# config.vm.synced_folder "./", "/vagrant", type: "rsync", disabled: false
end
When doing vagrant up, both methods for synced_folder display this:
==> default: Rsyncing folder: /cygdrive/c/vm/machine/ => /vagrant
I have tried doing vagrant up from both cmd.exe and also from the Cygwin64 Terminal (under /c/vm/machine). Neither of them create files to the Windows directory, which is in C:\vm\machine.
What do I need to do to make files created in the box also sync to Windows?
When I try the same in an Ubuntu box, the file appears in Windows and does not disappear:
This is the Vagrantfile of the Ubuntu box:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "v0rtex/xenial64"
config.vm.network "forwarded_port", guest: 80, host: 8083, host_ip: "127.0.0.1"
config.vm.network "forwarded_port", guest: 443, host: 8443, host_ip: "127.0.0.1"
config.vm.network "forwarded_port", guest: 3306, host: 3303, host_ip: "127.0.0.1"
config.vm.network "forwarded_port", guest: 5000, host: 5003, host_ip: "127.0.0.1"
config.vm.network "forwarded_port", guest: 8000, host: 8003, host_ip: "127.0.0.1"
config.vm.network "forwarded_port", guest: 9090, host: 9093, host_ip: "127.0.0.1"
config.vm.network "forwarded_port", guest: 9091, host: 9193, host_ip: "127.0.0.1"
end
Upon vagrant up for the Ubuntu box, I see this:
==> default: Mounting shared folders...
default: /vagrant => C:/vm/ubu1604-64
The solution is as follows:
Change the Vagrantfile synced_folder part to this:
config.vm.synced_folder "./", "/vagrant", type: "virtualbox", disabled: false
And then run this command in the directory where the Vagrantfile is:
vagrant plugin install vagrant-vbguest
Then do either vagrant reload if it was already running, or vagrant up otherwise.
It will run for quite a while - for me it took about 7 minutes altogether. However, it is a one-time install, so all future vagrant up's will take a normal amount of time.
After that, the files created in the /vagrant directory will also appear in Windows C:\vm\machine (for example) and will persist between Vagrant sessions, ie. vagrant halt + vagrant up

How to share a vagrant machine with https

I have a working vagrant VM I want to Share. In my Vagrantfile I have:
config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.network "private_network", ip: "192.168.1.15"
config.vm.network "forwarded_port", guest: 443, host: 443
in the virtual host I have
<VirtualHost *:443>
...
ServerAlias *.vagrantshare.com
....
</Virtualhost>
not sure about the first line but it was there already
I share the machine with
vagrant share --https 443
this is the output:
==> default: Detecting network information for machine...
default: Local machine address: 127.0.0.1
default:
default: Note: With the local address (127.0.0.1), Vagrant Share can only
default: share any ports you have forwarded. Assign an IP or address to your
default: machine to expose all TCP ports. Consult the documentation
default: for your provider ('virtualbox') for more information.
default:
default: Local HTTP port: 8080
default: Local HTTPS port: 443
default: Port: 2222
default: Port: 443
default: Port: 8080
==> default: Checking authentication and authorization...
==> default: Creating Vagrant Share session...
default: Share will be at: towering-badger-9312
==> default: Your Vagrant Share is running! Name: towering-badger-9312
==> default: URL: http://towering-badger-9312.vagrantshare.com
==> default:
==> default: You're sharing your Vagrant machine in "restricted" mode. This
==> default: means that only the ports listed above will be accessible by
==> default: other users (either via the web URL or using `vagrant connect`).
I can see it in vagrant cloud but I got an error while trying to access it via https:
towering-badger-9312.vagrantshare.com is currently unable to handle this request.
HTTP ERROR 500
not any other useful message in the console, any idea how to debug this?
thanks
Replace this line
config.vm.network "forwarded_port", guest: 443, host: 443
with i.e.
config.vm.network "forwarded_port", guest: 443, host: 8443
first, because forwarded_port is for accessing from your host and second, you should not be able to bind to port 443 on host.
Also
vagrant share --https 443
is redundant (docs):
HTTPS (SSL)
Vagrant Share can also expose an SSL port that can be accessed over
SSL. For example, instead of accessing http://foo.vagrantshare.com, it
could be accessed at https://foo.vagrantshare.com.
vagrant share by default looks for any SSL traffic on port 443 in your
development environment. If it cannot find any, then SSL is disabled
by default.
so
vagrant share
should suffice (assuming there's no other issue).

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