Vagrant 'pre-boot' VM customization error - vagrant

What is the cause of this particular error?
I have the latest version of VirtualBox (5.2.22-126460) and Vagrant (2.2.2).
Those are running on a freshly installed Windows 10 operating system.
Whenever I try to 'vagrant up' my machine I get this following output:
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set forwarded ports...
==> default: Vagrant has detected a configuration issue which exposes a
==> default: vulnerability with the installed version of VirtualBox. The
==> default: current guest is configured to use an E1000 NIC type for a
==> default: network adapter which is vulnerable in this version of VirtualBox.
==> default: Ensure the guest is trusted to use this configuration or update
==> default: the NIC type using one of the methods below:
==> default:
==> default: https://www.vagrantup.com/docs/virtualbox/configuration.html#default-nic-type
==> default: https://www.vagrantup.com/docs/virtualbox/networking.html#virtualbox-nic-type
==> 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: 1080 (guest) => 1080 (host) (adapter 1)
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
A customization command failed:
["modifyvm", :id, "--cableconnected0", "on"]
The following error was experienced:
#<Vagrant::Errors::VBoxManageError: There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.
Command: ["modifyvm", "22fda01f-9b13-43f9-bf0d-4deb81c688c8", "--cableconnected0", "on"]
Stderr: VBoxManage.exe: error: Invalid NIC number 0
>
Please fix this customization and try again.
Vagrantfile:
Vagrant.configure("2") do |config|
config.vm.box = "local.1400degrees.com"
config.vm.hostname = "local.website.com"
config.vm.synced_folder ".", "/vagrant", :mount_options => ["dmode=777,fmode=777"]
config.vm.network "forwarded_port", guest: 1080, host: 1080
config.vm.network "private_network", ip: "192.168.33.13"
config.hostmanager.enabled = true
config.hostmanager.manage_host = true
config.ssh.username = 'vagrant'
config.ssh.password = 'vagrant'
config.ssh.insert_key = false
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--cableconnected1", "on"]
end
end

Per this github issue a solution can be to
1.first of all destroy the virtual box with vagrant destroy
2.navigate to C:\Users\YOUR_USERNAME
3.delete the .vagrant.d folder
4.go into VirtualBox VMs folder and delete everything inside it.
5.start it again with vagrant up
You can get more in depth logs by using vagrant up --debug or if you would like to save it to a file vagrant up --debug &> vagrant.log. Also, a great thing about this is you can always tear it down and start over :)

I believe the real reason this is happening is due to this: https://github.com/hashicorp/vagrant/issues/10481
The fix was already merged to the vagrant master branch, however it will probably be included in version 2.2.5 or later. Latest vagrant version as of writing this up is 2.2.4 and the bug is still present.
The fix that was done:
In plugins/providers/virtualbox/action/set_default_nic_type.rb
They changed the code from E1000_SUSCEPTIBLE = Gem::Requirement.new("<= 5.2.22").freeze to E1000_SUSCEPTIBLE = Gem::Requirement.new("< 5.2.22").freeze

Related

After PC restarted the vagrant machine fails to starts. It shows port collision

UPDATE: After host PC reboot vagrant up shows port collision on any port
My vagrant machine fails to start.
Usually it was working normally, but today after I restarted my PC the vagrant machine no more starts.
I did not change the Vagrantfile.
It says about ports collision.
If I remove the 6379 setting for redis, then it says for port 1080 and so on.
Like all ports have the collision.
If I try to run the macine via VMware - then it starts OK, but I cannont connect to it via ssh, because it doesn't have the settings that are defined in Vagrantfile...
Here is the log:
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'ubuntu/trusty64' is up to date...
==> default: There was a problem while downloading the metadata for your box
==> default: to check for updates. This is not an error, since it is usually due
==> default: to temporary network problems. This is just a warning. The problem
==> default: encountered was:
==> default:
==> default: The requested URL returned error: 404
==> default:
==> default: If you want to check for box updates, verify your network connectio n
==> default: is valid and try again.
==> default: Fixed port collision for 6379 => 6379. Now on port 2250.
Vagrant found a port collision for the specified port and virtual machine.
While this port was marked to be auto-corrected, the ports in the
auto-correction range are all also used.
VM: default
Forwarded port: 1080 => 1080
Here is my Vagrantfile:
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/trusty64"
forward_port = ->(guest, host = guest) do
config.vm.network :forwarded_port,
guest: guest,
host: host,
auto_correct: true
end
config.vm.synced_folder "sites/", "/var/www"
config.vm.synced_folder ".", "/vagrant", disabled: true
forward_port[6379] # redis
forward_port[1080] # mailcatcher
forward_port[3306] # mysql
forward_port[80, 8080] # nginx/apache
config.vm.provision :puppet do |puppet|
puppet.manifests_path = "manifests"
puppet.manifest_file = "default.pp"
end
config.vm.network :private_network, ip: "33.33.33.10"
config.ssh.username = "vagrant"
config.ssh.password = "vagrant"
end

