re-implemented redhat distribution of host only network with additional check to see if network interface is up as on intial setup when not using dhcp the interface will be down as dhcp lookup will time out. To prevent vagrant time out on boot you need to add file /etc/dhclient.conf with value content timeout 1; to guest this is beacuse the default is 60 seconds this should be done in the base box
This commit is contained in:
parent
8b6d63ab58
commit
eda6b81093
|
@ -25,8 +25,8 @@ module Vagrant
|
||||||
|
|
||||||
if enable_network?
|
if enable_network?
|
||||||
@env.ui.info I18n.t("vagrant.actions.vm.network.enabling")
|
@env.ui.info I18n.t("vagrant.actions.vm.network.enabling")
|
||||||
@env["vm"].system.prepare_host_only_network
|
|
||||||
@env.env.config.vm.network_options.compact.each do |network_options|
|
@env.env.config.vm.network_options.compact.each do |network_options|
|
||||||
|
@env["vm"].system.prepare_host_only_network(network_options)
|
||||||
@env["vm"].system.enable_host_only_network(network_options)
|
@env["vm"].system.enable_host_only_network(network_options)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,3 +6,4 @@ require 'vagrant/systems/solaris'
|
||||||
|
|
||||||
require 'vagrant/systems/debian'
|
require 'vagrant/systems/debian'
|
||||||
require 'vagrant/systems/gentoo'
|
require 'vagrant/systems/gentoo'
|
||||||
|
require 'vagrant/systems/redhat'
|
||||||
|
|
|
@ -68,7 +68,7 @@ module Vagrant
|
||||||
|
|
||||||
# Prepares the system for host only networks. This is called
|
# Prepares the system for host only networks. This is called
|
||||||
# once prior to any `enable_host_only_network` calls.
|
# once prior to any `enable_host_only_network` calls.
|
||||||
def prepare_host_only_network
|
def prepare_host_only_network(net_options = nil)
|
||||||
raise BaseError, :_key => :unsupported_host_only
|
raise BaseError, :_key => :unsupported_host_only
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
module Vagrant
|
module Vagrant
|
||||||
module Systems
|
module Systems
|
||||||
class Debian < Linux
|
class Debian < Linux
|
||||||
def prepare_host_only_network
|
def prepare_host_only_network(net_options = nil)
|
||||||
# Remove any previous host only network additions to the
|
# Remove any previous host only network additions to the
|
||||||
# interface file.
|
# interface file.
|
||||||
vm.ssh.execute do |ssh|
|
vm.ssh.execute do |ssh|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
module Vagrant
|
module Vagrant
|
||||||
module Systems
|
module Systems
|
||||||
class Gentoo < Linux
|
class Gentoo < Linux
|
||||||
def prepare_host_only_network
|
def prepare_host_only_network(net_options = nil)
|
||||||
# Remove any previous host only network additions to the
|
# Remove any previous host only network additions to the
|
||||||
# interface file.
|
# interface file.
|
||||||
vm.ssh.execute do |ssh|
|
vm.ssh.execute do |ssh|
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
module Vagrant
|
module Vagrant
|
||||||
module Systems
|
module Systems
|
||||||
class Redhat < Linux
|
class Redhat < Linux
|
||||||
def prepare_host_only_network(net_options = nil)
|
def prepare_host_only_network(net_options)
|
||||||
# Remove any previous host only network additions to the
|
# Remove any previous host only network additions to the
|
||||||
# interface file.
|
# interface file.
|
||||||
vm.ssh.execute do |ssh|
|
vm.ssh.execute do |ssh|
|
||||||
# Clear out any previous entries
|
# Clear out any previous entries
|
||||||
#ssh.exec!("sudo sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/sysconfig/network-scripts/ifcfg-eth#{net_options[:adapter]} > /tmp/vagrant-ifcfg-eth#{net_options[:adapter]}")
|
ssh.exec!("sudo sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/sysconfig/network-scripts/ifcfg-eth#{net_options[:adapter]} > /tmp/vagrant-ifcfg-eth#{net_options[:adapter]}")
|
||||||
#ssh.exec!("sudo su -c 'cat /tmp/vagrant-ifcfg-eth#{net_options[:adapter]} > /etc/sysconfig/network-scripts/ifcfg-eth#{net_options[:adapter]}'")
|
ssh.exec!("sudo su -c 'cat /tmp/vagrant-ifcfg-eth#{net_options[:adapter]} > /etc/sysconfig/network-scripts/ifcfg-eth#{net_options[:adapter]}'")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -17,7 +17,8 @@ module Vagrant
|
||||||
vm.ssh.upload!(StringIO.new(entry), "/tmp/vagrant-network-entry")
|
vm.ssh.upload!(StringIO.new(entry), "/tmp/vagrant-network-entry")
|
||||||
|
|
||||||
vm.ssh.execute do |ssh|
|
vm.ssh.execute do |ssh|
|
||||||
ssh.exec!("sudo /sbin/ifdown eth#{net_options[:adapter]} 2> /dev/null")
|
interface_up = ssh.test?("/sbin/ifconfig eth#{net_options[:adapter]} | grep 'inet addr:'")
|
||||||
|
ssh.exec!("sudo /sbin/ifdown eth#{net_options[:adapter]} 2> /dev/null") if interface_up
|
||||||
ssh.exec!("sudo su -c 'cat /tmp/vagrant-network-entry >> /etc/sysconfig/network-scripts/ifcfg-eth#{net_options[:adapter]}'")
|
ssh.exec!("sudo su -c 'cat /tmp/vagrant-network-entry >> /etc/sysconfig/network-scripts/ifcfg-eth#{net_options[:adapter]}'")
|
||||||
ssh.exec!("sudo /sbin/ifup eth#{net_options[:adapter]}")
|
ssh.exec!("sudo /sbin/ifup eth#{net_options[:adapter]}")
|
||||||
end
|
end
|
||||||
|
|
|
@ -60,6 +60,7 @@ module Vagrant
|
||||||
mapping = {
|
mapping = {
|
||||||
:debian => Systems::Debian,
|
:debian => Systems::Debian,
|
||||||
:gentoo => Systems::Gentoo,
|
:gentoo => Systems::Gentoo,
|
||||||
|
:redhat => Systems::Redhat,
|
||||||
:linux => Systems::Linux,
|
:linux => Systems::Linux,
|
||||||
:solaris => Systems::Solaris
|
:solaris => Systems::Solaris
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue