I'm using sysprep'd images so the boot time is very long for each instance. I have been suspicious that config.vm.boot_timeout was not working in VirtualBox but could not find the value in use in the debug. This morning I tried Hyper-V and it reports the wait time, and it is not that I'm trying to set. I've recreated the scenario with a very small Vagrantfile (i.e. without the VirtualBox provider and all my provisioners).
Vagrant.configure(2) do |config|
config.vm.box = 'cdaf/WindowsServerStandard'
config.vm.box_check_update = false
config.vm.guest = :windows
config.vm.communicator = 'winrm'
config.vm.boot_timeout = 600 # 10 minutes
config.vm.provider 'hyperv' do |hyperv, override|
hyperv.memory = 1024
hyperv.cpus = 2
end
end
Here is the output from vagrant up (note the Timeout: 120 seconds)
Bringing machine 'default' up with 'hyperv' provider...
==> default: Verifying Hyper-V is enabled...
==> default: Configured startup memory is 1024
==> default: Configured cpus number is 2
==> default: Importing a Hyper-V instance
default: Cloning virtual hard drive...
default: Creating and registering the VM...
default: Successfully imported a VM with name: WindowServerStandardGUI
==> default: Starting the machine...
==> default: Waiting for the machine to report its IP address...
default: Timeout: 120 seconds
Hyper-V failed to determine your machine's IP address within the
configured timeout. Please verify the machine properly booted and
the network works. To do this, open the Hyper-V manager, find your
virtual machine, and connect to it.
Platform
Host is Windows 10 with Vagrant 1.9.2
Guest is Windows Server 2016
I had misinterpreted the "Timeout: 120 seconds" in hyper-v provider, it is not the WinRM timeout, it is the timeout for the VM to report it's IP address, i.e. I can increase this to 4 minutes using
hyperv.ip_address_timeout = 240
Related
Development is happening on Mac OSX
Writing a cookbook to partition, format, mount drives dynamically based on drives that are not partitioned, mounted, or formatted, May have been taken out of single drive raid-0 configuration, or may not have been configured through raid controller yet...
While working on writing test cases for cookbook. I am having the following issues.
.kitchen.yml file:
driver:
name: vagrant
# ssh:
# insert_key: false
customize:
cableconnected1: 'on'
createhd:
- filename: /tmp/disk1.vdi
size: 128
storagectl:
- name: SATA Controller
portcount: 4
storageattach:
- storagectl: SATA Controller
port: 0
device: 0
type: hdd
medium: /tmp/disk1.vdi
privileged: true
Command: kitchen verify
Gets stuck at the following
Output:
-----> Starting Kitchen (v1.20.0)
$$$$$$ Deprecated configuration detected:
require_chef_omnibus
Run 'kitchen doctor' for details.
-----> Creating <default-centos-7>...
(erb):173: warning: constant ::Fixnum is deprecated
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'bento/centos-7'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'bento/centos-7' is up to date...
==> default: Setting the name of the VM: default-centos-
7_default_1526333511693_18382
==> default: Fixed port collision for 22 => 2222. Now on port 2200.
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 22 (guest) => 2200 (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:2200
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.
Will not proceed any further. The adding disk code was taken directly from the kitchen-vagrant documentation for adding a disk.
I can remove the createhd, storagectl, & storageattach sections, at which point the vagrant box works as intended.
I have verified that the /tmp/disk1.vdi file is created, I also have to delete the file between runs, after a kitchen destroy else I get the following error:
-----> Starting Kitchen (v1.20.0)
$$$$$$ Deprecated configuration detected:
require_chef_omnibus
Run 'kitchen doctor' for details.
-----> Creating <default-centos-7>...
(erb):173: warning: constant ::Fixnum is deprecated
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'bento/centos-7' is up to date...
==> default: Machine not provisioned because `--no-provision` is
specified.
Waiting for SSH service on 127.0.0.1:2200, retrying in 3 seconds
It will continue being stuck on retying in 3 seconds indefinitely until I escape the command.
I have tried with and without:
ssh:
insert_key: false
I have tried different formats of files that vagrant is supposed to support as a disk, including .vdi, .vmdk
I have ensured that SATA Controller is the appropriate controller available for the box.
This seems issue with vagrant and virtualbox versions. You can find a similar issue here
The reason for this is that kitchen/vagrant tries to bind the OS disk to port 0 of your controller. So the reason it doesn't boot is because there is no boot disk bound!
If you change port: 0 to port: 1 in your example it should boot as expected.
I have been having a lot of troubles with Vagrant 2.0.1 on Windows 10 with Hyper V.
When I do vagrant up I receive an ipv6 address. Which chef can't access and fails to provision the virtual:
Bringing machine 'default' up with 'hyperv' provider...
==> default: Verifying Hyper-V is enabled...
==> default: Configured startup memory is 2048
==> default: Configured cpus number is 2
==> default: Importing a Hyper-V instance
default: Cloning virtual hard drive...
default: Creating and registering the VM...
default: Setting VM Integration Services
default: Successfully imported a VM with name: vargrant-dev-source
==> default: Installing Chef cookbooks with Librarian-Chef...
==> default: Auto-generating node name for Chef...
==> default: Starting the machine...
==> default: Waiting for the machine to report its IP address...
default: Timeout: 120 seconds
default: IP: fe80::215:5dff:fe02:f5a
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: fe80::215:5dff:fe02:f5a:22
default: SSH username: vagrant
default: SSH auth method: private key
... Eventually times out here ....
I used the following commands to set up a NATed switch:
New-VMSwitch –SwitchName “NATSwitch” –SwitchType Internal
New-NetIPAddress –IPAddress 172.21.21.1 -PrefixLength 24 -InterfaceAlias "vEthernet (NATSwitch)"
New-NetNat –Name MyNATnetwork –InternalIPInterfaceAddressPrefix 172.21.21.0/24
Interestingly everything works the first time I set up the VM switch and I get a valid IPV4 address and things are okay. But after I reboot the virtual machines will only ever get IPV6 addresses and I cant access existing ones created before the reboot.
My vagrant file:
Vagrant.configure("2") do |config|
config.vm.provider "hyperv"
config.vm.box = "maxx/ubuntu16"
config.vm.boot_timeout = 2000
config.vm.network "private_network", ip: "172.21.21.2"
... general config omitted.
end
I have tried both DHCP and static and both seem to fail. With static IP seemingly ignored completely.
Any ideas what I'm missing or doing wrong? (I am using a wifi connection if that is relevant)
I found a way around it by using internet connection sharing between my wifi and the virtual hyper v network. But currently, there is a bug in windows build 1607 where internet connection sharing needs to be restarted after every reboot.
A large thread here on the MS forums:
https://answers.microsoft.com/en-us/windows/forum/windows_10-networking/ics-internet-connection-sharing-dosent-work-in/a203c90f-1214-4e5e-ae90-9832ae5ceb55
Recently, my work laptop died, and I'm trying to get my project setup on a different laptop that was in my garage. My project lives inside of a trusty64 Ubuntu vagrant box using Oracle's Virtualbox software. However, I'm running into a bunch of issues trying to get the vagrant setup to work on this laptop. I also have the project running on my home desktop, and it all works there just fine.
This laptop is a Gateway NE56R12u from 2012 with 8 GB of RAM. It has a 64-bit dual-core processor running Windows 10 Professional (I installed Ubuntu 16.04 on this laptop as well doing a dual-boot, it is having the same exact errors using the Ubuntu operating system as it is having using Windows 10) My home desktop (that everything works on just fine) is also Windows 10 Professional. I'm using Vagrant 2.0.0 and VirtualBox 5.1.28 on both Windows 10 machines. They are booting the same project on the same branch.
When looking at the Virtualbox GUI on the laptop, it is only showing 32-bit options for boxes, which seems to be due to a lack of available hardware acceleration (I did not find any acceleration options in the BIOS). The Virtualbox GUI throws an error that says due to missing acceleration properties, the box will not be able to detect that I have a 64-bit processor. The acceleration tab is inaccessible. So I've switched to trying to use a 32-bit 'trusty' box.
However, I am still having problems and am unable to use a virtual machine. The problems appear to be with network connections and connecting to my filesystem.
When I type in vagrant up it starts normally:
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'ubuntu/trusty32'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'ubuntu/trusty32' is up to date...
==> default: Setting the name of the VM: directoryName_default_1509067920271_59622
==> 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 (guest) => 3000 (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
but then hangs there until time-out.
going into the Virtualbox GUI and watching the device boot, I watch it hang here:
waiting 10 seconds for network device
waiting 120 seconds for network device
then it says it gave up waiting for network device and continues. Eventually, it gets and hangs here:
Waiting for network configuration...
Waiting up to 60 more seconds for network configuration...
Booting system without full network configuration
then it quickly finishes booting and switches to a Vagrant login screen where I can successfully log in. When logged in, there are no files from my filesystem present. The command line where I started the boot process still has not changed at this point. It waits for the full time-out from the Vagrantfile and then throws the error that it timed out. I am not able to ssh in.
What I've done so far:
I have checked that the network adapter for the virtual machine is enabled. I have PAE set to on in my Vagrantfile because otherwise it is automatically set to off and throws a fatal error during boot (I tried turning pae, hwvirtex, vtxvpid, and vtxux all to off in my Vagrantfile). I made sure it only has one processor set. I have tried every network adapter setting available within the Virtualbox settings and there is no change. I have run bcdedit /set hypervisorlaunchtype off as an administrator on the command line. I've destroyed the .vagrant.d file folder, the .VirtualBox folder, and the VirtualBoxVMs folders from ~/user. I've tried different networking options such as public network and a private network with the local ip address.
Note: after running bcdedit /set hypervisorlaunchtype off my virtual machines no longer show in the Virtualbox GUI. However, the first time I deleted the .folder's after running that command, my machine successfully booted the box for the first time and everything was working correctly with it. However, the next day when I used vagrant up from the halted machine, it no longer worked again. Sometimes, instead of timing out, Vagrant gives the error that the machine went into the invalid state of 'unknown' state or 'paused' state. This behavior, however, is not consistent.
I've also re-installed Virtualbox and Vagrant, tried Virtualbox version 5.1.30 and version 5.2 (which I immediately learned is not compatible with Vagrant, which is interesting). At one point, upon a fresh install of Virtualbox it worked once and then it was immediately broken again after halting. Reinstalling again does not make it work. I tried using the hashicorp/precise32 box, and while that is created, boots, and is ssh accessible with access to my filesystem it does not seem to support node or versions of npm after version 1.1.14 and npm install fails. The ubuntu/xenial32 box always has a stderr while trying to boot on the command line. I can not get the logs because the VMs themselves do not show up in the Virtualbox GUI. I ran bcdedit /set hypervisorlaunchtype auto as having it set to off did not help solve my problem, but the Virtualbox GUI still does not show my VMs. Having vb.gui set to true in the Vagrantfile does not change this and the GUI does not show.
This is an error message I've gotten from the Virtualbox GUI many, many times:
The VM session was aborted.
Result Code: E_FAIL (0x80004005)
Component: SessionMachine
Interface: ISession {7844aa05-b02e-4cdd-a04f-ade4a762e6b7}
My Vagrantfile:
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/trusty32"
config.vm.network "forwarded_port", guest: 3000, host: 3000
config.vm.boot_timeout = 500
config.vm.provider "virtualbox" do |vb|
vb.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"]
vb.customize ["modifyvm", :id, "--pae", "on"]
end
config.vm.provision :shell, :path => "scripts/init_environment.sh"
end
I don't know what's wrong. It's technically worked twice, so I feel there must be a software and not a hardware problem? I can get a different box to work fine on this computer, but that box doesn't work for my project. This project has been setup on 3 other computers successfully with 0 issues (2 of them Windows 10, one Mac OSX), though none of those machines required a 32-bit box. Any ideas are greatly appreciated, I just need this to work so I can work on the go! Many of my errors are not consistent. The next thing I'm thinking about trying is taking out the Ubuntu dual-boot...
Edit:
I will also note that I put vb.memory = "1024" into my Vagrantfile and the Virtualbox still uses 512 MB of base memory according to Virtualbox. Also, I got the VM's to show in the Virtualbox software again, and grabbed a logfile .
The issue for me seemed to be that the virtual machine had shut down previously with some orphaned child nodes (I have no idea what that means). But, I did find this article explaining how to save a broken system and reboot from disc (which the article explains where you can download this).
https://superuser.com/questions/947942/unprocessed-orphan-inode-list-in-virtualbox-vm
I'm creating a vagrant base box of windows server 2012, and i want to share it internally for which i'm using Vagrant http share with below command
vagrant share --http 80
C:\Isentia\Vagrant>vagrant share --http 80
==> dev: Detecting network information for machine...
dev: Local machine address: 169.254.202.14
dev: Local HTTP port: 80
dev: Local HTTPS port: disabled
==> dev: Checking authentication and authorization...
==> dev: Creating Vagrant Share session...
dev: Share will be at: caring-dragon-2751
==> dev: Your Vagrant Share is running! Name: caring-dragon-2751
==> dev: URL: http://caring-dragon-2751.vagrantshare.com
and accessing the box with vagrant up in another machine
C:\Isentia\DevVM>vagrant init http://caring-dragon-2751.vagrantshare.com:80
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.
C:\Isentia\DevVM>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'http://caring-dragon-2751.vagrantshare.com:80' could not be fo
und. Attempting to find and install...
default: Box Provider: virtualbox
default: Box Version: >= 0
==> default: Box file was not detected as metadata. Adding it directly...
==> default: Adding box 'http://caring-dragon-2751.vagrantshare.com:80' (v0) for
provider: virtualbox
default: Downloading: http://caring-dragon-2751.vagrantshare.com:80
default: Progress: 0% (Rate: 0curl:/s, Estimated time remaining: --:--:--)
An error occurred while downloading the remote file. The error
message, if any, is reproduced below. Please fix this error and try
again.
The requested URL returned error: 500 Internal Server Error
below is the vagrant file content
Vagrant.configure(2) do |config|
config.vm.box = "BuzzNumberDevBox"
config.vm.guest = :windows
config.vm.communicator = "winrm"
config.vm.boot_timeout = 600
config.vm.graceful_halt_timeout = 600
# Admin user name and password
config.winrm.username = "vagrant"
config.winrm.password = "vagrant"
config.vm.define "dev" do |dev|
dev.vm.network "private_network", ip: "192.168.100.10"
dev.vm.host_name = "vagranttests.dev"
dev.vm.network :forwarded_port, guest: 5985, host: 5985, id: "winrm", auto_correct: true
end
config.vm.provider :virtualbox do |vb|
# Customize the name of VM in VirtualBox manager UI:
vb.name = "BuzzNumber-Dev-VM-Web"
end
end
what i do not understand is what could be stopping it from being accessible from any machine. The documentation asked to use the link directly.
Vagrant share is designed for sharing access to an application hosted on a VM, NOT for sharing the actual VM. If you want to share the VM itself you need to run vagrant package to pack it, and then put it on a web server with a metadata.json or at a URL where the other user can add it directly. Can you clarify if you want to copy this box to another machine or simply access a service running on the initial vagrant box?
I've a network issue with a centos7 vagrant box.
When I setup a private network, with fixed IP, this one is well binding first, but get lost after some seconds/minutes.
vagrant up
==> default: Forcing shutdown of VM...
==> default: Destroying VM and associated drives...
==> default: Running cleanup tasks for 'shell' provisioner...
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'sfeirbenelux/centos7'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'sfeirbenelux/centos7' is up to date...
==> default: Setting the name of the VM: poc_docker
==> default: Fixed port collision for 22 => 2222. Now on port 2200.
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
==> default: Forwarding ports...
default: 22 => 2200 (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:2200
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection timeout. 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 its present...
default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> 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: 5.0.2
default: VirtualBox Version: 4.3
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Running provisioner: shell...
default: Running: inline script
==> default: net.ipv4.ip_forward = 1
==> default: Setting up swapspace version 1, size = 2097148 KiB
==> default: no label, UUID=170723d8-1782-4915-a877-4d9874ac7396
➜ install git:(master) ✗ ping 192.168.100.20
PING 192.168.100.20 (192.168.100.20): 56 data bytes
64 bytes from 192.168.100.20: icmp_seq=0 ttl=64 time=0.390 ms
64 bytes from 192.168.100.20: icmp_seq=1 ttl=64 time=0.252 ms
64 bytes from 192.168.100.20: icmp_seq=2 ttl=64 time=0.461 ms
^C
--- 192.168.100.20 ping statistics ---
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.252/0.368/0.461/0.087 ms
➜ install git:(master) ✗ ping 192.168.100.20
PING 192.168.100.20 (192.168.100.20): 56 data bytes
64 bytes from 192.168.100.20: icmp_seq=0 ttl=64 time=0.273 ms
Request timeout for icmp_seq 1
Request timeout for icmp_seq 2
Request timeout for icmp_seq 3
Request timeout for icmp_seq 4
With this vagrant file :
vagrant.configure(2) do |config|
config.vm.box = "centos7"
config.vm.hostname = "docker-registry"
config.vm.box_url = "https://github.com/holms/vagrant-centos7-box/releases/download/7.1.1503.001/CentOS-7.1.1503-x86_64-netboot.box"
#config.vm.network "public_network"
config.vm.network "private_network", ip: "192.168.100.20"
#config.vm.synced_folder ".", "/vagrant", type: "nfs"
# VirtualBox
config.vm.provider :virtualbox do |vb|
vb.name = "poc_docker"
vb.memory = 3072
vb.cpus = 2
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
end
end
When I connect on the box, it seems that the ip is lost.
sudo /sbin/ifup eth1
Fix the problem temporary, but the IP get losts sometime again.
Rebooting the box (vagrant halt && vagrant up) seem to fix the problem permanently.
I've try to create a custom centos 7 box with Packer ( https://atlas.hashicorp.com/sfeirbenelux/boxes/centos7), and I reproduce the issue too.
I suppose that's a Centos 7 specific issue ?
Do you already have the same problem ? Is there a way to fix this by adding a vagrant command ?
My environment :
OS X Yosemite
➜ ~ vagrant --version
Vagrant 1.7.2
➜ ~ VBoxManage --version
4.3.26r98988
It seems that's a problem due to DHCP configuration ( issue : https://github.com/mitchellh/vagrant/issues/5590 )
the network service doesn't reload NetworkManager, so it will continue to wait for dhcp lease .. and after dhcp timeout, the fixed ip is removed.
Adding a shell provision script with
sudo nmcli connection reload
sudo systemctl restart network.service
Fixes the problem
EDIT:
vagrant 1.7.3+ fixes the bug too ;)
There seems to be a similar issue in newer Vagrant versions (1.9.1).
A pull request that fixes the issue was already merged (not released yet):
https://github.com/mitchellh/vagrant/pull/8148
If you want to apply that fix you can try this (sudo may be required, depending on the file permissions):
Locate you local Vagrant installation (on Fedora it is /opt/vagrant/)
Move to the folder of the vagrant gem:
cd embedded/gems/gems/vagrant-1.9.1
Initialize a new Git Repository and add the GitHub remote:
git init
git remote add origin https://github.com/mitchellh/vagrant.git
git fetch --all
Checkout a new branch and reset it to your current release (e.g. 1.9.1).
If you are unsure if you have local changes do not use --hard and do a git diff / git checkout after the reset:
git checkout -b hotfixes
git reset --hard v1.9.1
Now apply the hotfix:
git cherry-pick 96611341a96d7d19fdade5556a110b22c6add22b
After that a vagrant reload should bring up the local network just fine.
The fix is mentioned in: https://github.com/mitchellh/vagrant/pull/8148
In /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/plugins/guests/redhat/cap/configure_networks.rb,
add /sbin/ifup '#{network[:device]}' right after nmcli c reload || true.