Configuration issue with OpenShift3 origin/all-in-one, vagrant Cluster setup

I am facing issue to see login page at
https://10.2.2.2:8443/console
,
even when I trying to do
"oc login https://10.2.2.2"
It worked for the first installation and I was able to login, but I had no luck when I did few re-installations to customize.
I have already gone throgh existing github vagrant issues, and stackoverflow as well but no clues for this issue.
I appreciate if someone can help me with this issue.
Installations Detals:
I've followed this blog for cluster setup in my mac ,
1) Installed VirtualBox Version 5.1.14 r112924 (Qt5.6.2)
2) Installed Vagrant 1.9.1
Here is my Vagrantfile config,
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.require_version ">= 1.7.2"
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version. Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
config.vm.box = "openshift/origin-all-in-one"
# uncomment this line if you downloaded the box and want to use it instead
# config.vm.box = "openshift3"
config.vm.box_check_update = false
config.vm.network "private_network", ip: "10.2.2.2"
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.hostname = "origin"
# 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: 80, host: 8080
# config.vm.network "forwarded_port", guest: 80, host: 1080
# config.vm.network "forwarded_port", guest: 443, host: 1443
# config.vm.network "forwarded_port", guest: 5000, host: 5000
# config.vm.network "forwarded_port", guest: 8080, host: 8080
# config.vm.network "forwarded_port", guest: 8443, host: 8443
config.vm.provider "virtualbox" do |vb|
# vb.gui = true
vb.memory = "4096"
vb.cpus = 2
vb.name = "origin-1.3.0"
end
end
This is my debug logs for Vagrant up --debug
Last login: Wed Feb 1 13:59:59 on ttys000
xxxxxs-MBP:origin xxxxx$ vagrant init openshift/origin-all-in-one
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.
xxxxxs-MBP:origin xxxxx$ vagrant up --provider=virtualbox
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'openshift/origin-all-in-one' could not be found. Attempting to find and install...
default: Box Provider: virtualbox
default: Box Version: >= 0
==> default: Loading metadata for box 'openshift/origin-all-in-one'
default: URL: https://atlas.hashicorp.com/openshift/origin-all-in-one
==> default: Adding box 'openshift/origin-all-in-one' (v1.3.0) for provider: virtualbox
default: Downloading: https://atlas.hashicorp.com/openshift/boxes/origin-all-in-one/versions/1.3.0/providers/virtualbox.box
==> default: Successfully added box 'openshift/origin-all-in-one' (v1.3.0) for 'virtualbox'!
/Users/xxxxx/.vagrant.d/boxes/openshift-VAGRANTSLASH-origin-all-in-one/1.3.0/virtualbox/include/_Vagrantfile:5: warning: already initialized constant VAGRANTFILE_API_VERSION
/Users/xxxxx/origin/Vagrantfile:5: warning: previous definition of VAGRANTFILE_API_VERSION was here
==> default: Importing base box 'openshift/origin-all-in-one'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: origin-1.3.0
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
default: Adapter 3: hostonly
==> default: Forwarding ports...
default: 8443 (guest) => 8443 (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
default: Warning: Remote connection disconnect. 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 it's present...
default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
default: No guest additions were detected on the base box for this VM! Guest
default: additions are required for forwarded ports, shared folders, host only
default: networking, and more. If SSH fails on this machine, please install
default: the guest additions and repackage the box to continue.
default:
default: This is not an error message; everything may continue to work properly,
default: in which case you may ignore this message.
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Running provisioner: shell...
default: Running: inline script
==> default:
==> default: Successfully started and provisioned VM with 2 cores and 5 G of memory.
openshift.service in vm is failing to start automatically,
I did ssh to machine and started manually with command sudo systemctl start origin and everything working perfect.
I had a bit of issue with Origin myself. I ended up using Docker and OpenShift Client. I have written down step by step on how to get started with OpenShift Origin on Windows. I am not trying to promote anything here. The entry is too long for me to cut and paste it. Please visit the link below:
http://blog.muralibala.com/2017/01/getting-started-with-openshift-origin-on-windows/
Hope this is helpful.

localhost Vagrant and VM on a windows (8.1) build - vagrant file specifications

Having a problem getting my localhost to work properly.
Running git bash I've successfully vagrant init "hashicorp/precise32"
vagrant up
Perhaps I'm putting my local host IP in the wrong place: 127.0.0.1
Confirmed my VM is running and here is my vagrant file:
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
Vagrant.configure(2) do |config|
config.vm.box = "hashicorp/precise32"
# config.vm.boot_timeout = "300"
# Setting this above never worked for me when i had a config.vm.boot_timeout
config.vm.network :forwarded_port, guest: 80, host: 8082
# config.vm.network :public_network
config.vm.network "private_network", ip: "127.0.0.1"
config.vm.synced_folder ".", "/vagrant", type: "nfs"
config.vm.provider :virtualbox do |vb|
vb.gui = true
# I turned this vb.gui = true on when i was having a problem with config.vm.boot_timeout
vb.customize ["modifyvm", :id, "--memory", "4096"]
vb.cpus = 4
end
end
I've added some additional options but I think my ip or ports are wrong. Any help would be greatly appreciated. Thank you.
edit ************************
Host file looks like so:
# Copyright (c) 1993-2006 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handle within DNS itself.
127.0.0.1 localhost
::1 localhost
After I vagrant reload:
$ vagrant reload
==> default: [vagrant-hostsupdater] Removing hosts
==> 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: Adapter 2: hostonly
==> default: Forwarding ports...
default: 80 (guest) => 8082 (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
==> default: Machine booted and ready!
[default] GuestAdditions 5.1.8 running --- OK.
==> default: Checking for guest additions in VM...
==> default: [vagrant-hostsupdater] Checking for host entries
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
default: /vagrant => C:/Users/Timothy/Documents/Magento
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.
Why is this so confusing right now, I've never had so much trouble setting up a local dev. environment.
you cannot use a private_network of 127.0.0.1 from your host thats your loopback adapter so it will never be able to reach your VM.
You should use on of the 3 following ranges (see https://en.wikipedia.org/wiki/Private_network#Private_IPv4_address_spaces)
10.0.0.0 - 10.255.255.255
172.16.0.0 - 172.31.255.255
192.168.0.0 - 192.168.255.255
vagrant will already create a NAT adapter on 10.0.2.15 to communicate over ssh.
I suggest to take an IP in the 192.168.x.x range and you will be able to work correctly with your VM

vagrant up fails for bento/ubuntu-16.04 on Oracle VirtualBox 5.0.16 r105871

Today I was planning to get the latest Ubuntu release into my virtual box using vagrant. After loading the image and running vagrant up, I got an error as reported below, which relates to the network configuration of the virtual box.
Interestingly, there are already some posts online (mainly on GitHub, e.g.: https://github.com/mitchellh/vagrant/issues/7155), but also on AskUbuntu (https://askubuntu.com/questions/760871/network-settings-fail-for-ubuntu-xenial64-vagrant-box), StackOverflow (vagrant up command giving error and eth1 not showing a resolvable ip address) and StackExchange (https://unix.stackexchange.com/questions/188413/not-able-to-resolve-ip-address-for-eth1-in-vagrant-vm). However these issues relate to either xenial64 (i.e. not bento) or use a public_network configuration.
As reported in https://askubuntu.com/questions/760871/network-settings-fail-for-ubuntu-xenial64-vagrant-box, this issue does not exist for ubuntu/trusty64 or ubuntu/wily64, but seems to be an issue for both ubuntu/xenial64 and bento/ubuntu-16.04 (i.e. both Ubuntu 16 boxes).
As you will see in my Vagrantfile below, I have a simple setup for bento/ubuntu-16.04 and use private_network only. To be clear, I can't really use this post (vagrant up command giving error and eth1 not showing a resolvable ip address) since it suggests to comment out the public_network part of the vagrant configuration. Also, I should mention that there are no other VM's running at the time this error occurs.
From the error log it seems obvious that there is an issue with the netowrk interface eth1, but what exactly the problem is, is unclear to me. I have previously successfully started the hashicorp/precise32 and ubuntu/trusty64 Ubuntu boxes with the same vagrant configuration and the same Oracle VB and have not encountered this problem.
Any help is appreciated. My technical setup and reference files are listed below.
Cheers
AHL
Setup:
Vagrant: v1.8.1
Oracle VirtualBox: v5.0.16 r105871
Ubuntu box: bento/ubuntu-16.04 (https://atlas.hashicorp.com/bento/boxes/ubuntu-16.04)
Host machine: Lenovo X1 Carbon, Windows 10
Vagrantfile:
Vagrant.configure(2) do |config|
config.vm.box = "bento/ubuntu-16.04"
config.vm.network "private_network", ip: "192.168.33.10"
end
Output:
C:\Users\AHL\workspace>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'bento/ubuntu-16.04' 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: Adapter 2: hostonly
==> default: Forwarding ports...
default: 22 (guest) => 2222 (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:2222
default: SSH username: vagrant
default: SSH auth method: private key
==> default: Machine booted and ready!
GuestAdditions 5.0.16 running --- OK.
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
/sbin/ifdown eth1 2> /dev/null
Stdout from the command:
Stderr from the command:
mesg: ttyname failed: Inappropriate ioctl for device
C:\Users\AHL\workspace>
I had the problem and found that for some reason, the virtual box did not connect the virtual cable to the network interface.
I solved it by adding
vb.customize ["modifyvm", :id, "--cableconnected1", "on"]
to my config.vm.provider "virtualbox" do |vb| loop, for example in my case I wanted 1GB RAM, USB3 and the network cable connected:
config.vm.provider "virtualbox" do |vb|
vb.memory = "1024"
vb.customize ["modifyvm", :id, "--usbxhci", "on"] # Connect USB3 disk
vb.customize ["modifyvm", :id, "--cableconnected1", "on"]
end
I did not need this --cableconnected1 line in any other boxes I have used, only in config.vm.box = "bento/ubuntu-16.04".
Maybe you have to check if doing vagrant updoes not connect any of your cables, I had also an extra network and eth0 was unwired and eth1 was wired.
Check your particular case. Maybe you have to play with the number after the option.
Hope this helps!
I think in your list, you need to add https://github.com/mitchellh/vagrant/issues/6871
The issue is still open - There are some users who reported they could fix the issue (https://github.com/mitchellh/vagrant/issues/6871#issuecomment-223290622 or https://github.com/mitchellh/vagrant/issues/6871#issuecomment-222348226)
If you can build your box yourself using packer, there are some fixes on the network issue.

How do I provision a Windows guest using the Vagrant shell/path provisioner?

I am trying to use Powershell to provision a Windows Vagrant machine. I've verified that my script works on my local machine if I launch Powershell as an Administrator. During the Vagrant provisioning process, the vagrant user cannot elevate and run the script.
I know powershell scripts are supported with Vagrant, so what needs to happen to use them for provisioning? My initial thought is try to have the script to launch an new Administrator Powershell, but I feel there must be a better way.
I'm trying to just download a file using System.Net.WebClient and using msiexec to install.
Vagrantfile:
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
PROVISION_WIN7_SCRIPT = "provision_win7.ps1"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.define "win7", primary: false do |win7|
config.vm.provision "shell", :path => "#{PROVISION_WIN7_SCRIPT}"
config.vm.box = "win7"
config.vm.hostname = "win7"
config.vm.communicator = "winrm"
config.vm.network :private_network, ip: "10.10.10.10"
config.vm.box_url = "https://atlas.hashicorp.com/designerror/boxes/windows-7/versions/1.0/providers/virtualbox.box"
config.vm.provider :virtualbox do |vb|
vb.gui = true
vb.customize ["modifyvm", :id, "--memory", 1024]
vb.customize ["modifyvm", :id, "--cpus", 1]
vb.customize ["modifyvm", :id, "--vram", "32"]
vb.customize ["modifyvm", :id, "--clipboard", "bidirectional"]
vb.customize ["setextradata", "global", "GUI/SuppressMessages", "all" ]
end
end
end
Edit:
I tried this again today using what I was running at the time: Vagrant 1.6.3, Virtualbox 4.3.30. When I bring up my vagrant box, I do not see any error output:
Bringing machine 'win7' up with 'virtualbox' provider...
==> win7: Importing base box 'designerror/windows-7'...
==> win7: Matching MAC address for NAT networking...
==> win7: Checking if box 'designerror/windows-7' is up to date...
==> win7: Setting the name of the VM: vagrant_win7_1453859492744_23074
==> win7: Clearing any previously set network interfaces...
==> win7: Preparing network interfaces based on configuration...
win7: Adapter 1: nat
win7: Adapter 2: hostonly
==> win7: Forwarding ports...
win7: 3389 => 3389 (adapter 1)
win7: 22 => 2222 (adapter 1)
win7: 5985 => 55985 (adapter 1)
==> win7: Running 'pre-boot' VM customizations...
==> win7: Booting VM...
==> win7: Waiting for machine to boot. This may take a few minutes...
==> win7: Machine booted and ready!
==> win7: Checking for guest additions in VM...
==> win7: Setting hostname...
==> win7: Configuring and enabling network interfaces...
==> win7: Mounting shared folders...
win7: /vagrant => /Users/dstark/Projects/itbestprac-pres/vagrant
==> win7: Running provisioner: shell...
win7: Running: c:\tmp\vagrant-shell.ps1
On my vagrant box under c:\tmp there's a vagrant-shell.ps1 and vagrant-elevated-shell.ps1 and if I manually execute the vagrant generated elevated shell ps script as the vagrant user it installs. So, I think my script is ok.
If I add the config.winrm.username and config.winrm.password I still am not able to elevate permissions necessary to run the script. There's also nothing telling in the Event Viewer.
Possibly you need to add the privileged flag to the provision line:
config.vm.provision "shell", path: "scripts/provision.ps1", privileged: true
Or in your case:
config.vm.provision "shell", :path => "#{PROVISION_WIN7_SCRIPT}", privileged: true

Resources