How create an ssh connection from vagrant to a specific virtual machine? Can I create a connection to a VM installed on WMware? - vagrant

I am absolutly new in Vagrant and in Apache Storm.
I am following an online course where show the following situation.
1) There is an Ubuntu virtual machine installed on Virtual Box
2) On the physic machine (the same where is installed Virtual Box and that run the Ubuntu VM) it is installed Vagrant
Ok, from the physic machine, it log into the virtual machine using this statment:
vagrant ssh
and show that it is created a connection to the installed Ubuntu VM.
Here the first doubt: how it know what is the exact virtualized system? What happen if I have installed more than one VM on Virtual Box (with the previous command it is not specified to what installed VM have to be connected)
Another doubt is: I don't use Virtual Box but I use WMware workstation? How can I use the vagrand ssh command to create a connection to a specific VM installed on my WMware workstation?

I'd try to answer a few points from your question -
First, in vagrant language the physic machine will be the host and the VM is called the guest (or guest VM)
Vagrant knows how to connect to the VM it did create as it maintains the Id of the created VM into a .vagrant directory where you have initialized the Vagrantfile.
You can run vagrant global-status and you will have an output with all the VMs that vagrant managed along with the Id, Name and Provider information.
The provider can be VirtualBox or VMWare or anything else. The same in the .vagrant directory you will have subdirectory for the provider (e.g. a directory .vagrant/machines/default/virtualbox or .vagrant/machines/default/vmware_xxx) by default vagrant will start the Virtualbox provider but you can specify the --provider=XXX option when setting up the VM for the 1st time and then vagrant will create the VM for this specific provider and further command on this VM (ssh, reload ...) will work on this specific provider.

Related

we are testing a scenario in which we have to transfer the file from hyperv host to guest vm

the main point is that we don't have internet connectivity to the guest VM
we have a HyperV-VM with windows server 2019 and have a guest VM of ubuntu 18.04
we have tried all the possible scenarios like unmounting of vhdx drive of guest VM and creating a shared folder and etc

Vagrant cannot vagrant up the box packaged from ubuntu xenial64 16.04

I have a custom vagrant box based on the offcial box ubuntu 16.04.
I simplly run like this to get the packaged box.
vagrant init ubuntu/xenial64; vagrant up --provider virtualbox
vagrant up
vagrant ssh # enter the virtual machine and do some custom change on it
vagrant halt
vagrant package --vagrantfile Vagrantfile --output custom_ubuntu1604.box
and then i copy the file custom_ubuntu1604.box to another directory, i use the box like this:
vagrant box add ubuntu1604base custom_ubuntu1604.box
vagrant init ubuntu1604base
vagrant up # at this point the machine will be stopped at "Started Journal Servie"
my new virtualbox machine base on the new packaged box will stop at:
the screenshot
And finally it timed out:
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.
Try to set config.vm.boot_timeout in Vagrantfile more than default e.x.600. From my experience I found out it take a long time at the first time to connecting guest machine.
For example
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/xenial64"
config.vm.provider "virtualbox"
config.vm.boot_timeout = 600
end

Vagrant access guest machine from host (windows)

I installed a vagrant virtual machine in Windows, it's working fine, I am trying to connect to the guest machine from windows, but as soon as I uncomment some thing in Vagrantfile like :
config.vm.network "private_network", ip: "192.168.33.10"
OR
config.vm.network "public_network"
when reloading vagrant, I got this error :
The guest machine entered an invalid state while waiting for it
to boot. Valid states are 'starting, running'. The machine is in the
'poweroff' state. Please verify everything is configured
properly and try again.
If the provider you're using has a GUI that comes with it,
it is often helpful to open that and watch the machine, since the
GUI often has more helpful error messages than Vagrant can retrieve.
For example, if you're using VirtualBox, run `vagrant up` while the
VirtualBox GUI is open.
The primary issue for this error is that the provider you're using
is not properly configured. This is very rarely a Vagrant issue.
I know this does not make sense but I just open VirtualBox and with right-click goes to Settings of created vagrant machine image and diable Audio and it is working after save and run vagrant up
I never encountered that error personally, having never used vagrant on windows. This issue has been discussed here.

Unable to read from Guest OS in VirtualBox. Host: Windows 8, Guest: CentOS 6

I'm hoping to have a situation where I can write code in the CentOS guest, and have it presented to me in a browser under the host OS. I'm currently using Windows 8 as my host.
My current network settings, and...
When typing ifconfig into the guest.
All I want to is to be able to get PHP code that is in /var/www/html on the guest machine, and have it show in the host machine's browsers. Suggestions?
Maybe you should give a look at Vagrant, a tool that allows you to replicate development environments on a guest machine and run the applications on your host's browser by opening a port that gives you access to localhost of the guest machine.
You can even edit the code in your host vm, but all the dependencies of the project are hosted by the guest vm.

Using gitlab-vagrant-vm from OSX host

I followed the instructions here and was able to succesfully (I think) install the gitlab vagrant virtual machine on OSX 10.8 using virtualbox.
I can do vagrant up to get the VM running, and everything seems to work fine. After that I can do vagrant ssh without a problem. Also, after sshing into the VM I was able to do bundle exec rake gitlab:test, which completed with results being 1584 examples, 0 failures.
I would like to see the gitlab web interface from my OSX host machine. I thought I could just direct my browser to the IP indicated in the VagrantFile (http://192.168.3.14), but that didn't work.
Any ideas?
Also any other usage tips for this setup would be appriciated (things like where the repositories are stored on my host machine so I can back them up, if anyone set the gitlab-vagrant-vm up for external access from either another computer on the network or a remote source, ect.)
You have to connect a second interface for vagrant. To do this you've to edit the VagrantFile.
For example if you want to conenct to the host wifi add the following line after 192.168.3.14
config.vm.network :bridged, bridge: "en0: Wi-Fi (AirPort)"
You also can bridge to the ethernet interface. Use ifconfig on the host machine to determine the right interface. After that the dyndns-server of the host network will assign an IP to the Vagrant-Box. Then you can access GitLab on that IP.
Did you actually start the server? You can do that with
bundle exec foreman start -p 3000
This will start the server on port 3000, you would then access it from the host with
http://192.168.3.14:3000/
Hope this helps,
Chris

Resources