Vagrant + Hyper V IPV6 addresses Assigned - vagrant

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

Related

how to solve this SMB share folder when vagrant sync folder fail in this case?

I have a vagrant in my Win10 PC.
Vagrant.configure("2") do |config|
config.vm.box = "generic/centos7"
config.vm.synced_folder "D:/Users/88888888/vagrant_proj/vagrant_data", "/vagrant_data"
config.vm.network "private_network", ip: "172.22.244.28"
end
When I vagrant up my vm, I get below error when sync folder:
MINGW64 ~/vagrant_proj/vagrant_vm/vmware_desktop_centos7
$ vagrant up
Bringing machine 'default' up with 'hyperv' provider...
==> default: Verifying Hyper-V is enabled...
==> default: Verifying Hyper-V is accessible...
default: Configuring the VM...
default: Setting VM Enhanced session transport type to disabled/default (VMBus)
Vagrant requires administrator access for pruning SMB shares and
may request access to complete removal of stale shares.
==> default: Starting the machine...
==> default: Waiting for the machine to report its IP address...
default: Timeout: 120 seconds
default: IP: 172.22.244.28
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 172.22.244.28:22
default: SSH username: vagrant
default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Preparing SMB shared folders...
default: You will be asked for the username and password to use for the SMB
default: folders shortly. Please use the proper username/password of your
default: account.
default:
default: Username (user[#domain]): ABC\88888888
default: Password (will be hidden):
Error! Your console doesn't support hiding input. We'll ask for
input again below, but we WILL NOT be able to hide input. If this
is a problem for you, ctrl-C to exit and fix your stdin.
default: Password (will be hidden): Aircraft04!
Vagrant requires administrator access to create SMB shares and
may request access to complete setup of configured shares.
==> default: Mounting SMB shared folders...
default: D:/Users/88888888/vagrant_proj/vagrant_data => /vagrant_data
Failed to mount folders in Linux guest. This is usually because
the "vboxsf" file system is not available. Please verify that
the guest additions are properly installed in the guest and
can work properly. The command attempted was:
mount -t cifs -o vers=2.0,credentials=/etc/smb_creds_vgt-2d3036366c24d0c86eee3d4f63f20f4f-adda498f781708cde2d8e46c475e9593,uid=1000,gid=1000,mfsymlinks,_netdev,nofail //10.0.129.112/vgt-2d3036366c24d0c86eee3d4f63f20f4f-adda498f781708cde2d8e46c475e9593 /vagrant_data
The error output from the last command was:
mount error(5): Input/output error
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
how to solve this SMB share folder?
the version is below:
$ vagrant.exe --version
Vagrant 2.2.19
and I use the vagrant HyperV provider.

Chef Kitchen Vagrant box will not start when adding additional disks

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.

No Intel® Virtualization Technology (VT-x): Vagrant stumbles even with 32-bit images

CPU: Intel® Core™2 Quad CPU Q8200 # 2.33GHz × 4
Host OS: Ubuntu 16.04.2 64-bit
Vagrant: 1.9.7
Virtualbox: 5.1.24
I do:
$ vagrant init precise64 http://files.vagrantup.com/xenial32.box
...
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set forwarded ports...
==> 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: 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.
Well, I tried xenial64.box as well. And precise32.
Here is some discussion "vagrant up" it stops at SSH auth method: private key
This seems to connected somehow with Intel Virtualization Technology.
Well, this CPU doesn't support it.
I will be satisfied with a 32 bit virtual machine. But how can I organize it? Well, I'd like just to start it. With or without SSH, or something. But just start.
Could you give me a kick here?

Vagrant windows on windows config.vm.boot_timeout not applied

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

Centos7 with private network lost fixed IP

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.

Resources