Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Windows 10] - Vagrant seems to truncate host-only network name if it ends with #[num] causing virtualbox not to find it #8004

Closed
jasonwilliams opened this issue Nov 14, 2016 · 15 comments

Comments

@jasonwilliams
Copy link

jasonwilliams commented Nov 14, 2016

Please note that the Vagrant issue tracker is reserved for bug reports and
enhancements. For general usage questions, please use the Vagrant mailing list:
https://groups.google.com/forum/#!forum/vagrant-up. Thank you!

Vagrant version

Vagrant 1.8.7

Virtualbox Version

Version 5.1.8 r111374 (Qt5.5.1)

Host operating system

OS Name Microsoft Windows 10 Pro
Version 10.0.14393 Build 14393

Guest operating system

Centos 7

Vagrantfile

require 'base64'
require 'yaml'
require 'json'

Vagrant.require_version ">= 1.8.0"

Vagrant.configure("2") do |config|

  env_file = File.dirname(__FILE__) + "/env.json"
  if File.exists?(env_file)
    env = JSON.parse(IO.read(env_file))
  else
    env = {}
  end

  box_url = (env['centos_version'] == "centos6") ? "https://myshare.box.com/shared/static/s0jvhavqu7jqukn48jnqab40ed1ff4kn.box" : "https://myshare.box.com/shared/static/51hsyyeunsebzgejp5g4kfdxo9k4sx0p.box"
  ip_addr = (env['centos_version'] == "centos6") ? '192.168.193.10' : '192.168.193.22'
  hostname = (env['centos_version'] == "centos6") ? 'sandbox.foo.co.uk' : 'cloud7.sandbox.foo.co.uk'

  config.vm.box       = (env['centos_version'] == "centos6") ? "centos6-sandbox" : "centos7-sandbox" 
  config.ssh.username = "developer"
  config.ssh.host = hostname
  config.ssh.port = 22
  config.ssh.forward_agent = true
  config.vm.network :forwarded_port, guest: 22, host: 2223, id: "ssh", disabled: "true"
  config.vm.network "private_network", ip: ip_addr, name: 'VirtualBox Host-Only Ethernet Adapter #7', adapter: 1

  config.vm.box_url   = box_url
  config.vm.box_download_insecure = true

  #cert in pem format
  if ENV['cert_path'] || env['cert_path']
    cert = ENV['cert_path'] || env['cert_path']
    config.vm.box_download_client_cert = "#{cert}"
    #puts "#{cert}:#{pw}"
    env['certificate'] = {
      "file" => Base64.encode64(IO.read(cert))
    }
  end

  workspace = "~/workspace"

  if ENV['workspace'] || env['workspace']
    workspace = ENV['workspace'] || env['workspace']
  end

  config.vm.synced_folder workspace, "/mnt/hgfs/workspace", :mount_options => ["dmode=777", "fmode=666"]



  # config.vm.provision "shell", inline: "sudo -u developer -H -i /usr/sbin/reithproxies $1", args: reithproxies
  config.vm.provision "file", source: "repos/", destination: "/tmp/"
  config.vm.provision "file", source: "configFiles/", destination: "/tmp/"
  # file provisioner doesn't have access to /etc but shell does
  config.vm.provision "shell", inline: "mv /tmp/repos/*.repo /etc/yum.repos.d/"
  config.vm.provision "shell", path: "guest_setup_script.py", args: [env['cert_path']]


  config.vm.provider :virtualbox do |vb|
    vb.name = (env['centos_version'] == "centos6") ? "CentOS-6-Sandbox" : "CentOS-7-Sandbox"
    vb.customize ["modifyvm", :id, "--usbehci", "off"]
  end
end

Please note, if you are using Homestead or a different Vagrantfile format, we
may be unable to assist with your issue. Try to reproduce the issue using a
vanilla Vagrantfile first.

Debug output

https://gist.github.com/Jayflux/6ff1aa5b2b48fb97f65f4e85f8d94d66

Expected behavior

Vagrant/virtualbox should be using the host-only name i set in the vagrantfile.

Actual behavior

Virtualbox seems to be looking for "VirtualBox Host-Only Ethernet Adapter" instead of "VirtualBox Host-Only Ethernet Adapter #7" unfortunately i cannot rename the adapters on windows.
If i remove the # then it searches for "VirtualBox Host-Only Ethernet Adapter 7" (which still does not exist), it looks like the pound sign is causing some truncation

Screenshot

host-only-7

@kikitux
Copy link
Contributor

kikitux commented Nov 25, 2016

The screenshot shows is all good ?

@jasonwilliams
Copy link
Author

jasonwilliams commented Nov 26, 2016

