Fetch first network device and pass to template for rendering
This commit is contained in:
parent
c3ba13cd4d
commit
2f5e15da55
|
@ -15,11 +15,12 @@ module VagrantPlugins
|
|||
entries = []
|
||||
interfaces = machine.guest.capability(:network_interfaces)
|
||||
|
||||
root_device = interfaces.first
|
||||
networks.each do |network|
|
||||
network[:device] = interfaces[network[:interface]]
|
||||
|
||||
entry = TemplateRenderer.render("guests/debian/network_#{network[:type]}",
|
||||
options: network,
|
||||
options: network.merge(:root_device => root_device),
|
||||
)
|
||||
entries << entry
|
||||
end
|
||||
|
|
|
@ -6,8 +6,8 @@ iface <%= options[:device] %> inet dhcp
|
|||
post-up route del default dev $IFACE || true
|
||||
<% else %>
|
||||
# We need to disable eth0, see GH-2648
|
||||
post-up route del default dev $IFACE || true
|
||||
post-up route del default dev <%= options[:root_device] %> || true
|
||||
post-up dhclient $IFACE
|
||||
pre-down route add default dev $IFACE
|
||||
pre-down route add default dev <%= options[:root_device] %>
|
||||
<% end %>
|
||||
#VAGRANT-END
|
||||
|
|
|
@ -23,6 +23,7 @@ describe "templates/guests/debian/network_dhcp" do
|
|||
it "renders the template" do
|
||||
result = Vagrant::Util::TemplateRenderer.render(template, options: {
|
||||
device: "eth1",
|
||||
root_device: "eth0",
|
||||
use_dhcp_assigned_default_route: true,
|
||||
})
|
||||
expect(result).to eq <<-EOH.gsub(/^ {8}/, "")
|
||||
|
@ -31,9 +32,9 @@ describe "templates/guests/debian/network_dhcp" do
|
|||
auto eth1
|
||||
iface eth1 inet dhcp
|
||||
# We need to disable eth0, see GH-2648
|
||||
post-up route del default dev $IFACE || true
|
||||
post-up route del default dev eth0 || true
|
||||
post-up dhclient $IFACE
|
||||
pre-down route add default dev $IFACE
|
||||
pre-down route add default dev eth0
|
||||
#VAGRANT-END
|
||||
EOH
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue