Skip to content

need to set default nic type via Vagrantfile for virttualbox #390

@oss-chapman

Description

@oss-chapman

Description

(patch to fix this is included in ticket)
When booting a kitchen created virtualbox, one receives the following message:

Vagrant has detected a configuration issue which exposes a
vulnerability with the installed version of VirtualBox. The
current guest is configured to use an E1000 NIC type for a
network adapter which is vulnerable in this version of VirtualBox.
Ensure the guest is trusted to use this configuration or update
the NIC type using one of the methods below:
https://www.vagrantup.com/docs/virtualbox/configuration.html#default-nic-type
https://www.vagrantup.com/docs/virtualbox/networking.html#virtualbox-nic-type
To correct it we need to be able to pass "default_nic_type" to vagrant itself.
The current test kitchen-vagrant driver does not allow for this option to be passed.

The bug is described here and other places: geerlingguy/drupal-vm#1869

Kitchen Version

1.24.0

Vagrant Version

2.2.3

virtualbox Version

5.2.18_Ubuntur123745

Config file sample (doesn't actually work):

---
driver:
  name: vagrant
  customize:
    default_nic_type: "virtio"

Patch to fix this issue:

mchapman@debian:~/pub/kitchen-vagrant$ git diff 1cad7a7
diff --git a/templates/Vagrantfile.erb b/templates/Vagrantfile.erb
index bf6154a..efb7db9 100644
--- a/templates/Vagrantfile.erb
+++ b/templates/Vagrantfile.erb
@@ -190,6 +190,8 @@ Vagrant.configure("2") do |c|
            ids << "\"#{id}\""
          end %>
     p.customize ["modifyvm", :id, "--cpuidset", <%= ids.join(', ') %>]
+    <% elsif key == :default_nic_type %>
+    p.default_nic_type = "<%= value %>"
     <% else %>
     p.customize ["modifyvm", :id, "--<%= key %>", "<%= value %>"]
     <% end %>

Expected Output

In the generated vagrant file (given the patch and config sample above, we now see:

Vagrant.configure("2") do |c|
  c.berkshelf.enabled = false if Vagrant.has_plugin?("vagrant-berkshelf")
  c.vm.box = "ubuntu/bionic64"
  c.vm.hostname = "default-ubuntu-bionic64.vagrantup.com"
  c.vm.synced_folder ".", "/vagrant", disabled: true
  c.vm.provider :virtualbox do |p|
    p.name = "kitchen-ami-confluence-default-ubuntu-bionic64"
    p.default_nic_type = "virtio"
  end
end

So the patch seems to work, the warning from vagrant goes away.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions