hashicorp / vagrant

Vagrant is a tool for building and distributing development environments.
https://www.vagrantup.com
Other
26.23k stars 4.43k forks source link

IPv6 assignment fails on Redhat guests, network_static66.erb not found #13226

Open lordgurke opened 1 year ago

lordgurke commented 1 year ago

Static IPv6 assignment to Vagrant boxes fails, because a "helper" is called, which does not exist by that name. This is likely a typo in the code, as network_static66.erb does not exist, but network_static6.erb does (and works).

Debug output

$ vagrant up web
Bringing machine 'web' up with 'virtualbox' provider...
....
==> web: Machine booted and ready!
==> web: Checking for guest additions in VM...
==> web: Configuring and enabling network interfaces...
/opt/vagrant/embedded/gems/gems/vagrant-2.3.6/lib/vagrant/util/template_renderer.rb:61:in `initialize': 
No such file or directory @ rb_sysopen - /opt/vagrant/embedded/gems/gems/vagrant-2.3.6/templates/guests/redhat/network_static66.erb (Errno::ENOENT)
from /opt/vagrant/embedded/gems/gems/vagrant-2.3.6/lib/vagrant/util/template_renderer.rb:61:in `open'
from /opt/vagrant/embedded/gems/gems/vagrant-2.3.6/lib/vagrant/util/template_renderer.rb:61:in `render'
from /opt/vagrant/embedded/gems/gems/vagrant-2.3.6/lib/vagrant/util/template_renderer.rb:36:in `render_with'
from /opt/vagrant/embedded/gems/gems/vagrant-2.3.6/lib/vagrant/util/template_renderer.rb:18:in `render'

Expected behavior

Static IPv6 address defined in Vagrantfile using web.vm.network "private_network", ip: "a:b:c:d" should be assigned on startup.

Actual behavior

Box starts, then when configuration of the network starts, it fails with a looooong backtrace and error message:

/opt/vagrant/embedded/gems/gems/vagrant-2.3.6/lib/vagrant/util/template_renderer.rb:61:in `initialize': No such file or directory @ rb_sysopen - /opt/vagrant/embedded/gems/gems/vagrant-2.3.6/templates/guests/redhat/network_static66.erb (Errno::ENOENT)

Reproduction information

Vagrant version

Vagrant 2.3.6

Host operating system

Arch Linux, Kernel 6.4.1-arch2-1

Guest operating system

CentOS 7

Steps to reproduce

  1. Configure static IPv6 assignment in Vagrantfile using web.vm.network "private_network", ip: "a:b:c:d"
  2. vagrant up the box

Vagrantfile

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

  config.vm.define "web", primary: true do |web|
    web.vm.box = "https://...../Centos7WebFPM"
    web.vm.network "private_network", ip: "172.17.0.101"
    web.vm.network "private_network", ip: "a:b:c:d:e:1"

end
polieter commented 1 year ago

Hi, I encounter the same situation with:

testVM: Setting hostname...
==> testVM: Configuring and enabling network interfaces...
==> testVM: Attempting graceful shutdown of VM...
==> testVM: Destroying VM and associated drives...
/opt/vagrant/embedded/gems/gems/vagrant-2.3.7/lib/vagrant/util/template_renderer.rb:61:in `initialize': No such file or directory @ rb_sysopen - /opt/vagrant/embedded/gems/gems/vagrant-2.3.7/templates/guests/gentoo/network_static66.erb (Errno::ENOENT)

The same reproduction steps as in @lordgurke case

youtous commented 1 year ago

Same issue with a debian12 VM (host on Arch Kernel: x86_64 Linux 6.4.7-arch1-1) (a quick & dirty workaround is to create a symbolic link : ╰─λ sudo ln -s /opt/vagrant/embedded/gems/gems/vagrant-2.3.6/templates/guests/debian/network_static6.erb /opt/vagrant/embedded/gems/gems/vagrant-2.3.6/templates/guests/debian/network_static66.erb)

lordgurke commented 1 year ago

This very likely broke with pull https://github.com/hashicorp/vagrant/pull/13024 as now the network config type is defined in the call function, but the existing code in hostonly_config remained in place, which now adds a second "6" to the network config type, thus leading to this problem.

I made a pull request to fix this bug in https://github.com/hashicorp/vagrant/pull/13241, in the meantime you may (or may not) want to do the following edit to your local installation to make IPv6 work again:
In /opt/vagrant/embedded/gems/gems/vagrant-2.3.6/plugins/providers/virtualbox/action/network.rb, Line 303 remove or comment out the line:

# Append a 6 to the end of the type
options[:type] = "#{options[:type]}6".to_sym