Add config for FreeBSD guest plugin. Allow device to be configurable
This commit is contained in:
parent
0dc40e1680
commit
cc343d1a7d
|
@ -13,7 +13,8 @@ module VagrantPlugins
|
||||||
machine.communicate.sudo("sed -i '' -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/rc.conf", {:shell => "sh"})
|
machine.communicate.sudo("sed -i '' -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/rc.conf", {:shell => "sh"})
|
||||||
|
|
||||||
networks.each do |network|
|
networks.each do |network|
|
||||||
entry = TemplateRenderer.render("guests/freebsd/network_#{network[:type]}",
|
device = "#{machine.config.freebsd.device}#{network[:interface]}"
|
||||||
|
entry = TemplateRenderer.render("guests/freebsd/network_#{network[:type]}",
|
||||||
:options => network)
|
:options => network)
|
||||||
|
|
||||||
# Write the entry to a temporary location
|
# Write the entry to a temporary location
|
||||||
|
@ -27,9 +28,9 @@ module VagrantPlugins
|
||||||
machine.communicate.sudo("rm /tmp/vagrant-network-entry", {:shell => "sh"})
|
machine.communicate.sudo("rm /tmp/vagrant-network-entry", {:shell => "sh"})
|
||||||
|
|
||||||
if network[:type].to_sym == :static
|
if network[:type].to_sym == :static
|
||||||
machine.communicate.sudo("ifconfig em#{network[:interface]} inet #{network[:ip]} netmask #{network[:netmask]}", {:shell => "sh"})
|
machine.communicate.sudo("ifconfig #{device} inet #{network[:ip]} netmask #{network[:netmask]}", {:shell => "sh"})
|
||||||
elsif network[:type].to_sym == :dhcp
|
elsif network[:type].to_sym == :dhcp
|
||||||
machine.communicate.sudo("dhclient em#{network[:interface]}", {:shell => "sh"})
|
machine.communicate.sudo("dhclient #{device}", {:shell => "sh"})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
module VagrantPlugins
|
||||||
|
module GuestFreeBSD
|
||||||
|
class Config < Vagrant.plugin("2", :config)
|
||||||
|
attr_accessor :device
|
||||||
|
|
||||||
|
def initialize
|
||||||
|
@device = "em"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -6,6 +6,11 @@ module VagrantPlugins
|
||||||
name "FreeBSD guest"
|
name "FreeBSD guest"
|
||||||
description "FreeBSD guest support."
|
description "FreeBSD guest support."
|
||||||
|
|
||||||
|
config("freebsd") do
|
||||||
|
require File.expand_path("../config", __FILE__)
|
||||||
|
Config
|
||||||
|
end
|
||||||
|
|
||||||
guest("freebsd") do
|
guest("freebsd") do
|
||||||
require File.expand_path("../guest", __FILE__)
|
require File.expand_path("../guest", __FILE__)
|
||||||
Guest
|
Guest
|
||||||
|
|
Loading…
Reference in New Issue