Vagrant cannot vagrant up the box packaged from ubuntu xenial64 16.04 - vagrant

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

Related

Vagrant Waiting For Domain To Get An IP Address

First, apologies: I'm a newbie.
I've created a very basic Vagrantfile by running Vagrant init. I only made a few changes:
config.vm.box = "generic/fedora28"
config.vm.box_version = "1.8.32"
config.vm.provider "libvirt" do |lv|
lv.memory = "4096"
end
(There are also a few items in my config.vm.provision section).
After running vagrant up , the process gets stuck at
==> default: Waiting for domain to get an IP address...
I'm running this off a Fedora 27 box, which uses version 2.0.2 of the Vagrant package (even though current is 2.1.5).
I've tried adding this line:
config.vm.network "private_network", ip: "192.168.100.101"
but it had no effect.
Can anyone help?
I have a Vagrant File that spins up 4 VMs, of image generic/ubuntu2004 on libvirt kvm, to make a k3s cluster that's accessible on the LAN. (multipass + k3s is only accessible via localhost b/c it doesn't allow easy bridging.)
I ran both of these commands > 50 times
sudo vagrant destroy --force --parallel
sudo vagrant up
On the ~51'st time, I noticed vagrant up got stuck on "Waiting for domain to get an IP address..."
What fixed it for me was sudo reboot. You know the classic have you tried unplugging it and plugging it back in?
Something else to try (I rebooted before trying it)
https://bugzilla.redhat.com/show_bug.cgi?id=1283989

How do I know which vagrantfile is in use?

This seems to be common problem:
Lets say i have a project which has Vagrantfile. So i executed "vagrant up" and vagrant machine is up and running. So for so good.
After few days i synced the same project codebase to another location on same machine and tried to execute vagrant up. But this time it failed saying "vagrant cant forward request to this port 8080". This is because another vagrant instance occupied this port 8080.
Now if i want to know from where this vagrant box spin off, how can i do this?
This command will tell you the state of all Vagrant environments:
$ vagrant global-status
If you would stop any machin, you can use:
$ vagrant halt id

Please clarify vagrant behavior

I have just started working with Vagrant. After starting guest machine and making some changes (e.g. installed some updates and python virtualenvs). And after few (vagrant halt and vagrant reload) when I ssh-ed into guest machine I noticed that all my changes disappeared. When I opened the Virtualbox I saw that there were two boxes with the name of my folder with guest os and on every vagrant up it seems like it is starting the second machine. When I started the first guest os through virtual box interface I saw that my data was present. How can I start with vagrant the first machine? Should I delete the second? When was it created?
Start with vagrant up
Vagrantfile
Vagrant.configure(2) do |config|
config.vm.box = "trusty_14"
config.vm.network "forwarded_port", guest: 8000, host: 8000
end`
So I tried to vagrant destroy. The second machine was deleted indeed, but after vagrant up the new one was created.
Then I checked the id's following #Frédéric Henri advice, and in id file was id of second machine, so I have replaced it with the id of first machine from VBoxManage list vms, and everything works!
But still did not get how and when the second machine was created...

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.

Vagrant Warning: Connection refused. Retrying

Testing default example
$ vagrant init hashicorp/precise32
$ vagrant up
My box:
Windows 8.1
VirtualBox 5.0.2
Vagrant 1.7.4
Intel i7-4700MQ CPU witch seems to have Intel® Virtualization Technology (VT-x) http://ark.intel.com/products/75117/Intel-Core-i7-4700MQ-Processor-6M-Cache-up-to-3_40-GHz
I know this is common error but after trying everything I still cannot make it work
While VM shows:
And I can log in successfully:
Firewall / Antivirus turned off.
Hyper-V is not installed
I have tried connecting via putty to 127.0.0.1 2222
EDIT:
Vagrantfile (I have removed commented out lines)
Vagrant.configure(2) do |config|
config.vm.box = "hashicorp/precise32"
end
This is what vagrant ssh does... nothing. And vagrant reload stuck on same issue.
This happens with Vagrant from time to time with the first spin up. After it does that it will timeout and drop you back at the prompt, go vagrant ssh, it will let you in. If it does not go vagrant reload and it will restart the vm. This occurs because the vagrant images have dns turned off so it takes a while to resolve the connection. Again, this sometimes occurs on the first up after you download it and spin it up.
I suspect this could be a misconfigured VBox guest.
I suppose you could try making sure that NAT and port forwarding are enabled in the settings of your VM, and if they aren't, you could enable it manually: in the VirtualBox Graphical Manager, select the machine, click on settings, click on network at the right of the popup, check all the adapters and make sure that the adapter that is "attached to NAT" is enabled. Also, check the port forwarding settings. You can also access the network settings when you are running the VM, from the buttons at the bottom/left (the third button in your second pic, from left to right).
Something that I found out was the case for me after multiple destroys/reebots: check if you have an SSH agent running with a key loaded (like Pageant for PuTTY).
In my case having another SSH key loaded with Pageant (instead of the one configured for Vagrant) was conflicting with the authentication process, which resulted in endless "Connection refused. Retrying" and ultimately in me being unable to use Vagrant.
The solution is to either
Load the appropriate key in Pageant
Close pageant (what I usually do, as it's faster in my case)
Hope this helps someone out there!
here are a few things I would try (and I do understand you might have tried a lot of this and it might not solve your issues but just in case) :
follow the steps from https://www.hanselman.com/blog/SwitchEasilyBetweenVirtualBoxAndHyperVWithABCDEditBootEntryInWindows81.aspx to completely disable Hyper-V (not sure its enough from windows features - and even though you're using a 32-bit box)
not sure if you enabled the gui mode when you logged into the vm from virtual box or you just opened it after, but enable the option and check if nothing is blocking during the startup
config.vm.provider :virtualbox do |vb|
vb.gui = true
end
use another ssh port (even though it does not mention there is a collision) you can try another port
config.vm.network :forwarded_port, guest: 22, host: 2522, auto_correct: false, id: "ssh"
see after vagrant up if you can connect with putty.
optionally, you can run vagrant up --debug to get more information about the error, you will see where it loops/error and give the output of that for others on SO to comment
EDIT
Giving another look, I thought the issue was about connection timeout but it is connection refused the message says
SSH username: vagrant
SSH auth method: password
but you're not passing any password in the Vagrantfile you show. Just add
Vagrant.configure(2) do |config|
config.vm.box = "hashicorp/precise32"
config.ssh.username = "vagrant"
config.ssh.password = "vagrant"
end
I would recommend to use ssh-key as it is a bit more simple to use.

Resources