@kikitux see https://gist.github.com/Jayflux/6ff1aa5b2b48fb97f65f4e85f8d94d66#file-gistfile1-txt-L3441
https://gist.github.com/Jayflux/6ff1aa5b2b48fb97f65f4e85f8d94d66#file-gistfile1-txt-L3449

from the gist i posted

The setup (screenshot) is fine, but the CLI is showing vagrant is cutting off the #7

@kenfusion
Copy link

Have you tried to escape the '#'?
Something like:
name: 'VirtualBox Host-Only Ethernet Adapter \#7'

@jasonwilliams
Copy link
Author

@kenfusion yup! had no luck at all!
I've tried VirtualBox Host-Only Ethernet Adapter \#7 and had the same issue.

@jasonwilliams
Copy link
Author

If it helps you guys, [kind of related], i've noticed that Virtualbox doesn't clean up old Host-only interfaces. So its impossible for me to go back to VirtualBox Host-Only Ethernet Adapter even if i uninstall Virtualbox and reinstall it, it will start my first Host-Only network interface at VirtualBox Host-Only Ethernet Adapter #7

@jasonwilliams
Copy link
Author

jasonwilliams commented Mar 6, 2017

@kenfusion @kikitux @chrisroberts any idea?

@chrisroberts
Copy link
Member

@Jayflux Hi! Can you try this setup on the recent release of both Vagrant and VirtualBox? I attempted to replicate the behavior but I see the correct name being used within the VMs settings. If it's still not working, please let me know. Thanks!

win10-vbox

@jasonwilliams
Copy link
Author

jasonwilliams commented Apr 20, 2017

@chrisroberts thanks for replying!
sure will try when i get back home.
btw the problem here isn't with Virtualbox, its vagrant failing to start up if the Network Adapter has a # in the name. The # gets truncated, so vagrant ends up looking for 'VirtualBox Host-Only Ethernet Adapter' instead of 'VirtualBox Host-Only Ethernet Adapter #2'

Whats doubly annoying is VirtualBox doesn't allow me to change the host-only adapter name on windows :(

Will have a try

@chrisroberts
Copy link
Member

@Jayflux You bet. The VM in the image above was created with Vagrant and properly setup without truncating the name (at least on my machine). Hopefully it will do the same for you, but please do reply back either way. Cheers!

@jasonwilliams
Copy link
Author

@chrisroberts in the meantime, could you share with me the Vagrantfile you used, version of Windows and version of Vagrant / VirtualBox ?

@chrisroberts
Copy link
Member

@Jayflux Sure: win10-15063 / vagrant 1.9.4.pre (build off master) / vbox 5.1.18

@jasonwilliams
Copy link
Author

jasonwilliams commented Apr 21, 2017

@chrisroberts still not working for me

λ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: hostonly
==> default: Forwarding ports...
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.

Command: ["startvm", "ba615f69-6e47-476b-ac2a-a871259dc074", "--type", "headless"]

Stderr: VBoxManage.exe: error: Interface ('VirtualBox Host-Only Ethernet Adapter') is not a Host-Only Adapter interface (VERR_INTERNAL_ERROR)
VBoxManage.exe: error: Details: code E_FAIL (0x80004005), component ConsoleWrap, interface IConsole

host-only

This is something that used to work, so there's been a regression somewhere, just working out what.
im on #vagrant if that helps

Vagrant 1.9.3
Virtualbox 5.1.20

@chrisroberts
Copy link
Member

Closing this up as it turned out to be an issue with the box. Cheers!

@jasonwilliams
Copy link
Author

hey @chrisroberts, I know this ticket is closed, but i found out the problem.
I was poking around in C:\Users\Jason\.vagrant.d\boxes\centos7-sandbox\0\virtualbox\include and i found this

if Gem.win_platform?
  VBOX_ADAPTER = 'VirtualBox Host-Only Ethernet Adapter'
  VBOXMANAGE_COMMAND = 'C:/Program Files/Oracle/VirtualBox/VBoxManage.exe'
  WORKSPACE = ('//?/' + ENV['HOME'] + '/workspace').gsub('/', "\\")
else
  VBOX_ADAPTER = 'vboxnet0'
  VBOXMANAGE_COMMAND = 'VBoxManage'
  WORKSPACE = ENV['HOME'] + '/workspace'
end

I'm guessing whoever made this .box hardcoded it to VirtualBox Host-Only Ethernet Adapter, i don't really know how the whole box thing works, but this here is a base Vagrantfile? Anyway, don't know why mine wasn't overriding it.

I changed it to VBOX_ADAPTER = 'VirtualBox Host-Only Ethernet Adapter #7' and i works

@ghost
Copy link

ghost commented Apr 2, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants